agentleFS
paullukicpaullukic/coograph/.github/skills/coograph-docs-restructure/SKILL.md

coograph-docs-restructure

Skill17 starsChanged 39 days agoMITView on GitHub

Bring a project's instruction and map files back under the tier budgets. Takes stock with layout.py, works out the project's shape, writes a project-specific OpenSpec (areas, layout.json, gotcha extraction), and after approval migrates one area per agent with every kept fact checked against the code. Use when layout.py --budget or a retro reports STRUCTURAL, or when maps have turned into changelogs.

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 4 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read .github/layout/README.md once before starting.

    line 17
  2. Very specific:

    Look for a non-archived openspec/changes/*-docs-restructure/.

    line 36
  3. Distinctive:

    Create the change directory now, so the snapshot lives with the change and is archived with it (a later restructure then takes a fresh one):

    line 54
  4. Very specific:

    If .github/layout/layout.py is missing, the project predates the layout checker: tell the user to sync coograph (git pull in the coograph …

    line 63
  5. Very specific:

    Use the code-graph first (get_minimal_context), then git ls-files patterns.

    line 74
  6. Very specific:

    Gotchas: Every trap buried in a map: a symptom with a non-obvious cause (environment, deploy, tooling, an error message that points the …

    line 97
  7. Very specific:

    Do not edit any instruction file before approval.

    line 134
  8. Very specific:

    If --budget still fails, the area split is wrong: split the over-budget doc, update the OpenSpec, and say so.

    line 212
  9. Distinctive:

    No instruction file is edited before the user approves the OpenSpec.

    line 217
  10. Distinctive:

    Every fact is checked against the code.

    line 218
  11. Distinctive:

    No dated sections in any new file.

    line 222

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Restructure the project's instruction files into the three tiers in .github/layout/README.md: always-loaded root files (9K combined), workspace routers (about 2K each), and on-demand feature docs (8K each), plus GOTCHAS.md. Two phases with a hard stop between them: Propose writes an OpenSpec and stops; Apply runs only after the user approves it.

Read .github/layout/README.md once before starting. It defines the tiers, the config, the feature-doc frontmatter and the gotcha format.

The rule that matters most: no current-state fact is lost, and no stale fact survives. Old map sections are often out of date. Every fact is checked against the code and gets one of three marks:

  • [x] file:line: the code confirms it. Keep it.
  • [kept: not in code]: the code can neither confirm nor contradict it (a deploy step, a console setting, a renewal date, team process). Keep it: in the area doc, or in GOTCHAS.md when it is a trap. "Not provable from code" is never a reason to drop.
  • [dropped: <reason>]: only when the code contradicts it, it is history rather than current state, or it duplicates another area.

Step 0: Resume or start

Look for a non-archived openspec/changes/*-docs-restructure/.

Approval is recorded on disk, not only in the conversation: the line approved: <YYYY-MM-DD> in the change's .openspec.yaml (Phase 1 writes it when the user approves, before the first Phase 2 edit).

  • Found, no proposal.md yet: an aborted Phase 1. Reuse that directory and its date, and continue at Step 2. Keep notes/layout-before.json when it parses as JSON with a tiers key; otherwise retake it (Step 1). Never create a second directory with a new date.
  • Found, proposal.md but no approved: line: show it and ask whether to continue with it or discard it. Never start a second one alongside it.
  • Found and approved: this is a resume. Go to Phase 2 and continue at the first unticked task in its tasks.md. Do not re-run Phase 1. Never regenerate notes/areas/*.md, notes/gotchas.md, notes/rules.md or notes/layout-before.json: they hold the only record of the original facts and the before numbers. Phase 2 only adds marks to them ([x], [kept: ...], [dropped: ...]) and writes notes/layout-after.json.
  • An area name was given (/coograph-docs-restructure auth): it applies only to an approved restructure. Run just that area's task. If no approved restructure exists, say so and stop.
  • Not found: Phase 1.

Phase 1: Propose

Step 1: Take stock

Create the change directory now, so the snapshot lives with the change and is archived with it (a later restructure then takes a fresh one):

python3 .github/layout/layout.py --budget
mkdir -p openspec/changes/<YYYY-MM-DD>-docs-restructure/notes
python3 .github/layout/layout.py --json > openspec/changes/<YYYY-MM-DD>-docs-restructure/notes/layout-before.tmp   && mv openspec/changes/<YYYY-MM-DD>-docs-restructure/notes/layout-before.tmp openspec/changes/<YYYY-MM-DD>-docs-restructure/notes/layout-before.json

If .github/layout/layout.py is missing, the project predates the layout checker: tell the user to sync coograph (git pull in the coograph checkout) or re-run /coograph-init, and stop.

From the JSON, record per file: tier, tokens, over budget, dated headings, duplicate paragraphs, table padding. These are the "before" numbers for the proposal; copy them, do not recompute.

Then list every instruction-like file the config does not know about yet, so nothing is missed: **/AGENTS.md, **/CLAUDE.md, **/*.instructions.md, docs/**/*.md that describe behaviour, CONVENTIONS.md, .cursor/rules/*. Use the code-graph first (get_minimal_context), then git ls-files patterns.

Step 2: Work out the shape

  • Workspaces. From package.json workspaces, pnpm-workspace.yaml, turbo.json, nx.json, go.work, the [workspace] table of Cargo.toml, or top-level directories that hold their own manifest. None means a single-package repo: no routers.
  • Tools in use. Which of CLAUDE.md, AGENTS.md, .github/copilot-instructions.md, .cursor/, .windsurfrules, CONVENTIONS.md, .clinerules exist. Every rule must stay reachable from each tool's entry file.
  • Product areas. Group map sections by the feature they describe, not by the workspace they sit in: "auth" spans web, mobile, core and functions. Read the headings of every map; a dated heading (## Login (openspec 2026-09-01)) names an area and a change, so several dated headings collapse into one area. Aim for 5 to 15 areas. An area whose current state will not fit in 8K is two areas.
  • Hard rules. Find every rule stated in more than one root file (duplicate_paragraphs lists the exact ones; also look for the same rule reworded). Each gets one home: hard rules and workflow in AGENTS.md, code conventions in .github/copilot-instructions.md, Claude-only extras in CLAUDE.md, which imports the other two with @.
  • Gotchas. Every trap buried in a map: a symptom with a non-obvious cause (environment, deploy, tooling, an error message that points the wrong way). Each becomes a GOTCHAS.md entry with paths: (and commands: where a command triggers it).

Step 3: Write the OpenSpec

openspec/changes/<YYYY-MM-DD>-docs-restructure/ with the usual files:

  • proposal.md: Why (the before numbers and the structural reasons, copied from Step 1), Goals (the after budgets), the area table, Decisions (where each hard rule lives; which files become routers; what happens to each old map), Risks.
  • layout.json proposal in the Decisions section: always_loaded, routers (one glob per workspace), docs, gotchas, budgets. Keep the seed budgets unless the user asks otherwise.
  • notes/areas/<area>.md, one per area: every fact the old files state about it, one line each, with its source (apps/web/AGENTS.md § Login). This is the fact list Apply ticks off.
  • notes/gotchas.md: every gotcha candidate with its source.
  • notes/rules.md: every rule in the root files, its current homes, and its one new home.
  • tasks.md, in this order:
    1. one task per area (docs/features/<area>.md, every fact in notes/areas/<area>.md marked [x], [kept: ...] or [dropped: <reason>]);
    2. GOTCHAS.md (every candidate placed or dropped with a reason);
    3. routers (each workspace's AGENTS.md cut to commands, gotcha pointers and an area index, plus a one-line <workspace>/CLAUDE.md holding @AGENTS.md when Claude Code is in use);
    4. root files (rules de-duplicated per notes/rules.md, routing table filled);
    5. .github/layout/layout.json;
    6. verification: layout.py --budget exits 0, every notes/areas/*.md line is marked, /coograph-review run.

Stop. Tell the user what the restructure will do in five lines (areas, files removed, files created, before and after budgets) and wait for approval. Do not edit any instruction file before approval. On approval, add approved: <YYYY-MM-DD> to the change's .openspec.yaml first; Step 0 reads it to tell a resume from a fresh start.


Phase 2: Apply (after approval)

Work through tasks.md in order.

Areas: one agent each

For each area task, delegate to one subagent (the @Explore agent for reading, then write the doc yourself, or one general agent per area where the tool supports it). Give it:

  • the area's notes/areas/<area>.md fact list;
  • the source sections, quoted;
  • the template below;
  • the instruction: check every fact against the code with the code-graph first (get_minimal_context, query_graph), then by reading the files. Mark it [x] with the confirming file:line; [kept: not in code] when the code can neither confirm nor contradict it (keep it in the doc); or [dropped: <reason>] only when the code contradicts it, it is history, or it duplicates another area.

Feature doc template:

---
paths:
  - <glob for every directory this area's code lives in, across workspaces>
---
# <Area>

<one paragraph: what this area does for the user>

## Core
- <current-state facts, bullets, no dates>
## Web
- ...
## Mobile
- ...
## Functions / backend
- ...
## Rules
- <constraints specific to this area>

Bullets, not wide tables (a table padded by a formatter costs more than its text). No dated headings, no "added in", no "(openspec ...)": history lives in openspec/changes/archive/ and git. Keep each doc under 8K tokens (layout.py --budget checks it).

Gotchas, routers, root files

  • GOTCHAS.md: entries in the format of .github/layout/README.md, each under 800 bytes. A gotcha the code contradicts (the trap was fixed) is dropped in notes/gotchas.md with the reason; one the code cannot confirm either way is kept.
  • Routers: commands for that workspace, the gotcha pointer, and an area index (auth → docs/features/auth.md). Nothing else. About 2K tokens.
  • Root files: apply notes/rules.md. Fill the routing table in AGENTS.md (Touching <glob> → read docs/features/<area>.md).

Verify

python3 .github/layout/layout.py --budget
python3 .github/layout/layout.py --json > openspec/changes/<YYYY-MM-DD>-docs-restructure/notes/layout-after.json

--budget must exit 0. Report before and after per tier from the two JSON files. Every line in every notes/areas/*.md and notes/gotchas.md carries a mark ([x], [kept: ...] or [dropped: <reason>]); count each mark and report the counts. Then run /coograph-review on the change.

If --budget still fails, the area split is wrong: split the over-budget doc, update the OpenSpec, and say so. Do not trim facts to fit.

Guardrails

  • No instruction file is edited before the user approves the OpenSpec.
  • Every fact is checked against the code. A fact the code cannot confirm or contradict is kept and marked; a fact is dropped only when the code contradicts it, it is history, or it is a duplicate, with the reason in the notes.
  • No dated sections in any new file.
  • Each rule is stated in exactly one file.
  • GOTCHAS.md is never always-loaded: never @-import it.
  • The project's layout.json is the user's: propose its contents in the OpenSpec, write it only in Apply.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.