Repo Docs Align
Use this skill to turn repo-doc drift into a grounded plan; when asked or clearly right, verified doc-align implementation.
Read before authority or compression calls:
- references/doc-surfaces-and-authority.md
- references/adaptive-compression.md
- references/subagent-orchestration.md
Bundled resources:
scripts/new_repo_docs_align_artifact.py - scaffold hidden artifacts under .agents/<skill-name>/YYYY-MM/MM-DD/NN/ (<skill-name> = installed skill dir name)
templates/drift-map.md
templates/reviewed-surfaces.md
templates/exec-plan.md
templates/retrospective.md
Core contract
- Start from current repo reality, not prior assumptions.
- Task incomplete until deliverables produced or marked
[blocked].
- One canonical doc surface per concern; update in place; avoid duplicate new docs.
- Default: repo-wide doc alignment - branch changes affect doc-owned concern anywhere → inspect surface, bring current.
- Hidden working artifacts OK for analysis, planning, tracking, retros; not canonical repo docs. Artifacts support run; canonical docs stay authority.
- Nontrivial runs: explicit checklist of outputs + reviewed areas. Before finalize: every deliverable + related doc surface covered or
[blocked].
- Major-choice scoring (material decisions only):
- No global fixed weight mix - per decision, pick criteria + weights for that focus (placement, supersession, stack/tool, scope, governance, risk, readers, maintenance; use what fits best).
- Name dimensions; weights sum to clear whole (e.g.
100%); score options; record rubric + scores in plan/synthesis.
- Target
9.0+ on winning path under that rubric when scoring applies.
- User input improves major decision → one question at a time.
request_user_input when available:
- 2-3 mutually exclusive options
- Rubric for this decision (dimensions + weights) + per-option
0.0-10.0 scores (weighted totals OK)
- Recommended option first
Tool posture
update_plan for nontrivial runs - workstream explicit + checkable.
request_user_input for major authority, scope, artifact decisions repo evidence cannot settle. No broad free-form batches.
- Parallel read-only retrieval when safe for fast discovery.
- Subagents only when available; bounded exploration, evidence, doc/API verification, grep/path/file audits, focused review, validation triage. Main agent keeps authority, synthesis, default edits local.
- Built-in
web.* or MCP research when repo/docs evidence thin, stale, or task asks external verification.
- Tool/plugin discovery only when capability not known this session.
- Image/PDF inspection when source of truth is visual (screenshots, rubrics, scans, PDF-only requirements).
Subagent contract
- Default: exploration + evidence only. No fan-out full doc authorship by default.
- Prefer
1-3 focused subagents; no nested subagents unless user asks.
- Explorer agents read-heavy, evidence-first. Implementation workers only for narrow follow-on after main agent chose authority path.
- Every
spawn_agent call: inherit the custom role's model and effort when
pinned; otherwise choose from the GPT-5.6 routing policy in
references/subagent-orchestration.md.
- Main skill: use Terra for bounded retrieval and Sol for judgment; tighten the
task before escalating an underfitting subagent.
- Every delegated task specifies:
- narrow task or question
- allowed scope or surfaces
- read-only vs may edit
- strict wait expectation
- exact return format
- Default wait: immediately wait for every spawned subagent before substantive
next work or final synthesis.
- Evidence-first returns:
- key finding or result
- files + symbols inspected
- commands or checks run, if any
- recommended next action
- unresolved questions or risks
- Conflicting delegated findings → surface conflict; resolve in main synthesis before act.
Workflow
1. Normalize the job
Extract:
- task
plan-only, plan-then-execute, or audit-only
- user wants durable repo artifact (exec plan/checklist)
- request mentions
AGENTS.md, README, ADRs, specs, runbooks, requirements docs, code comments
- whether compression/token optimization is in scope
User asked specific response format → preserve exactly.
Repo dirty or branch-specific → anchor on current worktree:
git status --short
git diff --name-only
- changed code + docs → active functionality + authority surfaces
- from anchor: sweep related docs needing updates, corrections, supersession, rewrites, new coverage
- worktree = start signal for related-doc discovery, not outer boundary of docs review
- OK to inspect/plan/edit docs untouched in worktree if same functionality, workflow, contract, authority chain
- sweep until repo-wide docs for affected functionality current; no stale related guidance
2. Inventory the repo surfaces
Inspect smallest high-signal set first:
- root
AGENTS.md
- nearest scoped
AGENTS.md
README.md + docs indexes
- repo-local docs hub / status authority:
docs/README.md, requirements.md, release indexes, execution catalogs, machine-readable ledgers when present
- ADR/spec/runbook dirs
- requirements, standards, policy docs when present
- recently changed files + nearby comments/docstrings
rg/repo-native search map likely impacted docs before edit. Parallelize independent read-only discovery before synthesis. Delegation: lightweight explorer subagents for repo mapping only after evidence targets known.
Many docs → prioritize via docs hubs, status ledgers, execution catalogs, changed functionality; prioritization ≠ coverage limit.
3. Route into the right supporting skills and plugins
Prefer repo-native or user-named skills first. Adapt; don’t assume stack.
Examples:
$technical-writing when drafting/rewriting ADRs, specs, runbooks, migration docs, internal guides.
$caveman-compress only when surface fits references/adaptive-compression.md.
$hard-cut when simplifying stale doc structure or removing superseded guidance.
- Stack/platform skills/plugins (for example
$github:github, $cloudflare:*, $expo:*, $sentry-cli, Context7, or built-in web search) only when repo context or user request makes them relevant and the capability is installed.
Named skill/plugin unavailable → note briefly; closest valid fallback.
4. Build a drift map before proposing changes
Compare current docs to:
- implemented behavior
- current scripts/commands
- current architecture + file ownership
- current validation flow
- branch-specific changes that made existing docs stale
- related repo docs describing, constraining, teaching, operating, validating, routing affected functionality
Good delegation:
- one explorer:
AGENTS.md + scoped guidance drift
- one explorer: ADR/spec/runbook/README ownership mapping
- one explorer: external doc/API verification when repo evidence thin; built-in
web.* where search needed
Classify each finding:
update-in-place
create-canonical-doc
mark-superseded
delete-stale-guidance
leave-unchanged
No new docs until existing authority doc confirmed not owning concern.
Don’t stop at first matching doc. Follow authority chain across README hubs, AGENTS, requirements, ADRs, specs, runbooks, setup, release docs, prompt catalogs, nearby comments/docstrings until related doc set aligned.
Map every proposed doc/comment change to exact file, path, or code-comment surface. No named target → not grounded yet.
5. Choose the canonical authority path
Authority matrix in references/doc-surfaces-and-authority.md.
Rules:
- Prefer modifying current canonical doc over creating new.
- New ADR/spec/runbook only when concern materially new + doesn’t fit current authority surface.
- Keep
AGENTS.md durable repo guidance only — no task logs or branch narration.
- Repo already has docs-role map, status ledger, execution catalog → first-class authority input before inventing placement.
- Long-lived execution context needed → create/update one checkable repo-local exec artifact per existing naming conventions.
6. Produce the durable exec artifact when needed
Future-session handoff → create/update one canonical plan/checklist with only fitting sections:
- scope + intent
- summary of completed work
- files + surfaces reviewed
- what is done
- remaining tasks + subtasks
- further improvements worth considering
- required research
- decisions made + open decisions
- validation commands + success criteria
- required skills/plugins/tools
- exact files/dirs to load next session
- enforced rules/invariants next session must preserve
- blockers + assumptions
Execution-oriented, not diary.
If the repo already has an execution catalog, prompt ledger, or trigger-prompt system, update that canonical surface, not parallel plan file.
6a. Hidden working artifact policy
Non-canonical artifacts from this skill default:
.agents/<skill-name>/YYYY-MM/MM-DD/NN/
When this skill is installed as repo-docs-align, that resolves to .agents/repo-docs-align/YYYY-MM/MM-DD/NN/.
Use this hidden work area for things like:
drift-map.md
reviewed-surfaces.md
exec-plan.md
retrospective.md
- other temporary/session analysis supporting docs alignment
Rules:
- create directory when needed
- fresh numeric run bucket
01, 02, 03 same-day repeats
- ensure repo ignores
.agents/ or min .agents/<skill-name>/
- canonical docs, ledgers, specs, ADRs, runbooks, active execution catalogs stay true authority surfaces — not
.agents/<skill-name>/
- typed filenames vs one giant note when artifacts differ materially
- only create artifacts useful for run; no empty scaffolding
Deterministic scaffolding for hidden work area:
python3 scripts/new_repo_docs_align_artifact.py \
--dir <repo-root> \
--artifacts drift-map,reviewed-surfaces,exec-plan,retrospective
Run exact command from installed skill directory. Script resolves bundled templates relative to itself; shorter relative path unambiguous install-wide.
--artifacts = only files needed. --force = only when intentionally refreshing existing artifact file.
7. Implement doc and comment changes when the task calls for execution
After drift map + authority are grounded:
- update canonical docs
- tighten or remove stale guidance
- align nearby code comments/docstrings where useful
- smallest edit set that fully resolves grounded drift; no partially corrected authority chains
- minimal, reviewable diffs
Do not rewrite unrelated docs for imperfection alone.
8. Apply adaptive compression only where it improves the repo
Follow references/adaptive-compression.md.
Default:
- compress internal operational, agent-facing, workflow, repo-maintenance docs when scan speed + token efficiency improve
- richer prose for public, product, marketing, narrative, teaching docs unless user requests compression
When compressing:
- preserve code, commands, paths, URLs, headings, tables, exact technical terms
- keep document navigable
- don’t cavemanify docs whose value is nuanced explanation or polished prose
9. Verify before finalizing
Verify:
- every doc change maps to specific file or confirmed gap
- every unchanged reviewed surface has reason (explicit or implicit) grounded in current repo reality
- authority choices match current repo structure
- requested deliverables complete
- formatting matches surrounding docs
- referenced commands, scripts, paths still exist
- irreversible or external side effects surfaced before execution
Changed AGENTS.md → re-read it end to end before closeout and confirm every
command and gate it names still resolves.
Output shape
Default order unless user asked for a different format:
- drift summary
- canonical authority decisions
- exec artifact path or inline plan
- implemented doc/comment changes
- verification commands + residual gaps
Stop rules
- Stop + ask only when major authority decision genuinely ambiguous + repo evidence can’t resolve.
- Missing evidence or uncertain claims →
UNVERIFIED.
- Retrieval empty or suspiciously narrow → retry one or two different strategies before conclude.
1---2name: repo-docs-align3description: Sync repo docs (AGENTS, README, ADRs, specs, runbooks, doc comments) ↔ code/workflow. Triggers—big change, drift, docs-align/AGENTS prompts, plan, governance. Repo-native tools, any stack.4metadata:5 successor_to: docs-align6---78# Repo Docs Align910Use this skill to turn repo-doc drift into a grounded plan; when asked or clearly right, verified doc-align implementation.1112Read before authority or compression calls:1314- [references/doc-surfaces-and-authority.md](references/doc-surfaces-and-authority.md)15- [references/adaptive-compression.md](references/adaptive-compression.md)16- [references/subagent-orchestration.md](references/subagent-orchestration.md)1718Bundled resources:1920- `scripts/new_repo_docs_align_artifact.py` - scaffold hidden artifacts under `.agents/<skill-name>/YYYY-MM/MM-DD/NN/` (`<skill-name>` = installed skill dir name)21- `templates/drift-map.md`22- `templates/reviewed-surfaces.md`23- `templates/exec-plan.md`24- `templates/retrospective.md`2526## Core contract2728- Start from current repo reality, not prior assumptions.29- Task incomplete until deliverables produced or marked `[blocked]`.30- One canonical doc surface per concern; update in place; avoid duplicate new docs.31- Default: repo-wide doc alignment - branch changes affect doc-owned concern anywhere → inspect surface, bring current.32- Hidden working artifacts OK for analysis, planning, tracking, retros; not canonical repo docs. Artifacts support run; canonical docs stay authority.33- Nontrivial runs: explicit checklist of outputs + reviewed areas. Before finalize: every deliverable + related doc surface covered or `[blocked]`.34- Major-choice scoring (material decisions only):35 - No global fixed weight mix - per decision, pick criteria + weights for that focus (placement, supersession, stack/tool, scope, governance, risk, readers, maintenance; use what fits best).36 - Name dimensions; weights sum to clear whole (e.g. `100%`); score options; record rubric + scores in plan/synthesis.37 - Target `9.0+` on winning path under that rubric when scoring applies.38- User input improves major decision → one question at a time. `request_user_input` when available:39 - 2-3 mutually exclusive options40 - Rubric for this decision (dimensions + weights) + per-option `0.0-10.0` scores (weighted totals OK)41 - Recommended option first4243## Tool posture4445- `update_plan` for nontrivial runs - workstream explicit + checkable.46- `request_user_input` for major authority, scope, artifact decisions repo evidence cannot settle. No broad free-form batches.47- Parallel read-only retrieval when safe for fast discovery.48- Subagents only when available; bounded exploration, evidence, doc/API verification, grep/path/file audits, focused review, validation triage. Main agent keeps authority, synthesis, default edits local.49- Built-in `web.*` or MCP research when repo/docs evidence thin, stale, or task asks external verification.50- Tool/plugin discovery only when capability not known this session.51- Image/PDF inspection when source of truth is visual (screenshots, rubrics, scans, PDF-only requirements).5253## Subagent contract5455- Default: exploration + evidence only. No fan-out full doc authorship by default.56- Prefer `1-3` focused subagents; no nested subagents unless user asks.57- Explorer agents read-heavy, evidence-first. Implementation workers only for narrow follow-on after main agent chose authority path.58- Every `spawn_agent` call: inherit the custom role's model and effort when59 pinned; otherwise choose from the GPT-5.6 routing policy in60 `references/subagent-orchestration.md`.61- Main skill: use Terra for bounded retrieval and Sol for judgment; tighten the62 task before escalating an underfitting subagent.63- Every delegated task specifies:64 - narrow task or question65 - allowed scope or surfaces66 - read-only vs may edit67 - strict wait expectation68 - exact return format69- Default wait: immediately wait for every spawned subagent before substantive70 next work or final synthesis.71- Evidence-first returns:72 - key finding or result73 - files + symbols inspected74 - commands or checks run, if any75 - recommended next action76 - unresolved questions or risks77- Conflicting delegated findings → surface conflict; resolve in main synthesis before act.7879## Workflow8081### 1. Normalize the job8283Extract:8485- task `plan-only`, `plan-then-execute`, or `audit-only`86- user wants durable repo artifact (exec plan/checklist)87- request mentions `AGENTS.md`, README, ADRs, specs, runbooks, requirements docs, code comments88- whether compression/token optimization is in scope8990User asked specific response format → preserve exactly.9192Repo dirty or branch-specific → anchor on current worktree:9394- `git status --short`95- `git diff --name-only`96- changed code + docs → active functionality + authority surfaces97- from anchor: sweep related docs needing updates, corrections, supersession, rewrites, new coverage98- worktree = start signal for related-doc discovery, not outer boundary of docs review99- OK to inspect/plan/edit docs untouched in worktree if same functionality, workflow, contract, authority chain100- sweep until repo-wide docs for affected functionality current; no stale related guidance101102### 2. Inventory the repo surfaces103104Inspect smallest high-signal set first:105106- root `AGENTS.md`107- nearest scoped `AGENTS.md`108- `README.md` + docs indexes109- repo-local docs hub / status authority: `docs/README.md`, `requirements.md`, release indexes, execution catalogs, machine-readable ledgers when present110- ADR/spec/runbook dirs111- requirements, standards, policy docs when present112- recently changed files + nearby comments/docstrings113114`rg`/repo-native search map likely impacted docs before edit. Parallelize independent read-only discovery before synthesis. Delegation: lightweight explorer subagents for repo mapping only after evidence targets known.115Many docs → prioritize via docs hubs, status ledgers, execution catalogs, changed functionality; prioritization ≠ coverage limit.116117### 3. Route into the right supporting skills and plugins118119Prefer repo-native or user-named skills first. Adapt; don’t assume stack.120121Examples:122123- `$technical-writing` when drafting/rewriting ADRs, specs, runbooks, migration docs, internal guides.124- `$caveman-compress` only when surface fits `references/adaptive-compression.md`.125- `$hard-cut` when simplifying stale doc structure or removing superseded guidance.126- Stack/platform skills/plugins (for example `$github:github`, `$cloudflare:*`, `$expo:*`, `$sentry-cli`, Context7, or built-in web search) only when repo context or user request makes them relevant and the capability is installed.127128Named skill/plugin unavailable → note briefly; closest valid fallback.129130### 4. Build a drift map before proposing changes131132Compare current docs to:133134- implemented behavior135- current scripts/commands136- current architecture + file ownership137- current validation flow138- branch-specific changes that made existing docs stale139- related repo docs describing, constraining, teaching, operating, validating, routing affected functionality140141Good delegation:142143- one explorer: `AGENTS.md` + scoped guidance drift144- one explorer: ADR/spec/runbook/README ownership mapping145- one explorer: external doc/API verification when repo evidence thin; built-in `web.*` where search needed146147Classify each finding:148149- `update-in-place`150- `create-canonical-doc`151- `mark-superseded`152- `delete-stale-guidance`153- `leave-unchanged`154155No new docs until existing authority doc confirmed not owning concern.156Don’t stop at first matching doc. Follow authority chain across README hubs, AGENTS, requirements, ADRs, specs, runbooks, setup, release docs, prompt catalogs, nearby comments/docstrings until related doc set aligned.157Map every proposed doc/comment change to exact file, path, or code-comment surface. No named target → not grounded yet.158159### 5. Choose the canonical authority path160161Authority matrix in `references/doc-surfaces-and-authority.md`.162163Rules:164165- Prefer modifying current canonical doc over creating new.166- New ADR/spec/runbook only when concern materially new + doesn’t fit current authority surface.167- Keep `AGENTS.md` durable repo guidance only — no task logs or branch narration.168- Repo already has docs-role map, status ledger, execution catalog → first-class authority input before inventing placement.169- Long-lived execution context needed → create/update one checkable repo-local exec artifact per existing naming conventions.170171### 6. Produce the durable exec artifact when needed172173Future-session handoff → create/update one canonical plan/checklist with only fitting sections:174175- scope + intent176- summary of completed work177- files + surfaces reviewed178- what is done179- remaining tasks + subtasks180- further improvements worth considering181- required research182- decisions made + open decisions183- validation commands + success criteria184- required skills/plugins/tools185- exact files/dirs to load next session186- enforced rules/invariants next session must preserve187- blockers + assumptions188189Execution-oriented, not diary.190If the repo already has an execution catalog, prompt ledger, or trigger-prompt system, update that canonical surface, not parallel plan file.191192### 6a. Hidden working artifact policy193194Non-canonical artifacts from this skill default:195196- `.agents/<skill-name>/YYYY-MM/MM-DD/NN/`197198When this skill is installed as `repo-docs-align`, that resolves to `.agents/repo-docs-align/YYYY-MM/MM-DD/NN/`.199200Use this hidden work area for things like:201202- `drift-map.md`203- `reviewed-surfaces.md`204- `exec-plan.md`205- `retrospective.md`206- other temporary/session analysis supporting docs alignment207208Rules:209210- create directory when needed211- fresh numeric run bucket `01`, `02`, `03` same-day repeats212- ensure repo ignores `.agents/` or min `.agents/<skill-name>/`213- canonical docs, ledgers, specs, ADRs, runbooks, active execution catalogs stay true authority surfaces — not `.agents/<skill-name>/`214- typed filenames vs one giant note when artifacts differ materially215- only create artifacts useful for run; no empty scaffolding216217Deterministic scaffolding for hidden work area:218219```bash220python3 scripts/new_repo_docs_align_artifact.py \221 --dir <repo-root> \222 --artifacts drift-map,reviewed-surfaces,exec-plan,retrospective223```224225Run exact command from installed skill directory. Script resolves bundled templates relative to itself; shorter relative path unambiguous install-wide.226227`--artifacts` = only files needed. `--force` = only when intentionally refreshing existing artifact file.228229### 7. Implement doc and comment changes when the task calls for execution230231After drift map + authority are grounded:232233- update canonical docs234- tighten or remove stale guidance235- align nearby code comments/docstrings where useful236- smallest edit set that fully resolves grounded drift; no partially corrected authority chains237- minimal, reviewable diffs238239Do not rewrite unrelated docs for imperfection alone.240241### 8. Apply adaptive compression only where it improves the repo242243Follow `references/adaptive-compression.md`.244245Default:246247- compress internal operational, agent-facing, workflow, repo-maintenance docs when scan speed + token efficiency improve248- richer prose for public, product, marketing, narrative, teaching docs unless user requests compression249250When compressing:251252- preserve code, commands, paths, URLs, headings, tables, exact technical terms253- keep document navigable254- don’t cavemanify docs whose value is nuanced explanation or polished prose255256### 9. Verify before finalizing257258Verify:259260- every doc change maps to specific file or confirmed gap261- every unchanged reviewed surface has reason (explicit or implicit) grounded in current repo reality262- authority choices match current repo structure263- requested deliverables complete264- formatting matches surrounding docs265- referenced commands, scripts, paths still exist266- irreversible or external side effects surfaced before execution267268Changed `AGENTS.md` → re-read it end to end before closeout and confirm every269command and gate it names still resolves.270271## Output shape272273Default order unless user asked for a different format:2742751. drift summary2762. canonical authority decisions2773. exec artifact path or inline plan2784. implemented doc/comment changes2795. verification commands + residual gaps280281## Stop rules282283- Stop + ask only when major authority decision genuinely ambiguous + repo evidence can’t resolve.284- Missing evidence or uncertain claims → `UNVERIFIED`.285- Retrieval empty or suspiciously narrow → retry one or two different strategies before conclude.