agentic-repo-scaffold
Turns the agentic-repo-architecture framework into committed, executable artifacts in a target repo.
Core principle: instruction files are context, not enforcement. Every architecture rule this skill writes into AGENTS.md must have a matching deterministic check in tools/verify/ and CI, or it will be violated under context pressure.
When to use / not use
- Use for: a new repo, or hardening an existing one toward agent-safe boundaries; adding the verify harness; wiring
make verify; standing up.agent/ledgers for a long refactor. - Don't use for: writing a codebase-walkthrough doc (that's
/init), or a one-file change. This is repo-infrastructure scaffolding.
Procedure
Create a todo per step.
1. Detect stack and existing surface
- Read
package.json/go.mod/pyproject.toml/Cargo.toml, the build scripts, and the top-level tree. - Classify: frontend/full-stack (Next.js/React), backend/service (API/worker/RPC/events), or general (CLI/SDK/lib/monorepo/infra). Monorepo → classify per package.
- Inventory what already exists:
AGENTS.md,CLAUDE.md, anytools/verifyor check scripts,.agent/,.cursor/rules, averifycommand, CI workflow. Never clobber a richer existing file — extend it, or write a.proposedsibling and diff. - Load the matching stack reference (bundled in this skill) for the authoritative layer rules / contract tables / acceptance matrix:
- frontend →
references/frontend.md - backend →
references/backend.md - general →
references/general.md
- frontend →
2. Write AGENTS.md (the architecture contract)
- Start from
templates/AGENTS.template.md. Fill in: real architecture map (use the ACTUAL directory names in this repo — don't imposecore/application/ports/adaptersnames if the repo already has a working, legible convention; map the roles onto its real paths), import rules, contract rules, file limits, the verify command, and the done-definition. - Enrich the stack-specific sections (layer table, boundary rules, backend contract list) from the matching reference file's §6/§8. Keep it a routing map, not a knowledge dump — link to deeper docs rather than inlining them.
- If
CLAUDE.mdis absent, drop the thin pointer fromtemplates/CLAUDE.pointer.md. If it exists and is substantive, leave it; just ensure it referencesAGENTS.md.
3. Install the verification harness
- Copy from
templates/, adapting globs/paths to the repo:check-giant-files.mjs(language-agnostic LOC gate; orcheck-giant-files.pyfor non-JS repos)check-boundaries.mjs(forbidden-import / purity check — set the layer regexes to the repo's real paths)check-generated-clean.sh(regenerate +git diff --quiet; skip if the repo has no generated code)
- Wire ONE canonical command running the full gate set. Match the repo's runner:
- JS/TS → a
verifyscript inpackage.json(typecheck → lint → unit → contract → e2e/visual where present → architecture checks). - Go → a
make verifytarget (go vet→golangci-lint→go test ./...→ arch/giant-file checks). - Python →
make verify(ruff/mypy→pytest→ checks).
- JS/TS → a
- Use
templates/Makefile.fragmentortemplates/package.verify.jsonas the starting shape.
4. Stand up .agent/ ledgers (only for genuine long-horizon work)
- Create
.agent/PROGRESS.md,.agent/EVIDENCE.md,.agent/DECISIONS.mdfromtemplates/agent-ledgers/. - These are repo-committed ledgers for multi-session refactors — not session-handoff scratch files. Name them PROGRESS/EVIDENCE/DECISIONS, commit them, and skip this step for a fresh repo with no active long refactor.
5. Optional: Cursor rules
- If the repo uses Cursor, drop the scoped
.cursor/rules/*.mdcfrom the matching reference §8 (boundaries rule + verification rule). Skip otherwise.
6. Optional: CI gate
- If a CI workflow exists, add a job that runs the canonical verify command. If not, offer
templates/ci-verify.yml(GitHub Actions). A check that isn't in CI is advisory only.
7. Verify the harness actually runs
- Run each new check script and the verify command. They must execute (even if they report pre-existing violations — that's signal, surface it). A scaffold that doesn't run is not done.
- Report: what was created/extended, which checks pass vs. flag existing debt, and the exact
verifycommand. Do not mark done from inspection — show command output.
Notes
- Templates and the
references/blueprint ship inside this skill, so the package is self-contained. - Be surgical: in an existing repo, adapt to its conventions rather than imposing the reference's directory names. The roles (pure core, orchestration, ports, adapters, isolated generated, thin transport) are the invariant; the names are the repo's.