setup-bootstrap
Skill9 starsChanged 29 days agoMITView on GitHub
One-time repo setup that detects tech stack, audits the codebase, pulls coding guidelines, and generates a project-specific AGENTS.md plus a CLAUDE.md shim
- Deletes or force-pushes
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- batch-fixSkill
- brainstormingSkill
- code-review-and-qualitySkill
- code-simplificationSkill
- context-engineeringSkill
- fixSkill
- handoffSkill
- implementSkill
- incremental-implementationSkill
- instructionsSkill
- lessonsSkill
- mtk-doctorSkill
- mtk-setupSkill
- mtkSkill
- planning-and-task-breakdownSkill
- pre-commit-reviewSkill
- prior-work-checkSkill
- promote-lessonSkill
- repo-healthSkill
- research-contextSkill
- security-and-hardeningSkill
- setup-auditSkill
- setup-refreshSkill
- spec-drift-detectionSkill
- spec-driven-developmentSkill
- subagent-implementationSkill
- tech-stack-dotnetSkill
- tech-stack-pythonSkill
- tech-stack-typescriptSkill
- verification-before-completionSkill
- workflow-artifactsSkill
- writing-skillsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
23 rules. About 0 are common, 5 are distinctive, and 18 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
18
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 35
No aspirational rules, no list-of-everything: Every rule comes from an observed pattern or failure in this codebase.
- Very specific: line 42
Everything else is preserved untouched: Never delete: nested/per-package CLAUDE.md at any non-root path (even when the repo is NOT a …
- Distinctive: line 43
Superseding a prior MTK file must be loud: Remove it explicitly AND list it under "Retired prior MTK files" in the STEP 5 report.
- Very specific: line 53
Read stacks, primary_candidate, package_manager, react_native.detected / react_native.expo, go_detected and multiple_lockfiles (STEP 4.5 …
- Very specific: line 58
Write the primary stack as a single word: echo "dotnet" > .claude/tech-stack.
- Very specific: line 61
Run mkdir, rm -rf and echo > as separate Bash calls: conservative permission modes reject a chain containing rm -rf, which aborts the whole …
- Very specific: line 67
Prerequisites: run bash hooks/check-prerequisites.sh and carry its warnings into the STEP 5 report.
- Very specific: line 75
If the stack skill's ## Coding Style Reference names a remote source, fetch it at the pinned SHA and verify its sha256.
- Very specific: line 109
Run the stack skill's ## Scan Recipes in order: Project Structure, Patterns In Use, Data Layer, Infrastructure, Naming Conventions, Testing …
- Distinctive: line 137
Neither AGENTS.md nor CLAUDE.md: write AGENTS.md from the template, the shim from its second block, and the rules files.
- Very specific: line 141
Read the existing constitution and check for .claude/rules/.
- Distinctive: line 181
Every rule carries a section number (§X.Y) for reviewers to cite, and cites code from this codebase where possible.
- Very specific: line 189
Before writing (or previewing), verify every concrete path, project and file claim in AGENTS.md, architecture-principles.md, every …
- Very specific: line 199
Claim-level grounding (mandatory): after writing each generated doc, run bash scripts/verify-claims.sh <file> and apply …
- Distinctive: line 213
Before any write of a generated file, stage it and scan it, in every mode:
- Very specific: line 226
After AGENTS.md, the shim and the rules are written, run bash scripts/check-instruction-load.sh.
- Very specific: line 234
Follow .claude/references/product-context.md to generate:
- Very specific: line 257
No
.claude/settings.json: create it from the baseline plus stack additions over {}. - Very specific: line 260
Write refused by the permission layer: write the merged content to .claude/settings.json.mtk-proposed and add a Needs review line: "review …
- Very specific: line 271
Never overwrite an existing git pre-commit hook (other than MTK's own shim or a legacy MTK symlink), .mtkignore, .claudeignore or …
- Very specific: line 272
Keep tasks/lessons.md tracked.
- Very specific: line 283
false, ambiguous: ask via AskUserQuestion (header "Repo layout"): "Yes — generate per-package CLAUDE.md files" / "No — single project".
- Very specific: line 305
Default to merge mode: when a constitution exists — don't ask overwrite/merge/abort.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MTK Setup Bootstrap — Prepare Repository for AI-Assisted Development
MTK File Resolution
Resolve MTK skill/reference/script paths per .claude/references/mtk-file-resolution.md unless the router already stated MTK_ROOT=<path> this session; AGENTS.md, CLAUDE.md, .claude/tech-stack, .claude/rules/, tasks/, docs/, .mtk/ stay project-relative.
Companion files: several steps defer detail to .claude/references/*.md. If a companion cannot be resolved at read time, stop that step and report the missing path — do not reconstruct its content from memory.
You detect the tech stack, audit the codebase, and generate a tailored AGENTS.md — the canonical constitution every harness reads — plus the CLAUDE.md shim that imports it. The implementation and review agents use them as their source of truth.
Modes
--preview— run detection, scan and interview, then show the proposed AGENTS.md + shim + rules diff and confirm viaAskUserQuestionbefore writing anything.--non-interactive— skip the STEP 2.5 interview.--no-verify-commands— skip STEP 3.5a's command verification: nothing is executed, and the Tech Stack section gets no<!-- verified: ... -->stamp and no[UNVERIFIED]annotations. The STEP 5 report saysCommand verification: skipped via --no-verify-commands.
The flags combine.
Generation Constraints
Compliance with constitution rules degrades as the instruction count grows, and generated constitutions that list everything perform worst. So:
- Root AGENTS.md: target 60–80 lines, hard cap 120. Detail goes to
.claude/rules/or a hook. TheCLAUDE.mdshim is ~20 lines with no rule text. - Trigger-action rules with the reason attached (
When X, do Y — because Z). Write prohibitions only for constraints the codebase actually enforces (the counter-example gate in STEP 3 decides). NoIMPORTANT:/YOU MUSTmarkers: they cause over-triggering. - Mechanize what you can. A rule a hook or the
settings.jsondeny list enforces is not repeated in AGENTS.md. - No aspirational rules, no list-of-everything. Every rule comes from an observed pattern or failure in this codebase; omit what the model can read from the code.
File Preservation Policy (non-destructive contract — read before writing anything)
Bootstrap is additive and merge-only. It NEVER deletes a file it did not generate, and never runs git rm, rm, or a "replace/fresh-generate" sweep over pre-existing files — even if a wrapper, runner or --non-interactive caller asks for "replace mode." There is no replace mode.
- Only MTK-owned files may be overwritten in place. MTK-owned means carrying the
<!-- mtk-setupprovenance stamp, OR one of MTK's known generated paths: rootCLAUDE.md,.claude/rules/*in the standard set,.claude/references/*,.claude/tech-stack,.claude/settings.json,.claude/detected-tools.json,.claude/mtk-version.json,CODE_INDEX.md,pre-commit-review-list.md. Overwrite means rewrite the body — nevergit rm. Exception:architecture-principles.md,product.mdanddecisions.mdare never overwritten once present; a re-run routes changes through.claude/references/regen-diff-contract.md. - Everything else is preserved untouched. Never delete: nested/per-package
CLAUDE.mdat any non-root path (even when the repo is NOT a monorepo),.claude/CLAUDE.md, custom.claude/commands/*, custom.claude/rules/*outside MTK's standard set, team-added.claude/references/*, lockfiles, source files, or any AI-assistant config the team adopted. - Superseding a prior MTK file must be loud. Remove it explicitly AND list it under "Retired prior MTK files" in the STEP 5 report. If unsure a file is MTK-owned, treat it as hand-authored.
- Stage only your declared output —
git addspecific generated paths, nevergit add -A/git add .. - Scratch stays out of the tree. No
run-report.md/review.mdin the repo; operator scratch goes outside the working tree or is git-ignored.
STEP 0: Detect Tech Stack
bash scripts/setup-detect.sh --jsonRead stacks, primary_candidate, package_manager, react_native.detected / react_native.expo, go_detected and multiple_lockfiles (STEP 4.5 reuses this output). Markers: *.sln/*.slnx/*.csproj → dotnet; pyproject.toml/setup.py/requirements.txt/Pipfile → python; package.json/tsconfig.json without *.csproj → typescript.
- More than one stack → ask via
AskUserQuestion(header "Tech stack", one option per detected stack) which is primary. Record the rest as secondary stacks:setup-auditSTEP 2.6 writes them todetected-tools.jsonsecondary_stacks, STEP 2 runs their naming/testing recipes, STEP 3.6 folds in their references. - Empty → stop: go is not yet supported (
go_detected), otherwise add atech-stack-{name}/skill or open an issue.
Write the primary stack as a single word: echo "dotnet" > .claude/tech-stack.
.claude/tech-stackis a file: never put it in amkdir -plist.- Run
mkdir,rm -rfandecho >as separate Bash calls: conservative permission modes reject a chain containingrm -rf, which aborts the whole chain.
Polyglot repos. .claude/tech-stack holds the primary stack; subprojects override it with a nested .claude/tech-stack (closest wins) or a root .claude/tech-stack.map of <glob> <stack> lines (web/* typescript). Both resolve through scripts/resolve-tech-stack.sh. Add a map only for a genuinely polyglot repo. Repo-wide generators use the primary stack.
Then load .claude/skills/tech-stack-{stack}/SKILL.md — the source of build commands, scan recipes and reference paths for the rest of the run.
Prerequisites: run bash hooks/check-prerequisites.sh and carry its warnings into the STEP 5 report; they never block.
TypeScript only: the .claude/tech-stack-pm write, the multiple-lockfiles warning and the React Native/Expo feed live in .claude/references/bootstrap-supporting-files.md. Read it now and follow it.
STEP 1: Pull External Standards
Coding Guidelines
If the stack skill's ## Coding Style Reference names a remote source, fetch it at the pinned SHA and verify its sha256. Never fetch from main. The pin is bumped only by /mtk-setup --update-guidelines, so every bootstrap is reproducible.
For dotnet:
bash scripts/update-guidelines.sh --fetch CodingStyle.md --out .claude/references/dotnet/coding-guidelines.mdThe script reads the pin (repo-local .claude/mtk-version.json block first, else the toolkit manifest), fetches <sha>/CodingStyle.md, and moves it into place only after the sha256 matches. On a failed fetch or a mismatch it exits 1 and leaves the target untouched. If the file is then absent, tell the engineer to place it manually. Never fall back to an unpinned fetch.
For python / typescript: a reference whose first frontmatter block contains status:[[:space:]]*placeholder is skipped — not copied, not cited. When the team removes that line, the next bootstrap ships it.
Architecture Principles
If .claude/references/architecture-principles.md exists, leave it alone. Otherwise generate it from the STEP 2 findings with the /mtk-setup --audit template, including the repomap evidence pass (setup-audit STEP 0.5) and the mandatory ## Provenance section (setup-audit STEP 3.5). If you cannot run those inline, delegate to setup-audit rather than produce an unevidenced document.
STEP 1.5: Scan Ledger (resumable)
Persist progress with scripts/workflow-artifact.sh so a compaction or crash resumes instead of re-scanning.
- At skill start:
bash scripts/workflow-artifact.sh list. For an incompletesetup-bootstrapartifact updated < 24h ago, ask viaAskUserQuestion: "Resume from <current_step>" (skip every STEP with astep_completedevent, reload itsoutputs/summary), "Start fresh" (abandon <old-uuid> --reason engineer-choice, theninit), or "Cancel". An artifact ≥ 24h old is abandoned automatically (--reason stale-24h) with⚠️ Abandoned stale setup-bootstrap run (> 24h old) — starting fresh. - Start:
UUID=$(bash scripts/workflow-artifact.sh init setup-bootstrap --goal "<one-line goal>"). - After each STEP:
Summaries are concrete ("scanned 214 files, 3 inconsistencies").bash scripts/workflow-artifact.sh event "$UUID" step_completed \ --data '{"step":"STEP 2","outputs":["<files>"],"summary":"<one concrete sentence>"}' bash scripts/workflow-artifact.sh set "$UUID" current_step="STEP 2" - End of STEP 5:
bash scripts/workflow-artifact.sh set "$UUID" status=completed.
For repos with >1000 tracked source files, process the scan categories one at a time: write each category's findings into its step_completed event and keep only a 1–2 sentence summary in context.
STEP 2: Audit the Codebase
Run the stack skill's ## Scan Recipes in order: Project Structure, Patterns In Use, Data Layer, Infrastructure, Naming Conventions, Testing Patterns, Configuration. Then:
git log --oneline -20
git branch -a | awk 'NR<=20'
find . -name "pull_request_template*"For each secondary stack, also run its categories 5 (Naming) and 6 (Testing) so conventions.md covers it.
STEP 2.5: Post-Scan Interview (skip if --non-interactive and no persisted answers)
The questions, adaptive-ambiguity protocol, answer routing and setup-answers.json schema live in .claude/references/bootstrap-interview.md. Read it now and follow it.
- Answers file exists, interactive: show a compact summary, ask only empty/new keys, offer "revise a previous answer".
--non-interactive+ file: reuse silently; printℹ️ Reusing persisted interview answers from .claude/setup-answers.json (--non-interactive).--non-interactive, no file: skip and print⚠️ Interview skipped. AGENTS.md will be auto-detected only — consider running without --non-interactive for better team-specific rules.
STEP 2.7: Ingest Existing AI-Assistant Configs
Existing Cursor/Copilot/Windsurf/Cline/Gemini configs or a prior CLAUDE.md are interview-grade input to STEP 3: read-only and evidence-anchored. Detection list, anchors and dedup/conflict rules: .claude/references/config-ingestion.md. Read it now and follow it. Report Ingested AI configs: [paths, or "none found"] in STEP 5.
STEP 3: Generate AGENTS.md + CLAUDE.md shim + Rules Files
AGENTS.md holds the rules; CLAUDE.md imports it; .claude/rules/*.md hold topic detail, path-scoped; .claude/references/ are read on demand and never duplicated; hooks and the deny list carry what is mechanically enforceable.
Which path
- Neither AGENTS.md nor CLAUDE.md: write
AGENTS.mdfrom the template, the shim from its second block, and the rules files. - Hand-curated AGENTS.md (no
<!-- mtk-setupstamp): preserve it untouched and report it under "Preserved hand-authored files". Write the shim only ifCLAUDE.mdis absent; if both exist, leave both and name the pair in STEP 5. - MTK-owned constitution (stamped AGENTS.md, or any existing CLAUDE.md) → merge mode (default):
0. Stamped
AGENTS.md, noCLAUDE.md: write the shim, leaveAGENTS.md; reportshim written; AGENTS.md preserved.- Read the existing constitution and check for
.claude/rules/. - Inversion migration. A constitution-shaped
CLAUDE.md(has## Critical Rules) with no^@AGENTS\.mdline and no hand-curatedAGENTS.mdpredates the inversion. Propose moving its body toAGENTS.mdand replacing it with the shim, as a regen-diff proposal per.claude/references/regen-diff-contract.md. Never rewrite either file without approval; under--non-interactiveit defers to NEEDS REVIEW. - Monolithic (>200 lines, full rule sections): extract sections into
.claude/rules/and replace the body with the lean template, preserving project-specific content (through the proposal above when the body is still inCLAUDE.md). - Lean constitution + existing rules: classify and resolve each regenerated file per
regen-diff-contract.md§2 (classification against the.claude/.mtk-cache/ancestor), §3/§3a (per-hunk proposals; no ancestor → additive-only), §4 (cache) and §6 (gate not skippable, non-interactive defers, never deletes). Report per-file RESULT values in STEP 5.
- Read the existing constitution and check for
Root AGENTS.md
Reproduce the first block of .claude/references/root-agents-md-template.md, filling placeholders from the scan and interview. End it with the mandatory footer (needed by --audit re-runs and compliance audits):
<!-- mtk-setup: v{MANIFEST_VERSION}
coding-guidelines: moberghr/coding-guidelines@{MANIFEST_SHA}
generated: {ISO8601_UTC_NOW} -->{MANIFEST_VERSION} and {MANIFEST_SHA} come from .claude/manifest.json ({MANIFEST_SHA} is the SHA STEP 1 fetched at); {ISO8601_UTC_NOW} is date -u +%Y-%m-%dT%H:%M:%SZ.
CLAUDE.md shim
The template's second block: heading, the import, one plain-text pointer for a harness that reads the file literally, and the ## Claude Code only notes. Emit @AGENTS.md as a bare line, never in backticks or a fence — wrapped, the import is inert. Claude Code's default claude-md-or-agents-md mode reads CLAUDE.md and ignores AGENTS.md, so the bare import is the only path to the constitution; claude-md-and-agents-md loads both and de-duplicates. Rule text in the shim is duplicated in one mode and lost in the other.
.claude/rules/ files
Generate only files relevant to the project, 30–80 lines each: security.md, architecture.md, coding-style.md (project overrides only, never a copy of the guidelines), testing.md, data-layer.md, performance.md, infrastructure.md, git-workflow.md, project-specific.md.
Every rule file opens with paths: frontmatter. Without it the file loads into every request (measured: 30KB, ~7.5k tokens per turn, in one repo with 7 unfrontmattered files).
---
paths:
- "src/Handlers/**"
- "src/Services/**"
---Derive the globs from the directories the rule's own sections cite. A rule with no defensible glob folds into AGENTS.md or is dropped. "**" is allowed only with a comment saying why. A rule whose globs match nothing in the repo is dropped.
Rules for Generation
- Counter-example gate — run before emitting any absolute rule. Before writing any rule containing
NEVER,ALWAYS,all,everyormust, grep for counter-examples. If ANY exist, soften toPrefer X, note the exception count/location, and tag[CONVENTION], not[ENFORCED]. Absolute language and[ENFORCED]are for zero-counter-example, build-gated or tool-enforced rules. - Every rule carries a section number (§X.Y) for reviewers to cite, and cites code from this codebase where possible.
- Flag conflicts: "⚠️ Guideline says X, but codebase does Y. Standardize on: [recommendation]".
- Point at
.claude/references/files instead of copying them. - Live references over restated facts. Versions, dependency lists and package-manager choice are pointed at (
see \package.json`), not restated; build/test command lines stay inline.@`-import only files of ≤~50 lines — never a manifest or lockfile. - Cache-stable ordering: invariants (Critical Rules, Standards Reference, Tech Stack commands) first; volatile state (project profile, monorepo layout) last, so the prompt prefix stays cacheable.
STEP 3.5a: Verify Generated References
Before writing (or previewing), verify every concrete path, project and file claim in AGENTS.md, architecture-principles.md, every .claude/rules/*.md and (monorepo) every per-package CLAUDE.md:
bash scripts/verify-references.sh AGENTS.md \
.claude/references/architecture-principles.md .claude/rules/*.md
# (monorepo) also pass each per-package CLAUDE.mdIt checks backtick-spanned path claims, .csproj existence, framework versions and solution membership against disk, printing STALE … lines (exit 3) or exiting 0. On stale output: remove or correct the claim; drop a framework version no project file uses; note a stale solution entry but never edit the .sln. Re-run after any deletion or rename this session. Disk (test -d / test -f) is the source of truth — never solution membership, manifests or lockfiles — as of writing time, not scan time.
Claim-level grounding (mandatory): after writing each generated doc, run bash scripts/verify-claims.sh <file> and apply .claude/references/audit-grounding.md: rule tags [ENFORCED]/[CONVENTION]/[ASPIRATIONAL], the <!-- mtk-stamp --> footer, zero-hit downgrades, transient-state and terminology flags, and the paste-ready weak-claims report.
Command verification
Unless --no-verify-commands, verify the exact build/test/format commands before writing the Tech Stack section. Command assembly, the verify-commands.sh call and outcome handling — including the branch for a missing verifier or non-JSON output — live in .claude/references/command-verification.md. Read it now and follow it. Report N verified, N unverified, N skipped (or the skip reason) in STEP 5.
STEP 3.5b: Preview Gate (if --preview)
With --preview, write nothing yet: the plan table and the AskUserQuestion confirmation live in .claude/references/preview-gate.md. Read it now and follow it.
Unconditional: compute the lines/tokens table and enforce the ceilings in every mode. AGENTS.md over 120 lines → print "Generated AGENTS.md exceeds 120 lines — move <section> to .claude/rules/<name>.md" and abort. A shim over ~20 lines, or holding rule text, aborts the same way.
STEP 3.5c: Secret Scan Gate (always)
Before any write of a generated file, stage it and scan it, in every mode:
TMP=$(mktemp)
# write content to $TMP, then:
bash scripts/secret-scan.sh "$TMP" || { echo "secret-scan blocked write of <filename>"; rm -f "$TMP"; exit 1; }
mv "$TMP" "<target-path>"On a non-zero exit: print the offending <file>:<line>: <pattern> lines, abort the whole bootstrap, and point the engineer at the audit output or guidelines for the leak. MTK_SECRET_SCAN_SKIP=1 bypasses the scan for a confirmed false positive only; log the bypass prominently in STEP 5.
STEP 3.5d: Instruction Load Check
After AGENTS.md, the shim and the rules are written, run bash scripts/check-instruction-load.sh. Fix every finding before writing the PR; exit 2 or a missing script → report "instruction load not checked" in STEP 5.
STEP 3.6: Prune Stack Reference Files Against Detected Tools
The pruning procedure (detected union, per-file tools: intersection, override path, cache TTL) lives in .claude/references/bootstrap-supporting-files.md. Read it now and follow it.
STEP 3.8: Product Context Artifacts
Follow .claude/references/product-context.md to generate:
.claude/references/product.md(≤40 lines) — purpose, users, key flows, non-goals, from the STEP 2 README/docs scan andsetup-answers.json→answers.product_purpose..claude/references/decisions.md— ADR-lite, append-only, seeded from detectable history and interview rationale.
An existing file is preserved untouched and reported as preserved. Both writes pass the STEP 3.5c gate. After writing product.md, run bash scripts/verify-claims.sh .claude/references/product.md with the one-retry loop (fix the anchor, or delete only a self-generated line that failed); it is generated after STEP 3.5a, so it is checked here. Report surviving downgrades and one line per file (generated / preserved (existing)) in STEP 5.
STEP 4: Set Up Supporting Files & Directories
.claude/rules/
mkdir -p .claude/rules (never with .claude/tech-stack in the list). Then confirm every rule file has frontmatter — a missing block is how a repo ends up with every rule always-on:
for f in .claude/rules/*.md; do
head -1 "$f" | grep -q '^---$' || echo "BOOTSTRAP BUG: $f has no auto-attach frontmatter"
doneSettings Merge
Merge .claude/references/settings-baseline.md (### allow, ### deny, ### ask, ### settings) first, then the stack skill's ## Settings Additions. ### allow → permissions.allow, ### deny → permissions.deny, ### ask → permissions.ask; ### settings bullets (key: value) are top-level keys, merged only when absent so an existing value always wins. There is no top-level allowedTools key; never write one.
- No
.claude/settings.json: create it from the baseline plus stack additions over{}. Never copy the toolkit's ownsettings.json. - Never write an MTK hook command into the target's
.claude/settings.json.$CLAUDE_PLUGIN_ROOTis defined only for hooks a plugin declares in its ownhooks/hooks.json; in a project settings file it expands to empty and the hook runs asbash /hooks/<name>, failing on every call, silently (measured: 4,552bash: /hooks/format-on-edit.sh: No such file or directoryfailures across 7 repos). Barehooks/...and$CLAUDE_PROJECT_DIR/hooks/...dangle in plugin-cache installs. The plugin wires MTK's hooks itself; bootstrap writes only the opt-in marker (.claude/tech-stack).scripts/validate-toolkit.shfails on a stack skill whose Settings Additions lists an MTK hook. - Existing
.claude/settings.json: if it carries legacypermissions.allowedTools, first runbash "${CLAUDE_PLUGIN_ROOT}/scripts/migrate-settings-permissions.sh" .claude/settings.json(and on.claude/settings.local.jsonif it has the key). It activates only narrow build/test/format/lint rules; list the broad leftovers (interpreters, package managers,curl, bareWrite/Edit) under Needs review — they were never in effect. Then unionallow/deny/askwith the existing lists, no duplicates. Strip any existinghooks.*entry pointing at an MTK hook ($CLAUDE_PLUGIN_ROOT/hooks/,$CLAUDE_PROJECT_DIR/hooks/or barehooks/with an MTK hook basename): the first form fails on every call, the others fire twice beside the plugin's copy. Leave non-MTK hooks untouched. - Write refused by the permission layer: write the merged content to
.claude/settings.json.mtk-proposedand add a Needs review line: "review the diff, thenmv .claude/settings.json.mtk-proposed .claude/settings.json". Never skip the merge silently or retry the refused write verbatim.
Reference File Customization
Substitute the shared references' "match existing" placeholders with scan findings — only when the scan found exactly ONE tool in a category; with several or none, leave the generic text. The per-stack substitution tables live in .claude/references/bootstrap-customization.md. Read it now and apply them. Never remove sections for tools not yet in use.
Supporting files, hooks, ignore files, tooling & cross-agent mirrors
The git pre-commit hook, CI staleness gate, skills/agents checklist, pre-commit-review-list.md selection, tasks/, the learnings seed, .mtkignore, .claudeignore, analyzer configuration, the .NET companion plugin, recommended tooling, the .claude/mtk-version.json stamp and cross-agent mirrors live in .claude/references/bootstrap-supporting-files.md. Read it now and follow it.
These bind without the read:
- Never overwrite an existing git pre-commit hook (other than MTK's own shim or a legacy MTK symlink),
.mtkignore,.claudeignoreorpre-commit-review-list.md— skip and report. - Keep
tasks/lessons.mdtracked;.mtkignoreand.claudeignoreare committed. - Recommended tooling and the .NET companion plugin are surfaced, never installed.
- Cross-agent mirrors need an explicit ask — never orphan a tool a team adopted.
- The version stamp goes to
.claude/mtk-version.jsononly — never a slim.claude/manifest.json.
STEP 4.5: Monorepo — Per-Package CLAUDE.md (conditional)
Reuse STEP 0's setup-detect.sh --json (re-run if it fell out of context): monorepo.is_monorepo, ambiguous, packages, packages_skipped.
is_monorepotrue: generate per-package files below.- false, not ambiguous: skip. Any existing nested
CLAUDE.mdis hand-authored: leave it and list it under "Preserved hand-authored files". Not generating per-package files is never a reason to delete existing ones. - false, ambiguous: ask via
AskUserQuestion(header "Repo layout"): "Yes — generate per-package CLAUDE.md files" / "No — single project".
monorepo.packages is already resolved and capped at 20; when packages_skipped > 0, print "Skipped N packages — generate per-package CLAUDE.md manually for any that need special context." The per-package template, its rules (15–30 line local delta, 5-line stub for trivial packages, never overwrite, never repeat root rules) and the root Monorepo Layout block live in .claude/references/monorepo-bootstrap.md. Read it now and follow it; the layout block goes in root AGENTS.md (inside the 120-line cap), not the shim.
STEP 4.8: Seed Template Cache (for future re-runs)
The snapshot spec (files, layout, copy, retention) lives in .claude/references/bootstrap-template-cache.md. Read it now and follow it.
STEP 4.9: Rebuild References Index
bash scripts/build-references-index.sh regenerates the gitignored .claude/references.index used to auto-select references by file pattern.
STEP 4.95: Seed CODE_INDEX.md
Seed a root CODE_INDEX.md from .claude/references/code-index-template.md unless it exists (consumed by prior-work-check via scripts/query-code-index.sh). Never ship the template's placeholder rows. Populate from the audit's actual capabilities — each path:Symbol must resolve (test -f / git ls-files) — or write an explicitly empty index ("No capabilities indexed yet — add a row when a capability lands").
STEP 5: Verify & Report
Emit the report from .claude/references/bootstrap-report.md verbatim — earlier steps route their report lines into it and verify-claims.sh consumes it.
Bootstrap invariants
- Default to merge mode when a constitution exists — don't ask overwrite/merge/abort.
- Count AGENTS.md lines before finishing (target 60–80, cap 120); the shim stays ~20 lines with no rules.
- Per-package / nested CLAUDE.md files are never overwritten OR deleted at any non-root path, monorepo or not.
.claude/tech-stackis written before completion is reported — every skill reads it.- The generated files are meant to be committed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

