Project Handbook
Generate a complete project handbook with two audiences served by ONE set of files:
- Humans open
docs-site/index.html (via the launch script) — a navigable site with
architecture diagrams (Mermaid) and a health dashboard.
- AI agents read
docs-site/data/*.md and *.json directly — they ARE the site's
content. There is no separate "AI version" to keep in sync.
The viewer template (index.html, assets/, serve.cjs, launch scripts) is copied once
and never modified afterwards. All maintenance happens in data/ only.
Scope
Designed for JS/TS projects (npm / pnpm / yarn). For other ecosystems, tell the user
the scan phase is JS/TS-specific and offer to proceed with AI-only analysis (no tool
data) — health facets that depend on missing tools get status: "unknown".
Output language
The handbook content language follows the user's convention: check the user's
CLAUDE.md language, the language of their messages, and existing project docs. A
Traditional-Chinese-speaking user gets a 繁體中文 handbook; an English speaker gets
English. Viewer UI strings and file names stay English. When unsure, ask.
Workflow
Track phases with the task tools. Phases run in order.
Phase 0 — Existing handbook check
If docs-site/ already exists in the target project, do NOT silently overwrite. Ask the
user (AskUserQuestion) with these options, recommending the first:
- Audit & refresh (default) — diff-driven, token-efficient. Procedure:
- Read the baseline
commit from data/manifest.js. Run
git diff --name-status <baseline>..HEAD and git log --oneline <baseline>..HEAD.
If the baseline is unreachable (rebase, squash, shallow clone) or there is no git
history, fall back to a full audit of every section.
- Map changed files to affected sections (e.g. route/state/API files →
architecture; package.json scripts, configs, lockfile → dev-guide; API-layer
files → integration; setup files → onboarding). Deep-read and fix only the
affected sections.
- Sections with no related changes are proven current by the diff itself — keep
their content and
updatedAt untouched; do not re-read them.
- Always re-run the full Phase 1 scan to refresh
health.json (tool-driven, cheap).
- Interview-sourced content (
deployment, collaboration) is not derivable from a
code diff — just re-ask previously unanswered "⚠️ To confirm" items.
- Preserve hand-written content; never touch template files. Update manifest
generatedAt/commit to the new baseline; bump a section's updatedAt only if
its content actually changed (see freshness contract, Phase 4).
- In the final report, state which sections were re-checked and which were skipped
because the diff proved them unchanged.
- Skip — existing handbook is fine; stop.
- Regenerate — full rewrite; only when the user confirms nothing is worth keeping.
If docs-site/ does not exist, continue to Phase 1.
Phase 1 — Automated scan (tools first, AI fallback)
Principle: prefer real tool output; fall back to AI code-reading only when a tool cannot
run, and record which sources were actually used in health.json meta.toolsUsed.
A facet with no reliable data gets status: "unknown" — never invent numbers.
| Facet |
Primary commands |
AI fallback |
code-health |
line counts of tracked source files (git ls-files + count); npx -y knip --no-progress --reporter compact for unused exports/files |
read the largest files; note dead/commented-out code seen while reading |
dependencies |
npm outdated --json; npm audit --json (or pnpm/yarn equivalents — detect via lockfile) |
compare package.json ranges against lockfile |
git-hotspots |
git log --since="12 months ago" --pretty=format: --name-only aggregated per file (top ~20); git shortlog -sn; files untouched ≥ 12 months in active dirs |
skip facet with unknown if no git history |
testing |
count test files (*.test.*, *.spec.*, __tests__/); run coverage only if a coverage script already exists; npx tsc --noEmit if tsconfig present; eslint error count if config present |
map test files against key logic areas (payment, auth, data writes) and name untested ones |
Write results into data/health.json following references/health-schema.md.
Cross-link insights between facets (e.g. a file that is both oversized AND a git hotspot
deserves a warn item saying so).
Phase 2 — Architecture read
Read the project deeply enough to produce CORRECT diagrams and a navigable guide:
entry points, routing, state management, API layer, module boundaries, build setup.
Draft (as Mermaid flowchart) at minimum: a system map (frontend ↔ backend ↔ external
services) and a frontend data-flow diagram. Verify every path/name you write actually
exists — diagrams with wrong names are worse than no diagrams.
Phase 3 — Interview (knowledge that is NOT in the code)
Enumerate once, then batch-ask. Never drip-feed questions one at a time.
- From Phases 1–2 findings, build ONE complete question list, customized to the project
(e.g. found an axios baseURL pointing to a domain → ask who owns that backend and
where its docs live; found a Dockerfile → ask where images are deployed).
- Standard categories (adapt, drop irrelevant ones):
- Deployment — where does it run (VPS/cloud/on-prem)? how does a release happen?
who has access? rollback procedure?
- Backend & integrations — who owns each upstream API? staging environments?
API docs location? auth model?
- Team workflow — how do designs arrive (Figma? specs?)? code review rules?
who decides priorities? release cadence?
- Infrastructure — machine specs, memory/capacity limits, monitoring/alerting,
logs location?
- Operations — who are the users? peak hours? known recurring incidents?
- Ask via AskUserQuestion, grouped by category, a few questions per round.
- The user may not know answers. Mark those ⚠️ To confirm and add a concrete
pointer: who to ask / where to look (e.g. "ask whoever owns the CI config",
"check the cloud console billing page"). Collect all of these into a "To-confirm
list" in the relevant data file. Never present a guess as fact.
Phase 4 — Generate the handbook
- Copy the template: everything in this skill's
template/ directory →
<project>/docs-site/ (creating it). On macOS/Linux also chmod +x docs-site/open-handbook.sh.
- Write
data/manifest.js:
window.HANDBOOK_MANIFEST = {
project: "<Project Name>",
generatedAt: "<YYYY-MM-DD>", // date of this generation or audit run
commit: "<short hash>", // code baseline this handbook was verified against
language: "<content language code>",
sections: [
{ id: "overview", title: "...", file: "overview.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },
{ id: "architecture", title: "...", file: "architecture.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },
{ id: "dev-guide", title: "...", file: "dev-guide.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },
{ id: "deployment", title: "...", file: "deployment.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },
{ id: "integration", title: "...", file: "integration.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },
{ id: "collaboration", title: "...", file: "collaboration.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },
{ id: "onboarding", title: "...", file: "onboarding.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },
{ id: "health", title: "...", file: "health.json", type: "health", updatedAt: "<YYYY-MM-DD>" }
]
};
Section titles are written in the content language. The list above is the default
skeleton — scale to the project: a frontend-only demo with no backend merges
integration into architecture; drop collaboration for a solo project. Every
section in the manifest must have a corresponding file.
Freshness contract: generatedAt and commit describe the latest run (initial
generation OR audit). Each section's updatedAt is the date its CONTENT last
changed. On an audit run, update generatedAt/commit always, but bump a section's
updatedAt only if you actually edited that file — sections verified-but-unchanged
keep their old updatedAt. The viewer shows "Updated · verified at
" under each page title.
- Write the
data/*.md files. Content guide:
overview.md — what the project is, who uses it, what problem it solves. Mostly
interview-sourced.
architecture.md — the Phase 2 diagrams + module map table with real paths.
dev-guide.md — how to run it locally (verified commands), conventions, branch
strategy.
deployment.md — where it runs, how releases happen, capacity. Interview-sourced;
this is where most ⚠️ To confirm items usually live.
integration.md — upstream APIs, external services, who owns them. Scan + interview.
collaboration.md — design handoff, review rules, team workflow. Interview-sourced.
onboarding.md — a new developer's day one: environment → run it → make a first
small change (point at a real, easy file).
- Markdown rules: GitHub-flavored; Mermaid in fenced ```mermaid blocks; use
file:line references for code pointers; do not paste long code excerpts.
- Write
data/health.json from Phase 1 results (schema: references/health-schema.md).
- Add a pointer to the project's CLAUDE.md (create if missing, append if present):
## Project handbook
`docs-site/data/` holds this project's handbook as markdown/JSON — read it for
architecture, deployment, and team context. Humans: run `docs-site/open-handbook.bat`
(Windows) or `docs-site/open-handbook.sh` (macOS/Linux) to browse it.
Phase 5 — Verify & report
- Start the server (
node docs-site/serve.cjs 8787, background) and verify:
/, /data/manifest.js, and every file referenced in the manifest return 200.
- If a browser tool (e.g. Playwright) is available, screenshot the architecture and
health pages and confirm Mermaid diagrams rendered as SVG (not raw text). Otherwise,
tell the user to open the handbook and check the diagrams.
- Spot-check
file:line and path references in the data files against the real code.
- Report to the user: deliverables list, one-line health summary per facet, and the
complete ⚠️ To-confirm list with its "who to ask / where to look" pointers.
Honesty rules
- Tool didn't run → facet is
unknown, and meta.toolsUsed reflects reality.
- User couldn't answer → ⚠️ To confirm, never a guess dressed as fact.
- Bugs or risks noticed while reading code → report them; don't silently fix anything.
- This skill reports health; it does not refactor, upgrade, or fix.
1---2name: project-handbook3description: Generate a dual-audience project handbook for JS/TS projects: scan code health, dependencies, git hotspots and test gaps; interview the user for knowledge that lives outside the code (deployment, backend integration, team workflow, infrastructure); output a browsable HTML handbook for humans backed by markdown/JSON data files that AI agents read directly. Use when the user says "project handbook", "onboarding doc", "project health report", "document this project for humans", "幫專案做手冊", "新人文件", "專案體檢", "產專案手冊", or wants documentation that covers how the project is deployed and developed — not just what the code contains.4---56# Project Handbook78Generate a complete project handbook with two audiences served by ONE set of files:910- **Humans** open `docs-site/index.html` (via the launch script) — a navigable site with11 architecture diagrams (Mermaid) and a health dashboard.12- **AI agents** read `docs-site/data/*.md` and `*.json` directly — they ARE the site's13 content. There is no separate "AI version" to keep in sync.1415The viewer template (`index.html`, `assets/`, `serve.cjs`, launch scripts) is copied once16and **never modified afterwards**. All maintenance happens in `data/` only.1718## Scope1920Designed for **JS/TS projects** (npm / pnpm / yarn). For other ecosystems, tell the user21the scan phase is JS/TS-specific and offer to proceed with AI-only analysis (no tool22data) — health facets that depend on missing tools get `status: "unknown"`.2324## Output language2526The handbook **content** language follows the user's convention: check the user's27CLAUDE.md language, the language of their messages, and existing project docs. A28Traditional-Chinese-speaking user gets a 繁體中文 handbook; an English speaker gets29English. Viewer UI strings and file names stay English. When unsure, ask.3031## Workflow3233Track phases with the task tools. Phases run in order.3435### Phase 0 — Existing handbook check3637If `docs-site/` already exists in the target project, do NOT silently overwrite. Ask the38user (AskUserQuestion) with these options, recommending the first:39401. **Audit & refresh** (default) — diff-driven, token-efficient. Procedure:41 1. Read the baseline `commit` from `data/manifest.js`. Run42 `git diff --name-status <baseline>..HEAD` and `git log --oneline <baseline>..HEAD`.43 If the baseline is unreachable (rebase, squash, shallow clone) or there is no git44 history, fall back to a full audit of every section.45 2. Map changed files to affected sections (e.g. route/state/API files →46 `architecture`; package.json scripts, configs, lockfile → `dev-guide`; API-layer47 files → `integration`; setup files → `onboarding`). **Deep-read and fix only the48 affected sections.**49 3. Sections with no related changes are proven current by the diff itself — keep50 their content and `updatedAt` untouched; do not re-read them.51 4. Always re-run the full Phase 1 scan to refresh `health.json` (tool-driven, cheap).52 5. Interview-sourced content (`deployment`, `collaboration`) is not derivable from a53 code diff — just re-ask previously unanswered "⚠️ To confirm" items.54 6. Preserve hand-written content; never touch template files. Update manifest55 `generatedAt`/`commit` to the new baseline; bump a section's `updatedAt` only if56 its content actually changed (see freshness contract, Phase 4).57 7. In the final report, state which sections were re-checked and which were skipped58 because the diff proved them unchanged.592. **Skip** — existing handbook is fine; stop.603. **Regenerate** — full rewrite; only when the user confirms nothing is worth keeping.6162If `docs-site/` does not exist, continue to Phase 1.6364### Phase 1 — Automated scan (tools first, AI fallback)6566Principle: prefer real tool output; fall back to AI code-reading only when a tool cannot67run, and record which sources were actually used in `health.json` `meta.toolsUsed`.68A facet with no reliable data gets `status: "unknown"` — never invent numbers.6970| Facet | Primary commands | AI fallback |71|---|---|---|72| `code-health` | line counts of tracked source files (`git ls-files` + count); `npx -y knip --no-progress --reporter compact` for unused exports/files | read the largest files; note dead/commented-out code seen while reading |73| `dependencies` | `npm outdated --json`; `npm audit --json` (or pnpm/yarn equivalents — detect via lockfile) | compare package.json ranges against lockfile |74| `git-hotspots` | `git log --since="12 months ago" --pretty=format: --name-only` aggregated per file (top ~20); `git shortlog -sn`; files untouched ≥ 12 months in active dirs | skip facet with `unknown` if no git history |75| `testing` | count test files (`*.test.*`, `*.spec.*`, `__tests__/`); run coverage only if a coverage script already exists; `npx tsc --noEmit` if tsconfig present; eslint error count if config present | map test files against key logic areas (payment, auth, data writes) and name untested ones |7677Write results into `data/health.json` following `references/health-schema.md`.78Cross-link insights between facets (e.g. a file that is both oversized AND a git hotspot79deserves a `warn` item saying so).8081### Phase 2 — Architecture read8283Read the project deeply enough to produce CORRECT diagrams and a navigable guide:84entry points, routing, state management, API layer, module boundaries, build setup.85Draft (as Mermaid `flowchart`) at minimum: a system map (frontend ↔ backend ↔ external86services) and a frontend data-flow diagram. Verify every path/name you write actually87exists — diagrams with wrong names are worse than no diagrams.8889### Phase 3 — Interview (knowledge that is NOT in the code)9091**Enumerate once, then batch-ask. Never drip-feed questions one at a time.**92931. From Phases 1–2 findings, build ONE complete question list, customized to the project94 (e.g. found an axios baseURL pointing to a domain → ask who owns that backend and95 where its docs live; found a Dockerfile → ask where images are deployed).962. Standard categories (adapt, drop irrelevant ones):97 - **Deployment** — where does it run (VPS/cloud/on-prem)? how does a release happen?98 who has access? rollback procedure?99 - **Backend & integrations** — who owns each upstream API? staging environments?100 API docs location? auth model?101 - **Team workflow** — how do designs arrive (Figma? specs?)? code review rules?102 who decides priorities? release cadence?103 - **Infrastructure** — machine specs, memory/capacity limits, monitoring/alerting,104 logs location?105 - **Operations** — who are the users? peak hours? known recurring incidents?1063. Ask via AskUserQuestion, grouped by category, a few questions per round.1074. The user may not know answers. Mark those **⚠️ To confirm** and add a concrete108 pointer: *who to ask / where to look* (e.g. "ask whoever owns the CI config",109 "check the cloud console billing page"). Collect all of these into a "To-confirm110 list" in the relevant data file. **Never present a guess as fact.**111112### Phase 4 — Generate the handbook1131141. Copy the template: everything in this skill's `template/` directory →115 `<project>/docs-site/` (creating it). On macOS/Linux also `chmod +x docs-site/open-handbook.sh`.1162. Write `data/manifest.js`:117118```js119window.HANDBOOK_MANIFEST = {120 project: "<Project Name>",121 generatedAt: "<YYYY-MM-DD>", // date of this generation or audit run122 commit: "<short hash>", // code baseline this handbook was verified against123 language: "<content language code>",124 sections: [125 { id: "overview", title: "...", file: "overview.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },126 { id: "architecture", title: "...", file: "architecture.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },127 { id: "dev-guide", title: "...", file: "dev-guide.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },128 { id: "deployment", title: "...", file: "deployment.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },129 { id: "integration", title: "...", file: "integration.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },130 { id: "collaboration", title: "...", file: "collaboration.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },131 { id: "onboarding", title: "...", file: "onboarding.md", type: "markdown", updatedAt: "<YYYY-MM-DD>" },132 { id: "health", title: "...", file: "health.json", type: "health", updatedAt: "<YYYY-MM-DD>" }133 ]134};135```136137 Section titles are written in the content language. The list above is the default138 skeleton — **scale to the project**: a frontend-only demo with no backend merges139 `integration` into `architecture`; drop `collaboration` for a solo project. Every140 section in the manifest must have a corresponding file.141142 **Freshness contract:** `generatedAt` and `commit` describe the latest run (initial143 generation OR audit). Each section's `updatedAt` is the date its CONTENT last144 changed. On an audit run, update `generatedAt`/`commit` always, but bump a section's145 `updatedAt` only if you actually edited that file — sections verified-but-unchanged146 keep their old `updatedAt`. The viewer shows "Updated <updatedAt> · verified at147 <commit>" under each page title.1481493. Write the `data/*.md` files. Content guide:150 - `overview.md` — what the project is, who uses it, what problem it solves. Mostly151 interview-sourced.152 - `architecture.md` — the Phase 2 diagrams + module map table with real paths.153 - `dev-guide.md` — how to run it locally (verified commands), conventions, branch154 strategy.155 - `deployment.md` — where it runs, how releases happen, capacity. Interview-sourced;156 this is where most ⚠️ To confirm items usually live.157 - `integration.md` — upstream APIs, external services, who owns them. Scan + interview.158 - `collaboration.md` — design handoff, review rules, team workflow. Interview-sourced.159 - `onboarding.md` — a new developer's day one: environment → run it → make a first160 small change (point at a real, easy file).161 - Markdown rules: GitHub-flavored; Mermaid in fenced ```mermaid blocks; use162 `file:line` references for code pointers; do not paste long code excerpts.1634. Write `data/health.json` from Phase 1 results (schema: `references/health-schema.md`).1645. Add a pointer to the project's CLAUDE.md (create if missing, append if present):165166```markdown167## Project handbook168169`docs-site/data/` holds this project's handbook as markdown/JSON — read it for170architecture, deployment, and team context. Humans: run `docs-site/open-handbook.bat`171(Windows) or `docs-site/open-handbook.sh` (macOS/Linux) to browse it.172```173174### Phase 5 — Verify & report1751761. Start the server (`node docs-site/serve.cjs 8787`, background) and verify:177 `/`, `/data/manifest.js`, and every file referenced in the manifest return 200.1782. If a browser tool (e.g. Playwright) is available, screenshot the architecture and179 health pages and confirm Mermaid diagrams rendered as SVG (not raw text). Otherwise,180 tell the user to open the handbook and check the diagrams.1813. Spot-check `file:line` and path references in the data files against the real code.1824. Report to the user: deliverables list, one-line health summary per facet, and the183 complete ⚠️ To-confirm list with its "who to ask / where to look" pointers.184185## Honesty rules186187- Tool didn't run → facet is `unknown`, and `meta.toolsUsed` reflects reality.188- User couldn't answer → ⚠️ To confirm, never a guess dressed as fact.189- Bugs or risks noticed while reading code → report them; don't silently fix anything.190- This skill reports health; it does not refactor, upgrade, or fix.