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.4---56# Repo Docs Align78Use this skill to turn repo-doc drift into a grounded plan; when asked or clearly right, verified doc-align implementation.910Read before authority or compression calls:1112- [references/doc-surfaces-and-authority.md](references/doc-surfaces-and-authority.md)13- [references/adaptive-compression.md](references/adaptive-compression.md)14- [references/subagent-orchestration.md](references/subagent-orchestration.md)1516Bundled resources:1718- `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)19- `templates/drift-map.md`20- `templates/reviewed-surfaces.md`21- `templates/exec-plan.md`22- `templates/retrospective.md`2324## Core contract2526- Start from current repo reality, not prior assumptions.27- Task incomplete until deliverables produced or marked `[blocked]`.28- One canonical doc surface per concern; update in place; avoid duplicate new docs.29- Default: repo-wide doc alignment - branch changes affect doc-owned concern anywhere → inspect surface, bring current.30- Hidden working artifacts OK for analysis, planning, tracking, retros; not canonical repo docs. Artifacts support run; canonical docs stay authority.31- Nontrivial runs: explicit checklist of outputs + reviewed areas. Before finalize: every deliverable + related doc surface covered or `[blocked]`.32- Major-choice scoring (material decisions only):33 - 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).34 - Name dimensions; weights sum to clear whole (e.g. `100%`); score options; record rubric + scores in plan/synthesis.35 - Target `9.0+` on winning path under that rubric when scoring applies.36- User input improves major decision → one question at a time. `request_user_input` when available:37 - 2-3 mutually exclusive options38 - Rubric for this decision (dimensions + weights) + per-option `0.0-10.0` scores (weighted totals OK)39 - Recommended option first4041## Tool posture4243- `update_plan` for nontrivial runs - workstream explicit + checkable.44- `request_user_input` for major authority, scope, artifact decisions repo evidence cannot settle. No broad free-form batches.45- Parallel read-only retrieval when safe for fast discovery.46- 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.47- Built-in `web.*` or MCP research when repo/docs evidence thin, stale, or task asks external verification.48- Tool/plugin discovery only when capability not known this session.49- Image/PDF inspection when source of truth is visual (screenshots, rubrics, scans, PDF-only requirements).5051## Subagent contract5253- Default: exploration + evidence only. No fan-out full doc authorship by default.54- Prefer `1-3` focused subagents; no nested subagents unless user asks.55- Explorer agents read-heavy, evidence-first. Implementation workers only for narrow follow-on after main agent chose authority path.56- Every `spawn_agent` call: inherit the custom role's model and effort when57 pinned; otherwise choose from the GPT-5.6 routing policy in58 `references/subagent-orchestration.md`.59- Main skill: use Terra for bounded retrieval and Sol for judgment; tighten the60 task before escalating an underfitting subagent.61- Every delegated task specifies:62 - narrow task or question63 - allowed scope or surfaces64 - read-only vs may edit65 - strict wait expectation66 - exact return format67- Default wait: immediately wait for every spawned subagent before substantive68 next work or final synthesis.69- Evidence-first returns:70 - key finding or result71 - files + symbols inspected72 - commands or checks run, if any73 - recommended next action74 - unresolved questions or risks75- Conflicting delegated findings → surface conflict; resolve in main synthesis before act.7677## Workflow7879### 1. Normalize the job8081Extract:8283- task `plan-only`, `plan-then-execute`, or `audit-only`84- user wants durable repo artifact (exec plan/checklist)85- request mentions `AGENTS.md`, README, ADRs, specs, runbooks, requirements docs, code comments86- whether compression/token optimization is in scope8788User asked specific response format → preserve exactly.8990Repo dirty or branch-specific → anchor on current worktree:9192- `git status --short`93- `git diff --name-only`94- changed code + docs → active functionality + authority surfaces95- from anchor: sweep related docs needing updates, corrections, supersession, rewrites, new coverage96- worktree = start signal for related-doc discovery, not outer boundary of docs review97- OK to inspect/plan/edit docs untouched in worktree if same functionality, workflow, contract, authority chain98- sweep until repo-wide docs for affected functionality current; no stale related guidance99100### 2. Inventory the repo surfaces101102Inspect smallest high-signal set first:103104- root `AGENTS.md`105- nearest scoped `AGENTS.md`106- `README.md` + docs indexes107- repo-local docs hub / status authority: `docs/README.md`, `requirements.md`, release indexes, execution catalogs, machine-readable ledgers when present108- ADR/spec/runbook dirs109- requirements, standards, policy docs when present110- recently changed files + nearby comments/docstrings111112`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.113Many docs → prioritize via docs hubs, status ledgers, execution catalogs, changed functionality; prioritization ≠ coverage limit.114115### 3. Route into the right supporting skills and plugins116117Prefer repo-native or user-named skills first. Adapt; don’t assume stack.118119Examples:120121- `$technical-writing` when drafting/rewriting ADRs, specs, runbooks, migration docs, internal guides.122- `$caveman-compress` only when surface fits `references/adaptive-compression.md`.123- `$hard-cut` when simplifying stale doc structure or removing superseded guidance.124- 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.125126Named skill/plugin unavailable → note briefly; closest valid fallback.127128### 4. Build a drift map before proposing changes129130Compare current docs to:131132- implemented behavior133- current scripts/commands134- current architecture + file ownership135- current validation flow136- branch-specific changes that made existing docs stale137- related repo docs describing, constraining, teaching, operating, validating, routing affected functionality138139Good delegation:140141- one explorer: `AGENTS.md` + scoped guidance drift142- one explorer: ADR/spec/runbook/README ownership mapping143- one explorer: external doc/API verification when repo evidence thin; built-in `web.*` where search needed144145Classify each finding:146147- `update-in-place`148- `create-canonical-doc`149- `mark-superseded`150- `delete-stale-guidance`151- `leave-unchanged`152153No new docs until existing authority doc confirmed not owning concern.154Don’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.155Map every proposed doc/comment change to exact file, path, or code-comment surface. No named target → not grounded yet.156157### 5. Choose the canonical authority path158159Authority matrix in `references/doc-surfaces-and-authority.md`.160161Rules:162163- Prefer modifying current canonical doc over creating new.164- New ADR/spec/runbook only when concern materially new + doesn’t fit current authority surface.165- Keep `AGENTS.md` durable repo guidance only — no task logs or branch narration.166- Repo already has docs-role map, status ledger, execution catalog → first-class authority input before inventing placement.167- Long-lived execution context needed → create/update one checkable repo-local exec artifact per existing naming conventions.168169### 6. Produce the durable exec artifact when needed170171Future-session handoff → create/update one canonical plan/checklist with only fitting sections:172173- scope + intent174- summary of completed work175- files + surfaces reviewed176- what is done177- remaining tasks + subtasks178- further improvements worth considering179- required research180- decisions made + open decisions181- validation commands + success criteria182- required skills/plugins/tools183- exact files/dirs to load next session184- enforced rules/invariants next session must preserve185- blockers + assumptions186187Execution-oriented, not diary.188If the repo already has an execution catalog, prompt ledger, or trigger-prompt system, update that canonical surface, not parallel plan file.189190### 6a. Hidden working artifact policy191192Non-canonical artifacts from this skill default:193194- `.agents/<skill-name>/YYYY-MM/MM-DD/NN/`195196When this skill is installed as `repo-docs-align`, that resolves to `.agents/repo-docs-align/YYYY-MM/MM-DD/NN/`.197198Use this hidden work area for things like:199200- `drift-map.md`201- `reviewed-surfaces.md`202- `exec-plan.md`203- `retrospective.md`204- other temporary/session analysis supporting docs alignment205206Rules:207208- create directory when needed209- fresh numeric run bucket `01`, `02`, `03` same-day repeats210- ensure repo ignores `.agents/` or min `.agents/<skill-name>/`211- canonical docs, ledgers, specs, ADRs, runbooks, active execution catalogs stay true authority surfaces — not `.agents/<skill-name>/`212- typed filenames vs one giant note when artifacts differ materially213- only create artifacts useful for run; no empty scaffolding214215Deterministic scaffolding for hidden work area:216217```bash218python3 scripts/new_repo_docs_align_artifact.py \219 --dir <repo-root> \220 --artifacts drift-map,reviewed-surfaces,exec-plan,retrospective221```222223Run exact command from installed skill directory. Script resolves bundled templates relative to itself; shorter relative path unambiguous install-wide.224225`--artifacts` = only files needed. `--force` = only when intentionally refreshing existing artifact file.226227### 7. Implement doc and comment changes when the task calls for execution228229After drift map + authority are grounded:230231- update canonical docs232- tighten or remove stale guidance233- align nearby code comments/docstrings where useful234- smallest edit set that fully resolves grounded drift; no partially corrected authority chains235- minimal, reviewable diffs236237Do not rewrite unrelated docs for imperfection alone.238239### 8. Apply adaptive compression only where it improves the repo240241Follow `references/adaptive-compression.md`.242243Default:244245- compress internal operational, agent-facing, workflow, repo-maintenance docs when scan speed + token efficiency improve246- richer prose for public, product, marketing, narrative, teaching docs unless user requests compression247248When compressing:249250- preserve code, commands, paths, URLs, headings, tables, exact technical terms251- keep document navigable252- don’t cavemanify docs whose value is nuanced explanation or polished prose253254### 9. Verify before finalizing255256Verify:257258- every doc change maps to specific file or confirmed gap259- every unchanged reviewed surface has reason (explicit or implicit) grounded in current repo reality260- authority choices match current repo structure261- requested deliverables complete262- formatting matches surrounding docs263- referenced commands, scripts, paths still exist264- irreversible or external side effects surfaced before execution265266Changed `AGENTS.md` → re-read it end to end before closeout and confirm every267command and gate it names still resolves.268269## Output shape270271Default order unless user asked for a different format:2722731. drift summary2742. canonical authority decisions2753. exec artifact path or inline plan2764. implemented doc/comment changes2775. verification commands + residual gaps278279## Stop rules280281- Stop + ask only when major authority decision genuinely ambiguous + repo evidence can’t resolve.282- Missing evidence or uncertain claims → `UNVERIFIED`.283- Retrieval empty or suspiciously narrow → retry one or two different strategies before conclude.