# create-management-page

Adopt this skill: https://proskills.md/skills/other/clawpage-clawpage-skill-skills-create-management-page

Page: https://proskills.md/skills/other/clawpage-clawpage-skill-skills-create-management-page
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: skills/create-management-page/SKILL.md
size: 8050
upstream: https://github.com/clawpage/clawpage-skill/blob/main/skills/create-management-page/SKILL.md

````text
---
name: create-management-page
description: >-
  Create or refresh a read-only dashboard listing all of the user's clawpage
  pages. Trigger keywords — "管理页", "页面管理", "列出所有页面",
  "pages dashboard", "admin page", "read-only page list", "manage all my
  pages". Default policy is 3h TTL plus pagecode-protected. SECURITY-CRITICAL
  — never embed `sk_*` tokens in browser-shipped JS, even on a
  pagecode-protected page.
---

# Clawpage Create/Update Management Page

## When to use

- User wants a page that displays all pages they have created
- User expects read-only management view (no edit/delete actions from UI)
- User asks to create or refresh the current management page

## Data-flow rule

> The default workflow pre-fetches page data **at publish time via the `pages --list` CLI command** (see Workflow step 3) and inlines the JSON into the static HTML. The rendered management page makes **zero live API calls from the browser**, ships **zero tokens**, and requires no SDK.
>
> **Never embed an `sk_*` owner token into browser-shipped JS — even on a pagecode-protected page.** Pagecodes can be shared, page HTML can be inspected, browser caches persist, and any leak gives full account control. There is currently no token-scoping primitive that can safely live in the browser.

### Refresh strategies

If the user asks to "refresh now" without re-publishing, pick the **least-privilege** option that meets their need:

1. **Republish (recommended default).** Treat refresh as a new publish run — re-fetch via CLI, re-render HTML, `npx -y @clawpage.ai/cli publish --page-id [PAGE_ID]`. Token never leaves the CLI / your machine. This is what every other Clawpage page does.
2. **Manual refresh button → CLI hint.** Render a button that copies the republish command to clipboard or links to a docs section; user runs it from their terminal.
3. **Public-data-only auto-refresh.** If the page only needs to refresh `public` data tables / public stats endpoints, embed the SDK **without any token** — anonymous public reads are safe even on a publicly accessible page.

**Forbidden:** any code that ships an `sk_*` token to the browser, including:
- `const c = new Clawpage({ token: "sk_..." })` in inline `<script>` tags
- token in `localStorage` / `sessionStorage` / cookies set by the page
- token in `data-*` attributes or HTML comments

## Inputs and conventions

- Management page directory (preferred fixed path): `~/.clawpage/pages/page-management-center`
- Management page bootstrap template (default): `general_template` (shipped with `@clawpage.ai/cli`; copy via `npx -y @clawpage.ai/cli scaffold general_template <target>`)
- Publish script: ``npx -y @clawpage.ai/cli publish``
- API reference: `references/api-quickref.md`
- Shared contracts: `references/prompt-contracts.md`
- Security defaults (unless user explicitly overrides):
  - `ttlMs = 10800000` (3 hours)
  - must be password protected (`pagecode` must not be null/empty)

## Workflow

1. Resolve `[MANAGEMENT_PAGE_DIR]` once:
- A valid management-page project must satisfy both:
  - has `meta.md`
  - `meta.md` contains `metadata.management_page: true`
- Preferred path: `~/.clawpage/pages/page-management-center`
- If the preferred path does not exist or lacks the marker, scan both `~/.clawpage/pages/*/meta.md` and `./.pages/*/meta.md` for projects satisfying the rule and pick one deterministic path.
- If none found, initialize a new project:
  - if `~/.clawpage/pages/page-management-center` does not exist: use it.
  - if it exists but lacks the marker: use `~/.clawpage/pages/page-management-center-v2` (or next available `-vN`). Project-scoped equivalent: `./.pages/page-management-center` / `-vN`.

**Note:** Replace `[MANAGEMENT_PAGE_DIR]` with the resolved path. The CLI accepts bare names (`page-management-center` → `~/.clawpage/pages/page-management-center`) and cwd-relative paths.

```bash
npx -y @clawpage.ai/cli scaffold general_template [MANAGEMENT_PAGE_DIR]
```

2. Ensure metadata in `[MANAGEMENT_PAGE_DIR]/meta.md` is explicit:
- `metadata.name`
- `metadata.description`
- required marker: `metadata.management_page: true`

3. Pull latest page list via the CLI (token cascade is handled internally — no need to read `keys.local.json` or set headers manually):
```bash
npx -y @clawpage.ai/cli pages --list --all
```
- Output is JSON on stdout: `{ items, total, fetchedPages, mode, dataFetchedAt }`. Each item includes `pageId`, `pageName`, `rootUrl`, `publicUrl`, `currentVersion`, `expiresAt`, `passwordProtected` — exactly the fields the UI needs.
- Reuse the top-level `dataFetchedAt` (ISO) directly — do NOT generate your own timestamp; the CLI emits it at fetch time.
- The management page stays static — the rendered HTML ships with the data pre-inlined; it does NOT re-fetch in the browser. If the user explicitly asks for live refresh or edit actions, switch that surface to the Browser SDK per `the `use-sdk` skill` (and note the `/api/pages` SDK gap).
- For very large accounts where you only want a window: `--list --limit 50 --page 1` (omit `--all`).

4. Build a high-quality read-only UI (refer to `references/design-guidelines.md`):
- **Recommended tone:** professional / tech-dashboard — data-focused layout with clear hierarchy.
- clarity: search/filter/sort/read-only cards or table.
- no mutation controls (no delete/update API buttons).
- expose share-relevant URLs and protection/expiry summaries.
- show data acquisition time in the header: `Data fetched at: <dataFetchedAt> (<timezone>)`
- apply distinctive fonts and cohesive color palette per design guidelines.
- add page-load stagger animations for the page card list.

5. Apply localization/output contracts from `references/prompt-contracts.md`.

6. Pre-publish hard checks (must pass):
- `meta.md` metadata complete.
- required placeholders preserved.
- dry-run succeeds.

7. Publish:
- **Identify PAGE_ID**: Use `read_file` to read `[MANAGEMENT_PAGE_DIR]/meta.md` and extract `metadata.page_id` from the YAML frontmatter. Do not use fragile shell regex.
- **Identify PAGECODE**: If creating or if a reset is needed, generate a 6-8 character random safe string (e.g., base64url or alphanumeric).

- **Create mode** (if `page_id` is missing):
```bash
npx -y @clawpage.ai/cli publish \
  --page-dir [MANAGEMENT_PAGE_DIR] \
  --title "[TITLE]" \
  --subtitle "[SUBTITLE]" \
  --ttl-ms 10800000 \
  --pagecode "[GENERATED_PAGECODE]"
```
- Write back the returned `pageId` to `metadata.page_id` in `[MANAGEMENT_PAGE_DIR]/meta.md`.

- **Update mode** (if `page_id` exists):
```bash
npx -y @clawpage.ai/cli publish \
  --page-dir [MANAGEMENT_PAGE_DIR] \
  --page-id "[PAGE_ID]" \
  --title "[TITLE]" \
  --subtitle "[SUBTITLE]" \
  --ttl-ms 10800000
```
- *Note:* Add `--pagecode "[GENERATED_PAGECODE]"` only if rotating password or enforcing security on a previously public page.

8. Return fixed output fields from `references/prompt-contracts.md`.

9. Mandatory post-publish reminder:
- state: "This management page is valid for 3 hours by default and is password protected."
- include actual values: `ttlMsApplied`, `expiresAt`, `pagecodeProtected`, `pagecode`, `dataFetchedAt`.

## Failure handling (error code -> action)

- `LOCAL_KEYS_FILE_MISSING` or `LOCAL_TOKEN_MISSING` -> **stop and confirm with the user before registering.** Show:
  > "No Clawpage account is configured. To create a management page I need to register a new account. This creates a long-lived API token at `~/.clawpage/keys.local.json`. Proceed? (yes / pick a username / cancel)"
  
  Only run `npx -y @clawpage.ai/cli init` after explicit `yes`.
- `UNAUTHORIZED` -> verify token in `./keys.local.json`, then retry.
- `PAGE_NOT_FOUND` -> verify bound `pageId`; if missing/invalid, create once then persist returned `pageId`.
- `USERNAME_TAKEN` (register flow) -> propose 3 alternatives, user picks one, retry register.
- `IP_DAILY_REGISTRATION_LIMIT_REACHED` -> stop and ask user to retry next day or use existing account.
- `OWNER_DAILY_PAGE_
````

## File: README.md
upstream: https://github.com/clawpage/clawpage-skill/blob/main/README.md

````text
# clawpage

A coding-agent plugin for [Clawpage](https://clawpage.ai) — generative UI hosting that turns single-file HTML pages into public URLs. Use it from Claude Code, Codex, or Gemini CLI.

> **v1.0.0**: skills are now flat and independently invocable (one router was previously the entry point; that pattern has been replaced). Each skill self-describes when to trigger.

## What you can do

- Convert long stock-market analysis text into a chart-driven dashboard
- Build insight hubs, utility tools, and interactive mini apps
- Update existing pages by `pageId` with new content / style / behavior
- Add server-side state to a page: comments, counters, KV data, short links, blob storage
- Track view counts per page / homepage / short link
- Author and update reusable templates

## Skills

Each skill is independently invocable by name. Coding agents auto-pick the right one based on user intent; you can also reference them directly (e.g. `clawpage:create-page`).

| Skill | Use when |
|---|---|
| `clawpage:init` | First-time setup on a machine — register an account + save token. Idempotent. |
| `clawpage:create-page` | Brand-new page. Default: private + 3h TTL. |
| `clawpage:update-page` | Republish an existing page (you have its `pageId` or local project). |
| `clawpage:delete-page` | Permanently delete a page by `pageId`. Irreversible — confirms first. |
| `clawpage:create-management-page` | Read-only dashboard listing all your pages. |
| `clawpage:create-template` / `clawpage:update-template` | Author or evolve a reusable template. |
| `clawpage:manage-data` | Per-user KV data tables (comments, counters, configs, lightweight CMS). |
| `clawpage:manage-links` | Short links `clawpage.ai/s/<slug>` → `*.clawpage.ai`. |
| `clawpage:manage-blobs` | Upload images / files to R2, get public `blob.clawpage.ai/<id>` URLs. |
| `clawpage:view-stats` | Page-view counts and per-day series. |
| `clawpage:use-sdk` | Embed the Browser SDK so a page can call clawpage APIs without exposing tokens. |

## Slash commands

- `/clawpage-init` — initialize on this machine
- `/clawpage-publish` — convert current response into a hosted clawpage page
- `/clawpage-stats` — show traffic for your pages

## Install

The plugin shells out to [`@clawpage.ai/cli`](https://www.npmjs.com/package/@clawpage.ai/cli) (the runtime), so you only need this plugin loaded — `npx` fetches the cli on demand.

### Claude Code

```text
/plugin marketplace add https://github.com/clawpage/clawpage-skill
/plugin install clawpage
```

Updates: `/plugin update clawpage`.

### Codex

```bash
npx codex-marketplace add clawpage/clawpage-skill --plugin --global
```

The plugin manifest lives at `.codex-plugin/plugin.json`. `--global` registers it in your Codex user config; drop the flag for project-scoped install.

### Gemini CLI

```bash
gemini extensions install https://github.com/clawpage/clawpage-skill
```

The repo ships `gemini-extension.json` at the root.

## Supply-chain note

The plugin invokes `npx -y @clawpage.ai/cli@<latest>` by default. **npm package code from `@clawpage.ai/cli` will execute on your machine** the first time you trigger any skill. Three layers of trust:

1. **Source**: cli source at [github.com/clawpage/clawpage-cli](https://github.com/clawpage/clawpage-cli), MIT licensed. Audit before first run if you want.
2. **Provenance**: every npm release ≥ `0.3.0` ships [npm provenance](https://docs.npmjs.com/generating-provenance-statements) attestations linking the tarball to the GitHub commit it was built from. `npm view @clawpage.ai/cli@<version>` shows the link.
3. **Pin a version**: in your local copy of any SKILL.md, replace `npx -y @clawpage.ai/cli` with `npx -y @clawpage.ai/cli@0.5.0` (or whichever you've audited). Updates become opt-in.

If you'd rather avoid `npx` entirely: `npm install -g @clawpage.ai/cli@0.5.0` once, then change SKILL.md commands from `npx -y @clawpage.ai/cli ...` to `clawpage ...`.

## First-time auth

Trigger the `init` skill once:

```text
Init clawpage.
```

This runs `npx -y @clawpage.ai/cli init`, registers a fresh account, and writes your API token to `~/.clawpage/keys.local.json`. After that, every subsequent skill invocation works from any directory.

To set the token manually instead:

```bash
mkdir -p ~/.clawpage
cat > ~/.clawpage/keys.local.json <<'EOF'
{
  "clawpage": {
    "token": "sk_xxx",
    "apiHost": "https://api.clawpage.ai"
  }
}
EOF
```

## Example: long stock analysis → visual page

```text
Build a clawpage dashboard from this market note. Requirements:
1) extract 5 key conclusions
2) include KPI cards and 7D/30D/90D trend switching
3) mobile-first layout
4) publish and return publicUrl, rootUrl, accessUrl, pageId, expiresAt
```

Workflow:
- skill picks `stock-analysis-terminal` template
- transforms raw text into structured modules (summary, risks, observations)
- `npx -y @clawpage.ai/cli scaffold stock-analysis-terminal <page-name>` → `~/.clawpage/pages/<page-name>/`
- `npx -y @clawpage.ai/cli publish --page-dir <page-name> ...`
- returns the URL set + expiry info

## Template catalog

Shipped with `@clawpage.ai/cli`. List at runtime: `npx -y @clawpage.ai/cli scaffold --list`.

- `general_template`
- `stock-analysis-terminal`
- `insight-collection-hub`
- `utility-workbench`
- `concept-animation-lab`
- `mini-game-arcade`

## Direct CLI usage

Dry-run a template bundle (no publish, no auth required):

```bash
npx -y @clawpage.ai/cli scaffold general_template /tmp/preview
npx -y @clawpage.ai/cli publish --page-dir /tmp/preview --title "Preview" --dry-run
```

Publish a page project:

```bash
npx -y @clawpage.ai/cli publish \
  --page-dir my-dashboard \
  --title "My Page" \
  --subtitle "Optional"
```

Common flags: `--page-id <id>`, `--ttl-ms <n|null>`, `--pagecode <text|null>`, `--page-name <text>`, `--dry-run`.

## Security

- `~/.clawpage/keys.local.json` holds your `sk_*` owner token. Never commit it; never paste into a public Clawpage page (it would steal the whole account).
- Project-scoped `./keys.local.json` (cwd) takes precedence over the global one — handy for per-project accounts.
- The `init` skill is **idempotent**: calling it when already initialized is a no-op. Switching accounts requires `--force` and explicit user confirmation; pages owned by the previous account are not deleted but become unreachable from this machine.

## License

MIT-0 (MIT No Attribution). See `LICENSE`.
````
