New Project Bootstrap
You are setting up a repository so that AI agents can understand the project
quickly, use the same commands every time, validate their own work, and leave
behind enough evidence for a human to audit. The core principle: when an agent
struggles, the fix is adding structure to the repo — not telling the agent to
"try harder."
How this skill works
This is an interactive, multi-phase skill. You will interview the user, then
scaffold files in stages so they can review as you go. Do not dump everything
at once.
Phase 1: Interview
Before writing any files, gather the following from the user. Ask in a natural
conversational way — not as a numbered questionnaire.
Required:
- Project name — used for directory names, package.json, README title
- One-line description — what the product does
- Tech stack — frontend framework, backend language/framework, database
- App type — web app, API, CLI tool, library, monorepo, etc.
- Repo location — are we creating a new directory or working inside an existing repo?
Good to know (ask if not obvious):
- Does the project have a frontend that renders in a browser? (determines whether smoke tests and UI workflows are needed)
- Will there be a local dev server or integration stack to wrap? (determines harness runner needs)
- Any existing CI or deployment setup to preserve?
- Package manager preference (npm, pnpm, yarn, pip, go modules, cargo, etc.)
Once you have enough to proceed, confirm your understanding back to the user
before writing files.
Phase 2: Core documentation scaffold
Create these files first. They are short and set the foundation for everything
else.
Read references/doc-templates.md for the content templates. Customize every
template using the project details from Phase 1 — never leave placeholder text
that says "TODO" or "fill this in."
Every directory under docs/ must include an INDEX.md. Each index explains:
- what belongs in that directory
- what filename/content format files in that directory should follow
- links to every file in that directory
- links to each child directory's
INDEX.md
INDEX.md files belong only in docs/ and its subdirectories — not in
source code, scripts, config, or other top-level directories.
File creation order
AGENTS.md — the router file. 100–140 lines max. Contains: what the
product is, main stack, repo map, links to deeper docs, standard commands,
and a few hard rules. This is NOT a manual — it points agents to the right
doc for the right task.
CLAUDE.md — symlink to AGENTS.md. Run ln -s AGENTS.md CLAUDE.md.
This ensures Claude Code reads the same router file without duplicating
content. Add CLAUDE.md to the repo (git tracks symlinks).
README.md — standard project readme for humans.
docs/INDEX.md — docs directory contract and full file/subdirectory
index.
docs/README.md — docs index. Tells agents where to look next.
docs/ARCHITECTURE.md — module boundaries and dependency direction.
Short. Updated whenever structure changes.
docs/HARNESS.md — the operating contract: what commands to run, what
every PR must include, what qualifies for automerge, what needs human
review, how failures escalate.
docs/QUALITY_SCORE.md — repo health summary. Tracks incidents and
points at the next cleanup targets.
docs/behaviours/INDEX.md — behavior docs directory contract and full
file index.
docs/behaviours/README.md — index for behavior specs.
docs/behaviours/platform.md — canonical product behavior spec.
Start with 2–3 concrete scenarios based on what the user described.
docs/behaviours/current-state.md — summary of what's implemented.
docs/behaviours/e2e-checklist.md — checklist derived from platform.md.
docs/exec-plans/INDEX.md — execution plans directory contract, file
format expectations, and links to child directory indexes.
docs/exec-plans/README.md — index for execution plans, with
active/ and completed/ subdirectories.
docs/exec-plans/active/INDEX.md — explains how active plans are named
and structured.
docs/exec-plans/completed/INDEX.md — explains how completed plans are
archived and linked back to shipped work.
docs/generated/INDEX.md — explains that generated docs are refreshed
by script and should not be edited by hand.
docs/playbooks/INDEX.md — explains what operational playbooks belong
here and the format they should use.
After creating these, pause and tell the user: "Core docs are scaffolded.
Want to review before I add scripts?"
Phase 3: Scripts
Read references/script-templates.md for the implementation templates.
Adapt each script to the project's actual stack.
Create in this order
scripts/validate-repo.sh — the single command that checks repo truth.
Runs: markdown link checks, no-absolute-local-path checks, AGENTS.md drift
checks, behavior snapshot consistency, generated-doc freshness, index
coverage, and index freshness.
scripts/fast-feedback.sh — standard short loop for normal PRs.
Runs: validate-repo, stack-specific static checks, frontend type/lint/build
(if applicable), backend compile/test (if applicable). Must be deterministic.
scripts/ui-smoke.sh — only if the project has a browser frontend.
Runs a small tagged Playwright suite. Always leaves artifacts behind.
scripts/harness/run-local.sh — only if the project has a local dev
stack. Worktree-aware: derives ports from worktree name, derives isolated
data dir, boots dependencies, writes a manifest with ports/URLs/logs/artifacts.
scripts/generate-workspace-docs.mjs — generates a workspace inventory
so the repo map can be checked mechanically.
scripts/generate-index-docs.mjs — refreshes INDEX.md files under
docs/ so links to files and child directory indexes stay current.
scripts/check-index-docs.mjs — fails if any directory under docs/
is missing an INDEX.md, or if any index is stale, missing file links, or
missing child-directory index links.
scripts/refresh-quality-score.mjs — regenerates quality summary from
current repo state.
scripts/check-doc-links.mjs — validates markdown links in docs/ and
all INDEX.md files.
scripts/check-agents-drift.mjs — checks that AGENTS.md repo map
matches actual directory structure.
scripts/check-behaviour-docs.mjs — validates that current-state.md
and e2e-checklist.md are consistent with platform.md.
scripts/check-generated-docs.sh — CI gate: fails if generated docs
are stale.
scripts/validate-setup.sh — verifies the bootstrap itself is complete.
Checks that all expected docs, scripts, workflows, and directories exist.
Copy this from the skill's bundled scripts/validate-setup.sh. It accepts
--has-frontend and --has-harness flags to adjust expectations.
Make all .sh files executable. Make .mjs files work with node --experimental-vm-modules
or plain Node depending on what the project uses.
After creating scripts, pause: "Scripts are in place. Want to review before
I set up CI and the first test?"
Phase 4: First smoke test
Only if the project has a browser frontend.
Create e2e/smoke.behavior.spec.ts with a small Playwright test suite tagged
@smoke. Read references/test-templates.md for the template.
A good first suite checks:
- The login/signup screen renders
- An authenticated user can reach the main dashboard
- A core work-queue or listing page renders
If the project doesn't have a frontend, create an equivalent backend smoke
test in the project's test framework.
Also add Playwright config (playwright.config.ts) if not already present,
and install Playwright as a dev dependency.
Phase 5: GitHub workflows and PR template
Read references/workflow-templates.md for the workflow YAML templates.
Create these files
.github/pull_request_template.md — requires: intent summary, what
behavior changed, what validation ran, screenshots for UI changes.
.github/workflows/pr-fast.yml — runs scripts/fast-feedback.sh on
every PR.
.github/workflows/pr-ui-smoke.yml — runs smoke suite on UI-relevant
changes, uploads artifacts. Only if project has a frontend.
.github/workflows/nightly-baseline.yml — runs fuller browser baseline
nightly, opens a fix-forward PR if main breaks.
.github/workflows/weekly-doc-gardening.yml — refreshes generated docs
and opens a maintenance PR when needed.
.github/workflows/automerge.yml — staged automerge. Start conservative.
Automerge stages
Configure Stage 1 (the most conservative):
- Green CI required
- One independent agent review
- Human merge required
Include comments in the automerge workflow explaining Stage 2 (automerge
docs/tests/low-risk UI) and Stage 3 (wider automerge) so the team can
graduate later.
Always human-reviewed paths
These paths must never automerge at Stage 1:
- migrations, auth, billing, credentials
- desktop runtime code
- workflow and merge-policy files (
.github/)
AGENTS.md, docs/HARNESS.md
Phase 6: Handle existing debt (if applicable)
If this is an existing repo with violations:
- Run the validation scripts
- Baseline any existing violations into a
.baseline file
- Commit the baseline
- Configure CI to fail only on regressions, not the baseline
- Tell the user: "There are N existing violations baselined. Burn these down
over time."
Phase 7: Validate and wrap up
After all phases complete:
Run the setup validation script to confirm the bootstrap is complete.
The script is bundled with this skill at scripts/validate-setup.sh.
Copy it into the repo as scripts/validate-setup.sh (if not already done
in Phase 3), make it executable, then run it:
./scripts/validate-setup.sh --has-frontend --has-harness
Omit --has-frontend if there is no browser frontend. Omit --has-harness
if there is no local dev stack. The script checks every expected document,
script, workflow, and directory — any missing items are reported as failures.
Fix anything it flags before continuing.
Run node scripts/generate-index-docs.mjs so all indexes are normalized
before validation.
Run scripts/validate-repo.sh to verify doc links, drift checks, index
freshness, etc.
Run scripts/fast-feedback.sh to confirm the feedback loop works.
Summarize what was created, linking to each key file.
Suggest the Day 0 → Week 1 sequence from the reference docs for next steps.
Tell the user: "The repo is bootstrapped. A new agent can now read AGENTS.md
and find everything it needs."
Important principles to follow
- AGENTS.md is a router, not a manual. Keep it short. Point to docs/.
- Scripts are the source of truth for commands. Agents run scripts, not
ad-hoc command chains.
- Docs can fail CI. Generated docs have freshness checks. Links are
validated. Drift is caught.
- Start conservative on automerge. Widen only after the repo proves stable.
- If an agent keeps making the same mistake, fix the repo — add a script,
a check, or a doc. Do not rely on chat-based corrections.
- Boring technology wins. Shell scripts, standard CI, markdown docs.
Nothing exotic.
- Every PR must be auditable. PR template, validation evidence, artifacts.
Reference files
Read these as needed — they contain the actual templates:
references/doc-templates.md — Templates for AGENTS.md, docs/README.md,
ARCHITECTURE.md, HARNESS.md, QUALITY_SCORE.md, and behavior docs
references/script-templates.md — Templates for all scripts in scripts/
references/workflow-templates.md — Templates for GitHub workflows and
PR template
references/test-templates.md — Templates for smoke tests
1---2name: setup-harness3description: Bootstrap a new project repository for agent-first development. Use this skill whenever the user wants to set up a new repo, scaffold a project, create an agent-ready codebase, or mentions "bootstrap", "new project setup", "agent-first repo", "scaffold repo", or wants to structure a repo so that AI agents (Claude, Copilot, etc.) can work in it effectively from day one. Also trigger when the user asks to add AGENTS.md, harness scripts, or agent-friendly CI to an existing repo.4---56# New Project Bootstrap78You are setting up a repository so that AI agents can understand the project9quickly, use the same commands every time, validate their own work, and leave10behind enough evidence for a human to audit. The core principle: when an agent11struggles, the fix is adding structure to the repo — not telling the agent to12"try harder."1314## How this skill works1516This is an interactive, multi-phase skill. You will interview the user, then17scaffold files in stages so they can review as you go. Do not dump everything18at once.1920---2122## Phase 1: Interview2324Before writing any files, gather the following from the user. Ask in a natural25conversational way — not as a numbered questionnaire.2627**Required:**28- **Project name** — used for directory names, package.json, README title29- **One-line description** — what the product does30- **Tech stack** — frontend framework, backend language/framework, database31- **App type** — web app, API, CLI tool, library, monorepo, etc.32- **Repo location** — are we creating a new directory or working inside an existing repo?3334**Good to know (ask if not obvious):**35- Does the project have a frontend that renders in a browser? (determines whether smoke tests and UI workflows are needed)36- Will there be a local dev server or integration stack to wrap? (determines harness runner needs)37- Any existing CI or deployment setup to preserve?38- Package manager preference (npm, pnpm, yarn, pip, go modules, cargo, etc.)3940Once you have enough to proceed, confirm your understanding back to the user41before writing files.4243---4445## Phase 2: Core documentation scaffold4647Create these files first. They are short and set the foundation for everything48else.4950Read `references/doc-templates.md` for the content templates. Customize every51template using the project details from Phase 1 — never leave placeholder text52that says "TODO" or "fill this in."5354Every directory under `docs/` must include an `INDEX.md`. Each index explains:55- what belongs in that directory56- what filename/content format files in that directory should follow57- links to every file in that directory58- links to each child directory's `INDEX.md`5960`INDEX.md` files belong only in `docs/` and its subdirectories — not in61source code, scripts, config, or other top-level directories.6263### File creation order64651. **`AGENTS.md`** — the router file. 100–140 lines max. Contains: what the66 product is, main stack, repo map, links to deeper docs, standard commands,67 and a few hard rules. This is NOT a manual — it points agents to the right68 doc for the right task.69702. **`CLAUDE.md`** — symlink to AGENTS.md. Run `ln -s AGENTS.md CLAUDE.md`.71 This ensures Claude Code reads the same router file without duplicating72 content. Add `CLAUDE.md` to the repo (git tracks symlinks).73743. **`README.md`** — standard project readme for humans.75764. **`docs/INDEX.md`** — docs directory contract and full file/subdirectory77 index.78795. **`docs/README.md`** — docs index. Tells agents where to look next.80816. **`docs/ARCHITECTURE.md`** — module boundaries and dependency direction.82 Short. Updated whenever structure changes.83847. **`docs/HARNESS.md`** — the operating contract: what commands to run, what85 every PR must include, what qualifies for automerge, what needs human86 review, how failures escalate.87888. **`docs/QUALITY_SCORE.md`** — repo health summary. Tracks incidents and89 points at the next cleanup targets.90919. **`docs/behaviours/INDEX.md`** — behavior docs directory contract and full92 file index.939410. **`docs/behaviours/README.md`** — index for behavior specs.959611. **`docs/behaviours/platform.md`** — canonical product behavior spec.97 Start with 2–3 concrete scenarios based on what the user described.989912. **`docs/behaviours/current-state.md`** — summary of what's implemented.10010113. **`docs/behaviours/e2e-checklist.md`** — checklist derived from platform.md.10210314. **`docs/exec-plans/INDEX.md`** — execution plans directory contract, file104 format expectations, and links to child directory indexes.10510615. **`docs/exec-plans/README.md`** — index for execution plans, with107 `active/` and `completed/` subdirectories.10810916. **`docs/exec-plans/active/INDEX.md`** — explains how active plans are named110 and structured.11111217. **`docs/exec-plans/completed/INDEX.md`** — explains how completed plans are113 archived and linked back to shipped work.11411518. **`docs/generated/INDEX.md`** — explains that generated docs are refreshed116 by script and should not be edited by hand.11711819. **`docs/playbooks/INDEX.md`** — explains what operational playbooks belong119 here and the format they should use.120121After creating these, pause and tell the user: "Core docs are scaffolded.122Want to review before I add scripts?"123124---125126## Phase 3: Scripts127128Read `references/script-templates.md` for the implementation templates.129Adapt each script to the project's actual stack.130131### Create in this order1321331. **`scripts/validate-repo.sh`** — the single command that checks repo truth.134 Runs: markdown link checks, no-absolute-local-path checks, AGENTS.md drift135 checks, behavior snapshot consistency, generated-doc freshness, index136 coverage, and index freshness.1371382. **`scripts/fast-feedback.sh`** — standard short loop for normal PRs.139 Runs: validate-repo, stack-specific static checks, frontend type/lint/build140 (if applicable), backend compile/test (if applicable). Must be deterministic.1411423. **`scripts/ui-smoke.sh`** — only if the project has a browser frontend.143 Runs a small tagged Playwright suite. Always leaves artifacts behind.1441454. **`scripts/harness/run-local.sh`** — only if the project has a local dev146 stack. Worktree-aware: derives ports from worktree name, derives isolated147 data dir, boots dependencies, writes a manifest with ports/URLs/logs/artifacts.1481495. **`scripts/generate-workspace-docs.mjs`** — generates a workspace inventory150 so the repo map can be checked mechanically.1511526. **`scripts/generate-index-docs.mjs`** — refreshes `INDEX.md` files under153 `docs/` so links to files and child directory indexes stay current.1541557. **`scripts/check-index-docs.mjs`** — fails if any directory under `docs/`156 is missing an `INDEX.md`, or if any index is stale, missing file links, or157 missing child-directory index links.1581598. **`scripts/refresh-quality-score.mjs`** — regenerates quality summary from160 current repo state.1611629. **`scripts/check-doc-links.mjs`** — validates markdown links in docs/ and163 all `INDEX.md` files.16416510. **`scripts/check-agents-drift.mjs`** — checks that AGENTS.md repo map166 matches actual directory structure.16716811. **`scripts/check-behaviour-docs.mjs`** — validates that current-state.md169 and e2e-checklist.md are consistent with platform.md.17017112. **`scripts/check-generated-docs.sh`** — CI gate: fails if generated docs172 are stale.17317413. **`scripts/validate-setup.sh`** — verifies the bootstrap itself is complete.175 Checks that all expected docs, scripts, workflows, and directories exist.176 Copy this from the skill's bundled `scripts/validate-setup.sh`. It accepts177 `--has-frontend` and `--has-harness` flags to adjust expectations.178179Make all `.sh` files executable. Make `.mjs` files work with `node --experimental-vm-modules`180or plain Node depending on what the project uses.181182After creating scripts, pause: "Scripts are in place. Want to review before183I set up CI and the first test?"184185---186187## Phase 4: First smoke test188189Only if the project has a browser frontend.190191Create `e2e/smoke.behavior.spec.ts` with a small Playwright test suite tagged192`@smoke`. Read `references/test-templates.md` for the template.193194A good first suite checks:195- The login/signup screen renders196- An authenticated user can reach the main dashboard197- A core work-queue or listing page renders198199If the project doesn't have a frontend, create an equivalent backend smoke200test in the project's test framework.201202Also add Playwright config (`playwright.config.ts`) if not already present,203and install Playwright as a dev dependency.204205---206207## Phase 5: GitHub workflows and PR template208209Read `references/workflow-templates.md` for the workflow YAML templates.210211### Create these files2122131. **`.github/pull_request_template.md`** — requires: intent summary, what214 behavior changed, what validation ran, screenshots for UI changes.2152162. **`.github/workflows/pr-fast.yml`** — runs `scripts/fast-feedback.sh` on217 every PR.2182193. **`.github/workflows/pr-ui-smoke.yml`** — runs smoke suite on UI-relevant220 changes, uploads artifacts. Only if project has a frontend.2212224. **`.github/workflows/nightly-baseline.yml`** — runs fuller browser baseline223 nightly, opens a fix-forward PR if main breaks.2242255. **`.github/workflows/weekly-doc-gardening.yml`** — refreshes generated docs226 and opens a maintenance PR when needed.2272286. **`.github/workflows/automerge.yml`** — staged automerge. Start conservative.229230### Automerge stages231232Configure **Stage 1** (the most conservative):233- Green CI required234- One independent agent review235- Human merge required236237Include comments in the automerge workflow explaining Stage 2 (automerge238docs/tests/low-risk UI) and Stage 3 (wider automerge) so the team can239graduate later.240241### Always human-reviewed paths242243These paths must never automerge at Stage 1:244- migrations, auth, billing, credentials245- desktop runtime code246- workflow and merge-policy files (`.github/`)247- `AGENTS.md`, `docs/HARNESS.md`248249---250251## Phase 6: Handle existing debt (if applicable)252253If this is an existing repo with violations:254- Run the validation scripts255- Baseline any existing violations into a `.baseline` file256- Commit the baseline257- Configure CI to fail only on regressions, not the baseline258- Tell the user: "There are N existing violations baselined. Burn these down259 over time."260261---262263## Phase 7: Validate and wrap up264265After all phases complete:2662671. **Run the setup validation script** to confirm the bootstrap is complete.268 The script is bundled with this skill at `scripts/validate-setup.sh`.269 Copy it into the repo as `scripts/validate-setup.sh` (if not already done270 in Phase 3), make it executable, then run it:271272 ```bash273 ./scripts/validate-setup.sh --has-frontend --has-harness274 ```275276 Omit `--has-frontend` if there is no browser frontend. Omit `--has-harness`277 if there is no local dev stack. The script checks every expected document,278 script, workflow, and directory — any missing items are reported as failures.279 Fix anything it flags before continuing.2802812. Run `node scripts/generate-index-docs.mjs` so all indexes are normalized282 before validation.2833. Run `scripts/validate-repo.sh` to verify doc links, drift checks, index284 freshness, etc.2854. Run `scripts/fast-feedback.sh` to confirm the feedback loop works.2865. Summarize what was created, linking to each key file.2876. Suggest the Day 0 → Week 1 sequence from the reference docs for next steps.288289Tell the user: "The repo is bootstrapped. A new agent can now read AGENTS.md290and find everything it needs."291292---293294## Important principles to follow295296- **AGENTS.md is a router, not a manual.** Keep it short. Point to docs/.297- **Scripts are the source of truth for commands.** Agents run scripts, not298 ad-hoc command chains.299- **Docs can fail CI.** Generated docs have freshness checks. Links are300 validated. Drift is caught.301- **Start conservative on automerge.** Widen only after the repo proves stable.302- **If an agent keeps making the same mistake, fix the repo** — add a script,303 a check, or a doc. Do not rely on chat-based corrections.304- **Boring technology wins.** Shell scripts, standard CI, markdown docs.305 Nothing exotic.306- **Every PR must be auditable.** PR template, validation evidence, artifacts.307308---309310## Reference files311312Read these as needed — they contain the actual templates:313314- `references/doc-templates.md` — Templates for AGENTS.md, docs/README.md,315 ARCHITECTURE.md, HARNESS.md, QUALITY_SCORE.md, and behavior docs316- `references/script-templates.md` — Templates for all scripts in scripts/317- `references/workflow-templates.md` — Templates for GitHub workflows and318 PR template319- `references/test-templates.md` — Templates for smoke tests