refactor(skills): retrofit the corpus to the ADR-0020 context contract (#129)
Retrofits all 39 skills to ADR-0020's description/body context contract, then fixes what six rounds of independent review found in that retrofit — including four ways the hot gate itself failed open. Closes #99, #107, #108, #110, #111, #114, #115, #120. ## The retrofit (waves 1-5) | | Start | Now | |---|---|---| | Description FAILs (>400 chars) | 26 | **0** | | Body FAILs (>900 words, body-only) | 9 | **0** | | Dangling routing targets | 2 | **0** | | `Kyberforge.CompositionNote` | 10 | **0** | | Preload tax | 21,005 chars | **~10,500** | Under the 12,000-char success criterion. Per-wave detail is on #99. ## The review fixes **The gate failed open four ways, three of them found after the retrofit shipped.** An unrecognised follower token made a dangling target vanish. A skill directory with no `SKILL.md` resolved as a valid target, so a commit could be green locally and red in a fresh clone — three existing fixtures were relying on that, one of which made the install-leak A/B pass vacuously. Then the free-standing `/name` sweep turned out to be gated on the sentence carrying a boundary marker, so route notation in any other sentence was invisible — not an ERROR, not a SUGGESTION, not an INFO — which left the documented "`/name` always blocks" promise false from a second direction. All four fixed and pinned. **Two checks were silently not running.** `validate-provenance.sh` checks 7-8 were dead across nine skills. Waking them exposed a deeper problem: they assume `Research doc:` names a source index, but 30 of 121 entries point at topic content documents, so every new check-7 INFO was a false positive and check 8 was saved from a false-FAIL flood only by an *unannounced* skip. Checks 7/8 are now scoped to source indexes and every skip announces itself (#121). **The retrofit's own anti-goal, four times.** ADR-0020 warns that a blunt gate gets satisfied by deleting content rather than relocating it. `diagnose` and `skill-audit` relocated prose and then read it unconditionally; `prototype` and `vale-config` deleted rules outright that survived nowhere. All four addressed. ## Verification - `bash tests/run-tests.sh --strict` — 24 suites, 0 skipped, 0 failed - `bash tests/run-bats.sh` — 325 tests, 0 failures - `pre-commit run --all-files` — 17/17 - `pre-commit run --hook-stage pre-push --all-files` — 16/16, with `apm marketplace check` and `apm pack --check-clean` run against the remote, not skipped - `scripts/skill-size-check.sh` over all 39 skills — rc 0, 0 ERROR/FAIL, SUGGESTION-only - Preload tax measured at **10,498 chars**, max description 390 — both inside budget - Every new test proven non-vacuous by a deliberate mutation of the behaviour it covers **Per-commit sync, stated accurately:** the ten commits from the latest review round each pass `check-plugin-content-sync` in isolation, verified by checking each out in a detached worktree with a clean between. The earlier gitea window (`dfacf05..bedbd1d`, nine commits) does **not** — its mirror was regenerated in one batch at `bbc7300`. An earlier revision of this description claimed the property held for every commit; it does not, and a bisect through that window lands on a red commit. **Squash-merge** to collapse it, or accept that this range is not bisectable. ## Version bump Six plugins and the catalog take a **patch**, not a minor. The branch is **89 commits — 40 `fix` / 30 `refactor` / 12 `docs` / 5 `chore` / 2 `test` — zero `feat`, zero `!`, zero `BREAKING CHANGE`** — and adds no skill, agent, command or hook. (Two earlier revisions of this section cited a stale histogram, most recently 78 commits; the figures above are measured at HEAD.) Both rules this repo ships (`forge/references/version-bump.md`, landing in this PR, and `git-commits/references/conventional-commits-spec.md`) make that a patch, and the catalog set is unchanged at 7 entries. Not settled by that: four published files were removed from the installed tree, three moved, and `caveman` gained `disable-model-invocation`, retiring its old triggers. Under a strict reading those are major-class and currently ship under `refactor:` with no marker. Whether the deployed skill surface is a public contract is written down nowhere — worth deciding, but it outlives this PR. ## Deliberately not in scope #112 (cherry-pick ownership, now resolved in favour of `git-commits`), #113 (`rtk git` normalisation), #116 (research fan-out), #101 (audit-skill merge), #122 (non-spec skill-root files), #123 (no PRD producer) stay open. #117 is the one worth reading: the contract's remedy is to move prose into `references/`, which is exactly where neither the size gate nor Vale looks — and the blind spot is wider than #117 currently records, since there is no root `.vale.ini` at all, so every ADR, `CONTEXT.md` and `README.md` is unlinted too. That blind spot let this branch carry two `level: error` `Kyberforge.SentenceOpenerThereIs` violations into `references/` files it created — `provider-adapter-author/references/provider-matrix.md:31` and `agent-audit/references/finding-criteria.md:95`. Both are reworded in `afadaae`, confirmed by routing each file through the audit's own `vale-wrap.sh` (1 error each before, 0 after). Five further occurrences sit in `references/` files already on `main`; those are the pre-existing corpus and stay with #117, which is the real fix. Also unfixed and not this PR's: `apm install` appends a duplicate `SessionStart` entry to `.claude/settings.json`, so a fresh clone cannot get pre-push green without an edit AGENTS.md warns against. Reproduces identically on `main`. Co-authored-by: Defame1297 <gitea@rkdr.net> Reviewed-on: https://git.dev.rkdr.net/Defame1297/holocron/pulls/129 Co-authored-by: Claude Code AI - Gitea MCP <claude@noreply.git.dev.rkdr.net> Co-committed-by: Claude Code AI - Gitea MCP <claude@noreply.git.dev.rkdr.net>
This commit was merged in pull request #129.
This commit is contained in:
29
plugins/bin/.apm/skills/caveman/README.md
Normal file
29
plugins/bin/.apm/skills/caveman/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# caveman
|
||||
|
||||
Ultra-compressed output mode: drop articles, filler and pleasantries, keep the technical substance exact.
|
||||
|
||||
## What it does
|
||||
|
||||
Switches the agent into a terse register — no articles, no hedging, no pleasantries, fragments allowed, arrows for causality — while leaving technical terms, code blocks and quoted error strings untouched. The mode is *sticky*: once turned on it stays on for every subsequent response until the user says "stop caveman" or "normal mode", rather than decaying back to normal prose after a few turns.
|
||||
|
||||
It carries one built-in escape hatch. Security warnings, confirmations for irreversible actions, multi-step sequences where fragment order could be misread, and any request to clarify are answered in normal prose, then the compressed register resumes.
|
||||
|
||||
## Hand-invoked only
|
||||
|
||||
`SKILL.md` sets `disable-model-invocation: true`. This is the single most important thing to know about this skill: **the model cannot route to it.** No other skill can hand off to it, and no phrasing in a user's request will cause it to be selected automatically. The only way in is the human typing `/caveman`.
|
||||
|
||||
That is deliberate — output style is the user's choice, not an inference the router should make on their behalf. It is also why the description reads as one plain human-facing sentence rather than carrying the trigger phrasing and boundary clause a routable skill needs.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/caveman
|
||||
```
|
||||
|
||||
Then keep working normally. To leave the mode, say "stop caveman" or "normal mode".
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The whole skill — persistence rule, compression rules, worked examples, and the auto-clarity exception |
|
||||
@@ -1,17 +1,16 @@
|
||||
---
|
||||
name: caveman
|
||||
disable-model-invocation: true
|
||||
description: >
|
||||
Ultra-compressed communication mode. Cuts token usage ~75% by dropping
|
||||
filler, articles, and pleasantries while keeping full technical accuracy.
|
||||
Use when user says "caveman mode", "talk like caveman", "use caveman",
|
||||
"less tokens", "be brief", or invokes /caveman.
|
||||
Ultra-compressed output mode that drops articles, filler and pleasantries while
|
||||
keeping technical substance exact, cutting token usage by roughly 75%.
|
||||
---
|
||||
|
||||
Respond terse like smart caveman. All technical substance stay. Only fluff die.
|
||||
|
||||
## Persistence
|
||||
|
||||
ACTIVE EVERY RESPONSE once triggered. No revert after many turns. No filler drift. Still active if unsure. Off only when user says "stop caveman" or "normal mode".
|
||||
ACTIVE EVERY RESPONSE once user type `/caveman`. No revert after many turns. No filler drift. Still active if unsure. Off only when user says "stop caveman" or "normal mode".
|
||||
|
||||
## Rules
|
||||
|
||||
|
||||
35
plugins/bin/.apm/skills/diagnose/README.md
Normal file
35
plugins/bin/.apm/skills/diagnose/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# diagnose
|
||||
|
||||
A six-phase discipline for hard bugs and performance regressions: feedback loop → reproduce → hypothesise → instrument → fix with a regression test → clean up.
|
||||
|
||||
## What it does
|
||||
|
||||
Imposes an order of operations on debugging so the agent cannot skip to guessing. The load-bearing phase is the first one: build a fast, deterministic, agent-runnable pass/fail signal for the bug. Everything downstream — bisection, hypothesis testing, instrumentation — just consumes that signal, so the skill refuses to advance to Phase 2 without one, and says so explicitly rather than hypothesising blind.
|
||||
|
||||
The remaining phases each carry a constraint worth knowing about: hypotheses are generated 3–5 at a time and must be falsifiable, so the first plausible idea cannot anchor the whole investigation; every debug log is tagged with a unique prefix (`[DEBUG-a4f2]`) so cleanup is a single grep; the regression test is written before the fix and only at a seam that exercises the real bug pattern; and the run closes by asking what would have prevented the bug, handing off to `improve-codebase-architecture` when the answer is architectural.
|
||||
|
||||
Performance regressions take a branch of their own inside Phase 4 — baseline measurement and bisection, not logs.
|
||||
|
||||
## Conditional reading
|
||||
|
||||
Neither reference file is read on every run; `SKILL.md` names the condition for each.
|
||||
|
||||
- `references/feedback-loops.md` is read when Phase 1 has no signal yet, or when the loop you have is slow or intermittent.
|
||||
- `references/regression-seams.md` is read when Phase 5 leaves you unsure whether the available seam is deep enough — or whether one exists at all.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/diagnose
|
||||
```
|
||||
|
||||
Describe the bug or the regression. For filing and triaging a reported bug rather than diagnosing it, use `triage`; for test-first feature work, use `tdd`.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The six phases and their gates — what must be true before each one ends |
|
||||
| `references/feedback-loops.md` | Loaded when Phase 1 has no loop or the loop is too weak: ten ways to construct one ordered by cost, how to sharpen an existing loop, handling intermittent bugs, and what to ask the user for when the bug resists reproduction |
|
||||
| `references/regression-seams.md` | Loaded when Phase 5 is unsure about the seam: what makes a seam correct, the four shapes of a too-shallow seam, and what to do when no correct seam exists |
|
||||
| `assets/hitl-loop.template.sh` | Copy-and-edit bash template for the last-resort human-in-the-loop feedback loop, cited by `references/feedback-loops.md`. Provides `step` and `capture` helpers and prints captured values as `KEY=VALUE` for the agent to parse |
|
||||
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: diagnose
|
||||
description: Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.
|
||||
description: >
|
||||
Use when the user says "diagnose this" or "debug this", reports something
|
||||
broken, throwing, or failing, or says something got slow. Not filing or
|
||||
triaging a reported bug -> `triage`. Not test-first feature work -> `tdd`.
|
||||
---
|
||||
|
||||
# Diagnose
|
||||
@@ -15,40 +18,11 @@ When exploring the codebase, use the project's domain glossary to get a clear me
|
||||
|
||||
Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
|
||||
|
||||
### Ways to construct one — try them in roughly this order
|
||||
**If you do not yet have such a signal, read `references/feedback-loops.md`** — ten ways to build one ordered by cost, and what to ask the user for when the bug resists reproduction entirely.
|
||||
|
||||
1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
|
||||
2. **Curl / HTTP script** against a running dev server.
|
||||
3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
|
||||
4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
|
||||
5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
|
||||
6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
|
||||
7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
|
||||
8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
|
||||
9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
|
||||
10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
|
||||
**If you do have one, it is probably not sharp enough yet.** Make it faster and more deterministic, and make it assert on the exact symptom rather than "didn't crash" — a 30-second flaky loop is barely better than no loop. If it stays slow or intermittent after that, read that file's "Iterate on the loop itself" and "Intermittent bugs" sections.
|
||||
|
||||
Build the right feedback loop, and the bug is 90% fixed.
|
||||
|
||||
### Iterate on the loop itself
|
||||
|
||||
Treat the loop as a product. Once you have _a_ loop, ask:
|
||||
|
||||
- Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
|
||||
- Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
|
||||
- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
|
||||
|
||||
A 30-second flaky loop is barely better than no loop. A 2-second deterministic loop is a debugging superpower.
|
||||
|
||||
### Non-deterministic bugs
|
||||
|
||||
The goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's debuggable.
|
||||
|
||||
### When you genuinely cannot build a loop
|
||||
|
||||
Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) permission to add temporary production instrumentation. Do **not** proceed to hypothesise without a loop.
|
||||
|
||||
Do not proceed to Phase 2 until you have a loop you believe in.
|
||||
Do not proceed to Phase 2 until you have a loop you believe in. If you cannot build one, stop and say so explicitly, listing what you tried — never hypothesise without a signal.
|
||||
|
||||
## Phase 2 — Reproduce
|
||||
|
||||
@@ -57,7 +31,7 @@ Run the loop. Watch the bug appear.
|
||||
Confirm:
|
||||
|
||||
- [ ] The loop produces the failure mode the **user** described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
|
||||
- [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
|
||||
- [ ] The failure is reproducible across multiple runs. If it is intermittent, `references/feedback-loops.md` defines the rate high enough to debug against — go back to Phase 1 and raise it.
|
||||
- [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
|
||||
|
||||
Do not proceed until you reproduce the bug.
|
||||
@@ -90,19 +64,17 @@ Tool preference:
|
||||
|
||||
## Phase 5 — Fix + regression test
|
||||
|
||||
Write the regression test **before the fix** — but only if there is a **correct seam** for it.
|
||||
Write the regression test **before the fix** — but only at a **correct seam**: one where the test exercises the real bug pattern as it occurs at the call site. If the available seam looks too shallow, or you cannot tell whether it is, read `references/regression-seams.md`.
|
||||
|
||||
A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
|
||||
**If no correct seam exists, that itself is the finding.** Note it and carry it into Phase 6 — the architecture is preventing the bug from being locked down.
|
||||
|
||||
**If no correct seam exists, that itself is the finding.** Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
|
||||
At a correct seam:
|
||||
|
||||
If a correct seam exists:
|
||||
|
||||
1. Turn the minimised repro into a failing test at that seam.
|
||||
1. Turn the Phase 1 loop into a failing test at that seam, narrowed to the symptom captured in Phase 2.
|
||||
2. Watch it fail.
|
||||
3. Apply the fix.
|
||||
4. Watch it pass.
|
||||
5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
|
||||
5. Re-run the Phase 1 feedback loop against the original, un-narrowed scenario.
|
||||
|
||||
## Phase 6 — Cleanup + post-mortem
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
# Constructing and sharpening a feedback loop
|
||||
|
||||
A feedback loop is a fast, deterministic, agent-runnable pass/fail signal for the bug. Build the right one and the bug is 90% fixed. This file covers the whole arc: building a loop, sharpening one you already have, and escalating when the bug resists reproduction.
|
||||
|
||||
## Ways to construct one — try them in roughly this order
|
||||
|
||||
1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
|
||||
2. **Curl / HTTP script** against a running dev server.
|
||||
3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
|
||||
4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
|
||||
5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
|
||||
6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
|
||||
7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
|
||||
8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
|
||||
9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
|
||||
10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `assets/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
|
||||
|
||||
## Iterate on the loop itself
|
||||
|
||||
Treat the loop as a product. Once you have _a_ loop, ask:
|
||||
|
||||
- Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
|
||||
- Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
|
||||
- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
|
||||
|
||||
A 30-second flaky loop is barely better than no loop. A 2-second deterministic loop is a debugging superpower.
|
||||
|
||||
## Intermittent bugs — raise the reproduction rate
|
||||
|
||||
If the loop only sometimes fails, the goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's debuggable.
|
||||
|
||||
## When you genuinely cannot build a loop
|
||||
|
||||
Stop and say so explicitly. List what you tried. Ask the user for:
|
||||
|
||||
- access to whatever environment reproduces it,
|
||||
- a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or
|
||||
- permission to add temporary production instrumentation.
|
||||
|
||||
Do **not** proceed to hypothesise without a loop. A hypothesis you cannot falsify against a signal is a guess, and the fix that follows it is unverifiable.
|
||||
@@ -0,0 +1,24 @@
|
||||
# Judging a regression-test seam
|
||||
|
||||
Read this when Phase 5 leaves you unsure whether the seam available for the regression test is the correct one — either because the obvious seam looks shallow, or because there appears to be no seam at all.
|
||||
|
||||
## What makes a seam correct
|
||||
|
||||
A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site: the same entry point, the same participants, the same ordering, and the same state the real caller holds when it goes wrong.
|
||||
|
||||
## Seams that are too shallow
|
||||
|
||||
- A single-caller test when the bug only appears with multiple callers.
|
||||
- A unit test that cannot replicate the chain of calls that triggered the bug.
|
||||
- A test that reproduces the symptom by construction — asserting on a value the test itself set — rather than by driving the code path that produces it.
|
||||
- A test that mocks out the collaborator the bug actually lives in.
|
||||
|
||||
A regression test at a shallow seam gives false confidence. It passes forever, including after a change reintroduces the bug at the real call site, and it will be read by the next maintainer as proof the bug is locked down.
|
||||
|
||||
## When there is no correct seam
|
||||
|
||||
Do not force one, and do not settle for a shallow seam to have something green. Instead:
|
||||
|
||||
1. Apply the fix and verify it against the Phase 1 loop directly.
|
||||
2. Write down which seams you considered and why each was too shallow.
|
||||
3. Carry that into Phase 6's "what would have prevented this bug" question. A missing seam is an architecture finding — tangled callers, hidden coupling, or a module with no testable boundary — and the handoff is the `improve-codebase-architecture` skill, with those specifics attached.
|
||||
27
plugins/bin/.apm/skills/grill-me/README.md
Normal file
27
plugins/bin/.apm/skills/grill-me/README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# grill-me
|
||||
|
||||
Interview the user relentlessly about a plan or design until the decision tree is fully resolved.
|
||||
|
||||
## What it does
|
||||
|
||||
Turns the agent into an interviewer rather than an implementer. It walks the design tree branch by branch, resolving dependencies between decisions one at a time, and offers its own recommended answer alongside each question so the user has something concrete to push against. Two rules give it its shape: **one question at a time**, and **never ask what the codebase can answer** — if a question is settleable by reading the code, the agent goes and reads the code instead of spending the user's attention on it.
|
||||
|
||||
## Composition
|
||||
|
||||
This is the plain grilling loop, with no documentation side effects. The sibling `grill-with-docs` skill runs the same interview but additionally challenges answers against the project's `CONTEXT.md` glossary and existing ADRs, and writes decisions back into those files as they crystallise. Reach for that one when the project has a domain model worth defending; reach for this one when it does not, or when nothing should be written down yet.
|
||||
|
||||
`triage` composes the documented variant, not this one, when an issue needs fleshing out.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/grill-me
|
||||
```
|
||||
|
||||
Describe the plan or design to be stress-tested. Expect questions one at a time, each with a recommended answer.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The whole skill — the interview instruction, the one-question-at-a-time rule, and the explore-instead-of-asking rule |
|
||||
@@ -1,6 +1,10 @@
|
||||
---
|
||||
name: grill-me
|
||||
description: Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
|
||||
description: >
|
||||
Use when the user says "grill me" or wants a plan or design stress-tested by
|
||||
relentless interview — one question at a time, down each branch of the
|
||||
decision tree. Not a plan to challenge against `CONTEXT.md` and ADRs ->
|
||||
`grill-with-docs`.
|
||||
---
|
||||
|
||||
Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
|
||||
|
||||
37
plugins/bin/.apm/skills/grill-with-docs/README.md
Normal file
37
plugins/bin/.apm/skills/grill-with-docs/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# grill-with-docs
|
||||
|
||||
The grilling interview, run against the project's domain model — and writing decisions back into `CONTEXT.md` and ADRs as they land.
|
||||
|
||||
## What it does
|
||||
|
||||
Runs the same relentless one-question-at-a-time interview as `grill-me`, with the project's own documentation as an active participant. During codebase exploration it also locates the domain documentation — a root `CONTEXT.md` and `docs/adr/`, or a `CONTEXT-MAP.md` pointing at per-context glossaries and ADR directories in a multi-context repo — and then uses it five ways:
|
||||
|
||||
- **Challenges terms against the glossary.** When the user's usage conflicts with what `CONTEXT.md` already defines, that is raised immediately rather than absorbed.
|
||||
- **Sharpens fuzzy language** by proposing a precise canonical term ("you're saying 'account' — do you mean the Customer or the User?").
|
||||
- **Stress-tests domain relationships with concrete scenarios**, inventing edge cases that force the user to be precise about where one concept ends and the next begins.
|
||||
- **Cross-references claims against the code**, and surfaces contradictions between what the user says happens and what the code does.
|
||||
- **Updates `CONTEXT.md` inline**, the moment a term is resolved, rather than batching changes to the end of the session where they get lost.
|
||||
|
||||
Files are created lazily — only when there is something real to write.
|
||||
|
||||
ADRs are offered *sparingly*, and only when all three tests pass: the decision is hard to reverse, it would surprise a future reader without the context, and it was a genuine trade-off with real alternatives. Missing any one of the three means no ADR.
|
||||
|
||||
## Composition
|
||||
|
||||
`grill-me` is the same interview without the documentation side effects — use it when there is no domain model to defend or nothing should be written down yet. `triage` composes this skill (not `grill-me`) at step 4 when an issue needs fleshing out. `improve-codebase-architecture` runs its own grilling loop and borrows this skill's `CONTEXT.md` and ADR discipline for the decisions that come out of it.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/grill-with-docs
|
||||
```
|
||||
|
||||
Describe the plan or design. Expect questions one at a time, each with a recommended answer, and expect `CONTEXT.md` to be edited during the session rather than after it.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The interview instruction plus the domain-awareness rules: file layout discovery, the five during-session behaviours, and the three-part ADR test |
|
||||
| `CONTEXT-FORMAT.md` | Skill-root document, cited when a term is resolved: the structure of a `CONTEXT.md` and how to write a Language entry |
|
||||
| `ADR-FORMAT.md` | Skill-root document, cited when an ADR is offered: `docs/adr/` naming, sequential numbering, and the ADR template |
|
||||
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: grill-with-docs
|
||||
description: Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.
|
||||
description: >
|
||||
Use when a plan should be stress-tested against the project's domain model —
|
||||
the interview challenges terms against `CONTEXT.md` and writes decisions into
|
||||
it and into ADRs as they land. Not a plain interview -> `grill-me`.
|
||||
---
|
||||
|
||||
<what-to-do>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# improve-codebase-architecture
|
||||
|
||||
Surface architectural friction and propose deepening opportunities — refactors that turn shallow modules into deep ones.
|
||||
|
||||
## What it does
|
||||
|
||||
Looks for places where a codebase is hard to understand, hard to test, or hard for an agent to navigate, and proposes refactors that concentrate behaviour behind smaller interfaces. It runs in three stages:
|
||||
|
||||
1. **Explore.** Reads the domain glossary and any ADRs in the area first, then walks the codebase with an `Explore` sub-agent — organically, noting friction rather than applying fixed heuristics. The **deletion test** is the filter: imagine deleting the module; if complexity vanishes it was a pass-through, if complexity reappears across N callers it was earning its keep.
|
||||
2. **Present candidates.** A numbered list, each with files, problem, solution and benefits — benefits stated in terms of *locality* and *leverage* and of how tests would improve. No interfaces are proposed yet; the user picks one.
|
||||
3. **Grilling loop.** Walks the design tree for the chosen candidate, with documentation side effects landing inline as decisions crystallise.
|
||||
|
||||
The skill is opinionated about vocabulary, and that is the point: **module, interface, implementation, depth, seam, adapter, leverage, locality**, used exactly, with no drift into "component", "service", "API" or "boundary". Domain nouns come from `CONTEXT.md`, architecture nouns from `LANGUAGE.md` — so a proposal reads as "the Order intake module", never "the FooBarHandler".
|
||||
|
||||
ADRs are treated as decisions not to be re-litigated. A candidate that contradicts one is surfaced only when the friction is real enough to warrant reopening it, and is marked as such.
|
||||
|
||||
## Composition
|
||||
|
||||
`diagnose` hands off here when a bug's post-mortem concludes that no correct test seam exists, or that callers are tangled — the recommendation is made after the fix is in, not before. The grilling loop follows `grill-with-docs`'s discipline for `CONTEXT.md` entries and ADR offers, and `SKILL.md` names that skill's format documents directly.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/improve-codebase-architecture
|
||||
```
|
||||
|
||||
Point at a codebase or an area of one. Expect a numbered candidate list and a "which of these would you like to explore?" before any interface design happens.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | Condensed glossary, key principles, and the three-stage process |
|
||||
| `LANGUAGE.md` | Skill-root document, cited throughout `SKILL.md`: full definitions of every term, the words each one replaces, and the full principle list |
|
||||
| `INTERFACE-DESIGN.md` | Skill-root document, read at stage 3 when the user wants alternative interfaces explored: the parallel sub-agent "Design It Twice" pattern, framing the problem space, and the per-agent design constraints |
|
||||
| `DEEPENING.md` | Skill-root document, cited from `INTERFACE-DESIGN.md`: how to deepen a cluster of shallow modules safely, the four dependency categories (in-process, local-substitutable, remote-but-owned, true external), seam discipline, and the replace-don't-layer testing strategy |
|
||||
@@ -1,6 +1,11 @@
|
||||
---
|
||||
name: improve-codebase-architecture
|
||||
description: Find deepening opportunities in a codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/. Use when the user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more testable and AI-navigable.
|
||||
description: >
|
||||
Use when the user wants to improve architecture, find refactoring
|
||||
opportunities, consolidate tightly-coupled modules, or make a codebase more
|
||||
testable and AI-navigable — deepening opportunities that turn shallow modules
|
||||
into deep ones, informed by `CONTEXT.md` and `docs/adr/`. Not debugging a
|
||||
failure -> `diagnose`.
|
||||
---
|
||||
|
||||
# Improve Codebase Architecture
|
||||
@@ -9,7 +14,7 @@ Surface architectural friction and propose **deepening opportunities** — refac
|
||||
|
||||
## Glossary
|
||||
|
||||
Use these terms exactly in every suggestion. Consistent language is the point — don't drift into "component," "service," "API," or "boundary." Full definitions in [LANGUAGE.md](LANGUAGE.md).
|
||||
Use these terms exactly in every suggestion. Consistent language is the point — don't drift into "component," "service," "API," or "boundary."
|
||||
|
||||
- **Module** — anything with an interface and an implementation (function, class, package, slice).
|
||||
- **Interface** — everything a caller must know to use the module: types, invariants, error modes, ordering, config. Not just the type signature.
|
||||
@@ -20,12 +25,14 @@ Use these terms exactly in every suggestion. Consistent language is the point
|
||||
- **Leverage** — what callers get from depth.
|
||||
- **Locality** — what maintainers get from depth: change, bugs, knowledge concentrated in one place.
|
||||
|
||||
Key principles (see [LANGUAGE.md](LANGUAGE.md) for the full list):
|
||||
Key principles:
|
||||
|
||||
- **Deletion test**: imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
|
||||
- **The interface is the test surface.**
|
||||
- **One adapter = hypothetical seam. Two adapters = real seam.**
|
||||
|
||||
If a term or principle above is ambiguous in the case in front of you, or you need the definitions and the principles the two lists leave out, read `LANGUAGE.md`.
|
||||
|
||||
This skill is _informed_ by the project's domain model. The domain language gives names to good seams; ADRs record decisions the skill should not re-litigate.
|
||||
|
||||
## Process
|
||||
@@ -53,7 +60,7 @@ Present a numbered list of deepening opportunities. For each candidate:
|
||||
- **Solution** — plain English description of what would change
|
||||
- **Benefits** — explained in terms of locality and leverage, and also in how tests would improve
|
||||
|
||||
**Use CONTEXT.md vocabulary for the domain, and [LANGUAGE.md](LANGUAGE.md) vocabulary for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
|
||||
**Use CONTEXT.md vocabulary for the domain, and the architecture glossary above for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
|
||||
|
||||
**ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly (e.g. _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
|
||||
|
||||
@@ -65,7 +72,7 @@ Once the user picks a candidate, drop into a grilling conversation. Walk the des
|
||||
|
||||
Side effects happen inline as decisions crystallize:
|
||||
|
||||
- **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md` — same discipline as `/grill-with-docs` (see [CONTEXT-FORMAT.md](../grill-with-docs/CONTEXT-FORMAT.md)). Create the file lazily if it doesn't exist.
|
||||
- **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md` — same discipline as `grill-with-docs`, in the format `grill-with-docs`'s `CONTEXT-FORMAT.md` defines. Create the file lazily if it doesn't exist.
|
||||
- **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
|
||||
- **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones. See [ADR-FORMAT.md](../grill-with-docs/ADR-FORMAT.md).
|
||||
- **Want to explore alternative interfaces for the deepened module?** See [INTERFACE-DESIGN.md](INTERFACE-DESIGN.md).
|
||||
- **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones. See `grill-with-docs`'s `ADR-FORMAT.md`.
|
||||
- **Want to explore alternative interfaces for the deepened module?** Read `INTERFACE-DESIGN.md`.
|
||||
|
||||
32
plugins/bin/.apm/skills/prototype/README.md
Normal file
32
plugins/bin/.apm/skills/prototype/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# prototype
|
||||
|
||||
Build a throwaway prototype that answers one design question — either a runnable terminal app or several UI variations.
|
||||
|
||||
## What it does
|
||||
|
||||
Treats a prototype as **throwaway code that answers a question**, and lets the question decide the artifact. `SKILL.md` opens with a two-row dispatch table and the run resolves exactly one row before doing anything else:
|
||||
|
||||
- *"Does this logic / state model feel right?"* → a tiny interactive terminal app that pushes the state machine through the cases that are hard to reason about on paper.
|
||||
- *"What should this look like?"* → several radically different UI variations on one route, switchable from a floating bottom bar via a URL search param.
|
||||
|
||||
The two branches produce fundamentally different artifacts, so picking wrong wastes the whole prototype. When the question is genuinely ambiguous and the user is unreachable, the skill defaults on the shape of the surrounding code (backend module → logic, page or component → UI) and states the assumption at the top of the prototype rather than silently choosing.
|
||||
|
||||
Six rules apply to both branches: throwaway and visibly named as such, one command to run, no persistence by default, no polish, surface the full state after every action or variant switch, and delete or absorb the prototype when it is done. The *answer* is the only durable output — the skill captures it in a commit message, ADR, issue or `NOTES.md` before the code is deleted.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/prototype
|
||||
```
|
||||
|
||||
State the design question. For production code, use `tdd`; for talking a design through without building anything, use `grill-me`.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The branch dispatch table and the rules that apply to both branches |
|
||||
| `references/logic.md` | The logic branch, read only when that row is selected: when it is the right shape, and how to build the interactive terminal app |
|
||||
| `references/ui.md` | The UI branch, read only when that row is selected: when it is the right shape, and how to build and switch between the variations |
|
||||
|
||||
Each reference is self-contained — a run reads one of the two, never both.
|
||||
@@ -1,6 +1,10 @@
|
||||
---
|
||||
name: prototype
|
||||
description: Build a throwaway prototype to flush out a design before committing to it. Routes between two branches — a runnable terminal app for state/business-logic questions, or several radically different UI variations toggleable from one route. Use when the user wants to prototype, sanity-check a data model or state machine, mock up a UI, explore design options, or says "prototype this", "let me play with it", "try a few designs".
|
||||
description: >
|
||||
Use when the user wants a throwaway prototype to answer a design question about
|
||||
a data model, state machine or business logic, or to mock up a UI in several
|
||||
variations. Not production code -> `tdd`. Not talking a design through ->
|
||||
`grill-me`.
|
||||
---
|
||||
|
||||
# Prototype
|
||||
@@ -9,10 +13,12 @@ A prototype is **throwaway code that answers a question**. The question decides
|
||||
|
||||
## Pick a branch
|
||||
|
||||
Identify which question is being answered — from the user's prompt, the surrounding code, or by asking if the user is around:
|
||||
| Question being answered | Build | Reference |
|
||||
|---|---|---|
|
||||
| "Does this logic / state model feel right?" | A tiny interactive terminal app that pushes the state machine through cases that are hard to reason about on paper | `references/logic.md` |
|
||||
| "What should this look like?" | Several radically different UI variations on one route, switchable via a URL search param and a floating bottom bar | `references/ui.md` |
|
||||
|
||||
- **"Does this logic / state model feel right?"** → [LOGIC.md](LOGIC.md). Build a tiny interactive terminal app that pushes the state machine through cases that are hard to reason about on paper.
|
||||
- **"What should this look like?"** → [UI.md](UI.md). Generate several radically different UI variations on a single route, switchable via a URL search param and a floating bottom bar.
|
||||
Resolve the row from the user's prompt, the surrounding code, or by asking if the user is around, then read only that reference — each is self-contained.
|
||||
|
||||
The two branches produce fundamentally different artifacts — getting this wrong wastes the whole prototype. If the question is genuinely ambiguous and the user isn't reachable, default to whichever branch better matches the surrounding code (a backend module → logic; a page or component → UI) and state the assumption at the top of the prototype.
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ A tiny interactive terminal app that lets the user drive a state model by hand.
|
||||
- "I want to feel out what the API should look like before writing it."
|
||||
- Anything where the user wants to **press buttons and watch state change**.
|
||||
|
||||
If the question is "what should this look like" — wrong branch. Use [UI.md](UI.md).
|
||||
If the question is "what should this look like" — wrong branch. Read `references/ui.md`.
|
||||
|
||||
## Process
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Generate **several radically different UI variations** on a single route, switchable from a floating bottom bar. The user flips between variants in the browser, picks one (or steals bits from each), then throws the rest away.
|
||||
|
||||
If the question is about logic/state rather than what something looks like — wrong branch. Use [LOGIC.md](LOGIC.md).
|
||||
If the question is about logic/state rather than what something looks like — wrong branch. Read `references/logic.md`.
|
||||
|
||||
## When this is the right shape
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
```yaml
|
||||
version: "1.1"
|
||||
updated: 2026-06-21
|
||||
|
||||
when: >-
|
||||
Invoked when the user wants to gather structured reference documentation for a
|
||||
tool, library, or API from MCP documentation indexes or web sources. Typically
|
||||
run before writing a new skill that wraps an external tool, or any time
|
||||
reference files are needed for a topic. Triggered explicitly
|
||||
("/research <topic> <path>") or implicitly when the user asks to look up,
|
||||
gather, or pull docs for a topic before implementing something.
|
||||
|
||||
references:
|
||||
- .agents/skills/context7-mcp/SKILL.md # context7-mcp — MCP source channel integrated at step 2
|
||||
```
|
||||
31
plugins/bin/.apm/skills/research/README.md
Normal file
31
plugins/bin/.apm/skills/research/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# research
|
||||
|
||||
Research a tool, library or API from canonical documentation into a directory of structured per-topic reference files.
|
||||
|
||||
## What it does
|
||||
|
||||
Runs a six-step pipeline: scope against the working directory (what version is actually in use, what is already documented), resolve the topic through Context7, websearch for canonical docs covering whatever Context7 missed, read those sources, deepen one level into the links worth following, then write one markdown file per topic area plus a `sources.md` provenance record.
|
||||
|
||||
Four gotchas at the top of `SKILL.md` shape the whole run, and each exists because of a specific failure: the output path is never inferred (a guessed destination scatters a directory's worth of files through someone's source tree); nothing is written outside that path; no empty topic file is ever written (a stub `troubleshooting.md` reads downstream as researched and closed); and a Context7 "no results", redirect or header-only response does not count as coverage. If no topic area has content, the run writes nothing at all — `sources.md` included — and reports what it searched.
|
||||
|
||||
The frontmatter pins `model: sonnet` and a closed `allowed-tools` list. Notably it grants no subagent tool, so every `WebFetch` is serial and each fetched page lands in the run's own context — which is why steps 4 and 5 insist on reducing each page to notes before fetching the next, and cap deepening at roughly ten extra pages.
|
||||
|
||||
## Composition
|
||||
|
||||
Both reference files are read on condition, never on every run — `SKILL.md` inlines the minimum each step needs (the seven default topic areas at step 1, the four `sources.md` field names and the topic-file frontmatter keys at step 6) and sends the run to the reference only for what it does not carry. Those four field names are matched literally by the downstream provenance validator, so prose written in their place parses as nothing and the check passes having verified nothing — which is why they are inlined rather than deferred.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/research
|
||||
```
|
||||
|
||||
Name the topic and the output path — the skill will stop and ask if the path is missing. Supplying starting URLs is treated as a deliberate source choice and skips Context7 resolution and discovery. For documentation derived from existing code or specs, use `write-docs`; for a bug or incident, use `diagnose`.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The four gotchas and the six research steps |
|
||||
| `references/topics.md` | Read at Step 1 only when what belongs in a default topic is unclear or a custom topic is needed: the per-topic coverage table and the custom-topic naming rule |
|
||||
| `references/file-format.md` | Read at Step 6 only when the inlined field names do not settle the case: slug derivation, the Context7 slug and URL convention, and what belongs in a topic body |
|
||||
@@ -1,97 +1,78 @@
|
||||
---
|
||||
name: research
|
||||
description: >-
|
||||
Use when the user wants to research a topic and generate structured reference
|
||||
markdown files. Handles: finding canonical docs for a tool/library/API via
|
||||
Context7 MCP or web sources, reading and deepening into linked pages,
|
||||
organizing extracted content into topic files (overview, installation,
|
||||
configuration, cli-reference, api-reference, examples, troubleshooting). Do
|
||||
NOT use when the user wants to write documentation from existing code or specs
|
||||
(use write-docs), install or manage the neuledge-context MCP server (use
|
||||
neuledge-context), or research a bug/incident (use diagnose).
|
||||
Use when the user wants a tool, library, or API researched from canonical
|
||||
documentation into structured per-topic reference markdown files. Not
|
||||
documentation written from existing code or specs -> `write-docs`. Not a bug
|
||||
or incident -> `diagnose`.
|
||||
metadata:
|
||||
category: research
|
||||
allowed-tools:
|
||||
- WebSearch
|
||||
- WebFetch
|
||||
- Grep
|
||||
- Glob
|
||||
- Read
|
||||
- Write
|
||||
- WebSearch
|
||||
- WebFetch
|
||||
- mcp__context7__resolve-library-id
|
||||
- mcp__context7__query-docs
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
<requirements>
|
||||
## Gotchas
|
||||
|
||||
## Required inputs
|
||||
- Never infer the output path. A run writes a directory's worth of files, and a guessed destination scatters them through someone's source tree. If the user named no path, stop and ask.
|
||||
- Write nothing outside the given output path. A file placed beside the agreed directory is one the user never asked for and will not think to look for.
|
||||
- Never write an empty topic file. A stub `troubleshooting.md` reads downstream as researched and closed.
|
||||
- A Context7 response that is a "no results" message, a redirect notice, or header-only boilerplate is not coverage. A topic area counts as covered only when the response carries at least one substantive paragraph.
|
||||
|
||||
- **Topic** — the subject to research (tool, library, API, concept); inferred from user description if clear, ask if ambiguous
|
||||
- **Output path** — directory where reference files will be written; must be provided explicitly — do not infer or default
|
||||
- **Starting URLs** — optional; if provided, skip discovery websearch and read these first
|
||||
## Step 1 — Scope against the working directory
|
||||
|
||||
## Constraints
|
||||
Search for existing use of the topic — imports, config files, version pins, reference files already written — and narrow the research to what is missing: the version actually in use, the topics not yet documented.
|
||||
|
||||
- Never write files outside the explicitly provided output path
|
||||
- Skip any default topic file if no relevant content is found for it — do not create empty files
|
||||
- Create additional topic files beyond the default list when content warrants it (e.g. `webhooks.md`, `rate-limits.md`)
|
||||
- Subagents handle parallel source reading and link deepening — the orchestrator writes all files; subagents return summaries only, never write directly
|
||||
- Context7 MCP calls (`resolve-library-id`, `query-docs`) are made only by the orchestrator at step 2 — subagents must not call them
|
||||
- `sources.md` is always written, even if only one source was read
|
||||
- Each topic file must have frontmatter with `topic` and `source_keys`; body is prose only — no inline URLs
|
||||
- Source keys in `sources.md` must be kebab-case slugs: derived from the source domain or page title for web sources; for Context7 sources use `context7-<library-slug>` (e.g. `context7-vercel-next-js`)
|
||||
- Default topic list and file format spec live in `references/` sub-files — read them at step 1
|
||||
The default topic areas are `overview`, `installation`, `configuration`, `cli-reference`,
|
||||
`api-reference`, `examples` and `troubleshooting` — one file each, and only where content exists.
|
||||
If what belongs in one of them is unclear, or the topic needs a file outside that set, read
|
||||
`references/topics.md` for the per-topic coverage table and the custom-topic naming rule.
|
||||
|
||||
</requirements>
|
||||
## Step 2 — Resolve against Context7
|
||||
|
||||
<steps>
|
||||
If the topic is a library, framework, or API and the user gave no starting URLs, call `resolve-library-id` with the topic name and the user's full question — match quality depends on the question, not the bare name — then `query-docs` once per default topic area. Record each response as a source with slug `context7-<library-slug>`, and mark which topic areas it covered — those skip the web reads at step 4.
|
||||
|
||||
## Process
|
||||
If the library does not resolve, or the user gave starting URLs, go to step 3. Explicit URLs are a source choice; do not second-guess them with a resolution attempt.
|
||||
|
||||
1. **Scan codebase.** Search the working directory for existing usage of the topic — imports, config files, version pins, existing reference files. Use findings to narrow research scope (e.g. target the version already in use, skip topics already documented). Read `references/topics.md` for the default topic list and `references/file-format.md` for the output file format spec.
|
||||
## Step 3 — Discover sources
|
||||
|
||||
2. **Try Context7.** If the topic is a library, framework, or API and no starting URLs were provided, call `resolve-library-id` with the topic name and the user's question. If a match resolves, call `query-docs` once per default topic area (see `references/topics.md`). Treat each response as a source summary with slug `context7-<library-slug>` (e.g. `context7-vercel-next-js`). A topic area has sufficient content when the Context7 response contains at least one substantive paragraph — not a "no results" message, redirect notice, or header-only boilerplate. Mark covered topic areas — skip their subagent web reads in step 4. If the library does not resolve, or starting URLs were provided (explicit source choice by the user), skip this step entirely.
|
||||
If the user gave starting URLs, skip discovery: those URLs are the source list and go straight to step 4.
|
||||
|
||||
3. **Discover sources.** For topics not covered by Context7 (or when no starting URLs were provided and Context7 did not resolve), websearch for canonical documentation (prefer `llms.txt`, developer docs, official API references over tutorials or blog posts). Collect 3–5 candidate URLs before reading any.
|
||||
Otherwise, for every topic area Context7 did not cover, websearch for canonical documentation — `llms.txt`, official developer docs, and API references ahead of tutorials or blog posts. Collect three to five candidate URLs before reading any of them.
|
||||
|
||||
4. **Read sources in parallel.** Spawn one subagent per source URL. Each subagent fetches the page, extracts relevant content, identifies links worth deepening, and returns a structured summary (content by topic area + links to follow). Subagents do not write files.
|
||||
If nothing usable comes back, stop and report what was searched, then ask for starting URLs rather than settling for tutorials.
|
||||
|
||||
5. **Deepen.** For each subagent that returned links worth following, spawn child subagents per branch. Continue until content becomes repetitive or out of scope. Cap at ~10 additional pages total across all branches.
|
||||
## Step 4 — Read the sources
|
||||
|
||||
6. **Consolidate.** Merge all subagent summaries (Context7 and web) by topic area. Identify which default topics have sufficient content and which custom topics emerged.
|
||||
`WebFetch` each URL in turn. No subagent tool is granted here, so the reads are serial and every fetched page lands in this context: reduce each page to notes by topic area, plus the links worth deepening, before fetching the next one.
|
||||
|
||||
7. **Write topic files.** For each topic with content, write `<output-path>/<topic>.md` using the format in `references/file-format.md`. Orchestrator writes all files — never delegate file writing to a subagent.
|
||||
## Step 5 — Deepen
|
||||
|
||||
8. **Write `sources.md`.** Write `<output-path>/sources.md` mapping each source slug to its URL (use `context7:<library-id>` as the URL for Context7 sources), description, and list of topic files it contributed to. Include sources that yielded no content, marked `no content extracted`.
|
||||
`WebFetch` the links worth following, still one at a time and still reducing each page to notes. Stop a branch once its content turns repetitive or leaves the topic, and cap the whole step at roughly ten additional pages — serial reads make that cap a real budget, not a formality.
|
||||
|
||||
## Output format
|
||||
## Step 6 — Write
|
||||
|
||||
- `<output-path>/<topic>.md` per topic with content — formatted per `references/file-format.md`
|
||||
- `<output-path>/sources.md` — always produced; maps slug → URL, description, contributing files
|
||||
Merge every set of notes, Context7 and web alike, by topic area, then write, in the output path:
|
||||
|
||||
</steps>
|
||||
- `<topic>.md` for each topic area that has content, default or custom. Frontmatter carries `topic:` (the filename without `.md`) and `source_keys:` (kebab-case slugs matching `sources.md`); the body is prose in `##` sections, with no inline URLs.
|
||||
- `sources.md`, always, one `##` section per source — including sources that yielded nothing — with exactly these four fields:
|
||||
|
||||
<checks>
|
||||
```markdown
|
||||
- **URL:** <full URL>
|
||||
- **Description:** <one-line summary>
|
||||
- **Contributing files:** <topic files this source contributed to>
|
||||
- **Status:** `extracted` | `no content extracted`
|
||||
```
|
||||
|
||||
## Failure handling
|
||||
Spell those four field names exactly as given. The downstream provenance validator matches them literally; prose in their place parses as nothing, and the check passes having verified nothing.
|
||||
|
||||
- Output path not provided — stop and ask; do not infer or default
|
||||
- No sources found after websearch — report what was searched, ask user to provide starting URLs
|
||||
- Subagent returns no usable content — skip that source, log in `sources.md` as `no content extracted`
|
||||
- All topic files would be empty — stop, report what was searched, do not write any files
|
||||
Read `references/file-format.md` when the four fields above do not settle the case: what a slug should be, the `context7-<library-slug>` slug and `context7:<library-id>` URL convention for a Context7 source, or what belongs in a topic body versus a verbatim copy of the source.
|
||||
|
||||
## Self-check
|
||||
|
||||
- [ ] Codebase scanned before any websearch was performed
|
||||
- [ ] Output path was explicitly provided — not inferred
|
||||
- [ ] `references/topics.md` and `references/file-format.md` read at step 1
|
||||
- [ ] Context7 resolution attempted before websearch when topic is a library/framework/API
|
||||
- [ ] Context7 calls made only at orchestrator step 2 — no subagent called `resolve-library-id` or `query-docs`
|
||||
- [ ] Context7 sources recorded in `sources.md` with `context7:<library-id>` as URL
|
||||
- [ ] No topic file written without content
|
||||
- [ ] `sources.md` written with all sources read (including those with no content extracted)
|
||||
- [ ] All file writes performed by the orchestrator, not subagents
|
||||
- [ ] Each topic file has `topic` and `source_keys` frontmatter fields
|
||||
- [ ] All source keys in topic files have a matching entry in `sources.md`
|
||||
- [ ] No files written outside the provided output path
|
||||
|
||||
</checks>
|
||||
If no topic area has content, write nothing at all, `sources.md` included, and report what was searched.
|
||||
|
||||
32
plugins/bin/.apm/skills/tdd/README.md
Normal file
32
plugins/bin/.apm/skills/tdd/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# tdd
|
||||
|
||||
Test-driven development as a strict red-green-refactor loop, one behaviour at a time.
|
||||
|
||||
## What it does
|
||||
|
||||
Two convictions drive this skill. The first is about what a test is for: tests verify behaviour through public interfaces, not implementation details. A good test reads like a specification ("user can checkout with valid cart") and survives refactors because it does not care about internal structure. The warning sign for a bad one is precise — the test breaks when you refactor but behaviour has not changed.
|
||||
|
||||
The second is an explicit anti-pattern: **do not write all the tests first, then all the implementation.** Horizontal slicing treats RED as "write every test" and GREEN as "write every implementation", and it produces tests of *imagined* behaviour — tests of the shape of things, insensitive to real change, committed to before the implementation was understood. The correct shape is vertical: one test → one implementation → repeat, each cycle informed by what the last one taught you.
|
||||
|
||||
The workflow is four stages: plan (confirm the interface and which behaviours matter, with the user — you cannot test everything), fire a tracer bullet (one test proving the path works end to end), loop incrementally one behaviour at a time, then refactor once everything is green. Refactoring while RED is forbidden.
|
||||
|
||||
Codebase exploration uses the project's domain glossary, so test names and interface vocabulary match the project's language, and ADRs in the area are respected.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/tdd
|
||||
```
|
||||
|
||||
Describe the feature or bug. Expect the skill to ask what the public interface should look like and which behaviours matter most before any code is written. For diagnosing an existing bug rather than building test-first, use `diagnose`; for throwaway exploratory code, use `prototype`.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | Philosophy, the horizontal-slicing anti-pattern, the four-stage workflow, and the per-cycle checklist |
|
||||
| `tests.md` | Skill-root document, cited from Philosophy: worked good and bad test examples |
|
||||
| `mocking.md` | Skill-root document, cited from Philosophy: mock at system boundaries only, and what not to mock |
|
||||
| `deep-modules.md` | Skill-root document, cited from stage 1: what a deep module is (small interface, large implementation) and why it is the design to aim for |
|
||||
| `interface-design.md` | Skill-root document, cited from stage 1: designing interfaces for testability, starting with accepting dependencies rather than creating them |
|
||||
| `refactoring.md` | Skill-root document, cited from stage 4: the refactor-candidate checklist — duplication, long methods, shallow modules, feature envy, primitive obsession |
|
||||
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: tdd
|
||||
description: Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
|
||||
description: >
|
||||
Use when the user wants a feature built or a bug fixed test-first, in a strict
|
||||
red-green-refactor loop, one behaviour at a time. Not diagnosing an existing
|
||||
bug -> `diagnose`. Not throwaway exploratory code -> `prototype`.
|
||||
---
|
||||
|
||||
# Test-Driven Development
|
||||
@@ -13,7 +16,7 @@ description: Test-driven development with red-green-refactor loop. Use when user
|
||||
|
||||
**Bad tests** are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.
|
||||
|
||||
See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
|
||||
If you need worked examples of the difference — a behaviour-level test beside the implementation-coupled version of the same check — read `tests.md`. If a test needs a collaborator faked, read `mocking.md` before reaching for a mock.
|
||||
|
||||
## Anti-Pattern: Horizontal Slices
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Writing Agent Briefs
|
||||
|
||||
An agent brief is a structured comment posted on a GitHub issue when it moves to `ready-for-agent`. It is the authoritative specification that an AFK agent will work from. The original issue body and discussion are context — the agent brief is the contract.
|
||||
An agent brief is a structured comment posted on an issue in the issue tracker when it moves to `ready-for-agent`. It is the authoritative specification that an AFK agent will work from. The original issue body and discussion are context — the agent brief is the contract.
|
||||
|
||||
## Principles
|
||||
|
||||
@@ -27,7 +27,7 @@ Describe **what** the system should do, not **how** to implement it. The agent w
|
||||
|
||||
The agent needs to know when it's done. Every agent brief must have concrete, testable acceptance criteria. Each criterion should be independently verifiable.
|
||||
|
||||
- **Good:** "Running `gh issue list --label needs-triage` returns issues that have been through initial classification"
|
||||
- **Good:** "Querying the issue tracker for the `needs-triage` label returns issues that have been through initial classification"
|
||||
- **Bad:** "Triage should work correctly"
|
||||
|
||||
### Explicit scope boundaries
|
||||
|
||||
35
plugins/bin/.apm/skills/triage/README.md
Normal file
35
plugins/bin/.apm/skills/triage/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# triage
|
||||
|
||||
Move issues on the project issue tracker through a small state machine of triage roles.
|
||||
|
||||
## What it does
|
||||
|
||||
Gives issue triage an explicit state model and a fixed set of moves. Every issue carries exactly one **category** role (`bug`, `enhancement`) and one **state** role (`needs-triage`, `needs-info`, `ready-for-agent`, `ready-for-human`, `wontfix`); conflicting state roles are flagged to the maintainer before anything else happens. Unlabeled issues normally enter at `needs-triage`; `needs-info` returns there once the reporter replies. The maintainer can override at any point, and unusual transitions are questioned rather than executed silently.
|
||||
|
||||
A run does one of three things depending on what the maintainer asks for:
|
||||
|
||||
- **Show what needs attention** — three buckets, oldest first: unlabeled, `needs-triage`, and `needs-info` with reporter activity since the last triage notes.
|
||||
- **Triage a specific issue** — gather context (including prior triage notes, so resolved questions are not re-asked, and `.out-of-scope/` records that resemble the issue), recommend a category and state with reasoning, attempt reproduction for bugs *before* any grilling, run a `grill-with-docs` session if the issue needs fleshing out, then apply the outcome.
|
||||
- **Quick state override** — "move #42 to ready-for-agent" is trusted and applied directly, skipping grilling, after confirming the exact changes.
|
||||
|
||||
Two hard rules: every comment or issue the skill posts during triage must open with the AI-generated disclaimer, and the canonical role names above are *not* necessarily the label strings in the tracker — each is resolved against the tracker's live label set before it is applied, and a name with no counterpart there is reported to the maintainer as a gap rather than guessed at.
|
||||
|
||||
## Composition
|
||||
|
||||
`grill-with-docs` is invoked at step 4 when an issue needs fleshing out; whatever that session establishes is carried into the triage notes so the work is not lost. The reverse direction also exists: `diagnose` names this skill as the place to send a *reported* bug that needs filing rather than debugging.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/triage
|
||||
```
|
||||
|
||||
Then describe what you want in natural language — "show me anything that needs my attention", "let's look at #42", "move #42 to ready-for-agent", "what's ready for agents to pick up?".
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The roles and state machine, the three invocation modes, the needs-info template, and how to resume a prior session |
|
||||
| `AGENT-BRIEF.md` | Skill-root document, cited when an issue moves to `ready-for-agent` (and reused for `ready-for-human`): how to write a brief that stays durable for weeks while the codebase moves under it — describe interfaces and behavioural contracts, not line numbers |
|
||||
| `OUT-OF-SCOPE.md` | Skill-root document, cited when an enhancement is closed `wontfix` and when checking for prior rejections: how the `.out-of-scope/` knowledge base is laid out and what it is for — institutional memory, and deduplication against re-litigated requests |
|
||||
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: triage
|
||||
description: Triage issues through a state machine driven by triage roles. Use when user wants to create an issue, triage issues, review incoming bugs or feature requests, prepare issues for an AFK agent, or manage issue workflow.
|
||||
description: >
|
||||
Use when the user wants an issue created, triaged, or moved through the
|
||||
tracker's triage states, or an issue prepared for an AFK agent. Not debugging
|
||||
the bug itself -> `diagnose`. Not fleshing out a design -> `grill-with-docs`.
|
||||
---
|
||||
|
||||
# Triage
|
||||
@@ -35,7 +38,7 @@ Five **state** roles:
|
||||
|
||||
Every triaged issue should carry exactly one category role and one state role. If state roles conflict, flag it and ask the maintainer before doing anything else.
|
||||
|
||||
These are canonical role names — the actual label strings used in the issue tracker may differ. The mapping should have been provided to you - run `/setup-matt-pocock-skills` if not.
|
||||
These are canonical role names — the actual label strings used in the issue tracker may differ. Resolve each canonical name against the tracker's live label set before applying it, using whichever tracker skill this install provides. If a name has no counterpart there, report the gap and ask the maintainer for the mapping — never substitute a guess.
|
||||
|
||||
State transitions: an unlabeled issue normally goes to `needs-triage` first; from there it moves to `needs-info`, `ready-for-agent`, `ready-for-human`, or `wontfix`. `needs-info` returns to `needs-triage` once the reporter replies. The maintainer can override at any time — flag transitions that look unusual and ask before proceeding.
|
||||
|
||||
|
||||
30
plugins/bin/.apm/skills/write-docs/README.md
Normal file
30
plugins/bin/.apm/skills/write-docs/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# write-docs
|
||||
|
||||
Produce technical documentation derived from code and spec, one section at a time, with a confirmation gate on every section.
|
||||
|
||||
## What it does
|
||||
|
||||
Casts the agent as a technical writer with one non-negotiable constraint: **every claim must be traceable to a source file line, a spec section, or an explicit user statement.** Nothing is invented, and behaviour that genuinely cannot be documented from the available sources is marked out-of-scope rather than explained away.
|
||||
|
||||
The process is eight steps — identify scope, read and extract, gap check, draft section by section, confirmation gate, delta summary, reader testing, finalise — and several of them are deliberately gated on the human:
|
||||
|
||||
- Files are read only after the user approves them by name. The skill may propose candidates; it waits.
|
||||
- The **gap check** presents what the code does say and asks the user to fill only what it does not: caller intent, error-handling rationale, non-obvious side effects.
|
||||
- No section is finalised until the full revised text has been shown. The skill never gates on output the user has not seen, and never reprints the whole document — all edits are surgical.
|
||||
- **Reader testing** predicts 5–10 questions a target reader would ask, then spawns a sub-agent that receives only the finished doc and the questions — no source files. If the doc cannot answer them, neither can the sub-agent, and the run loops back to drafting.
|
||||
|
||||
Summary and overview sections are written last, once the detail sections are stable.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/write-docs
|
||||
```
|
||||
|
||||
Name the files or modules to document, the target audience (developer / user / contributor / internal), and the documentation type (reference, guide, README section, inline comment, changelog entry). For a PRD, ADR or decision doc, use `grill-me` or `grill-with-docs` instead — those have dedicated handling.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The whole skill — role, use/do-not-use boundaries, required inputs, constraints, the eight-step process, output format, failure handling, and a nine-item self-check |
|
||||
@@ -1,6 +1,11 @@
|
||||
---
|
||||
name: write-docs
|
||||
description: Write documentation for X, document this module, create docs for this feature. Use when the user wants to produce or update technical documentation derived from code, spec, or existing artifacts. Do NOT use when the user wants a PRD, ADR, decision doc, or skill file — those have dedicated skills.
|
||||
description: >
|
||||
Use when the user wants technical documentation produced or updated from code
|
||||
or spec, every claim traced to a source — "write docs for X", "document this
|
||||
module", "create docs for this feature", "write a README for this". Not an ADR
|
||||
or other decision record -> `grill-with-docs`. Not an external tool researched
|
||||
from its docs -> `research`.
|
||||
version: "1.0"
|
||||
updated: 2026-05-17
|
||||
when: invoked by explicit trigger ("write docs for X", "document this module", "create docs for this feature") or implicit request to produce technical documentation from code or spec
|
||||
@@ -35,7 +40,8 @@ You are a technical writer that produces documentation by reading code and spec
|
||||
- User says "write docs for X", "document this", "create docs for this feature", "write a README for this"
|
||||
|
||||
**Do not use when:**
|
||||
- User wants a PRD, decision doc, or architecture proposal → `to-prd` or `grill-me`
|
||||
- User wants an ADR, decision doc, or architecture proposal → `grill-with-docs`, which writes ADRs
|
||||
- User wants a PRD → no skill in this set produces one; say so rather than redirecting
|
||||
- User wants to document a skill file (skill files are self-describing)
|
||||
- User wants marketing or blog copy
|
||||
- Documentation requires tacit organisational knowledge that cannot be read from code or spec
|
||||
@@ -88,7 +94,7 @@ You are a technical writer that produces documentation by reading code and spec
|
||||
- Stage skipped without a logged reason → flag and require the one-sentence log before continuing
|
||||
- Code behaviour is undocumentable (internal implementation detail, no public spec) → note as out-of-scope in the doc; do not invent an explanation
|
||||
- Reader Testing sub-agent fails on multiple questions → surface the failures, return to step 4; do not mark complete
|
||||
- Requested output is a PRD, decision doc, or architecture proposal → redirect to `to-prd`, `grill-me`, or `grill-with-docs`
|
||||
- Requested output is an ADR, decision doc, or architecture proposal → redirect to `grill-with-docs`; for a PRD, say no skill here produces one instead of redirecting
|
||||
|
||||
## Self-check
|
||||
|
||||
|
||||
25
plugins/bin/.apm/skills/zoom-out/README.md
Normal file
25
plugins/bin/.apm/skills/zoom-out/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# zoom-out
|
||||
|
||||
Ask the agent to go up a layer of abstraction and map the modules and callers around unfamiliar code.
|
||||
|
||||
## What it does
|
||||
|
||||
A single-purpose prompt for the moment you land in a part of the codebase you do not know. Instead of answering at the level of the file in front of it, the agent climbs one layer and produces a map of the relevant modules and their callers — and names them using the project's own domain glossary vocabulary, so the map lines up with the language the rest of the repo already uses.
|
||||
|
||||
## Hand-invoked only
|
||||
|
||||
`SKILL.md` sets `disable-model-invocation: true`, so the router never selects this skill on its own and no other skill can hand off to it. It runs when the human asks for it. That also means its description is written as one plain human-facing sentence — it carries no trigger phrasing or boundary clause, because nothing routes on it.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/zoom-out
|
||||
```
|
||||
|
||||
Best used with the unfamiliar code already in context — the skill widens the view around what you are looking at rather than picking a starting point for you.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The whole skill — a single instruction, no supporting files |
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bin",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.6",
|
||||
"description": "Skills for everyday AI-assisted development work that is not tied to a single tool, forge or language, and has not yet been split into a focused plugin.",
|
||||
"author": {
|
||||
"name": "Defame1297",
|
||||
|
||||
2
plugins/bin/.github/plugin/plugin.json
vendored
2
plugins/bin/.github/plugin/plugin.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bin",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.6",
|
||||
"description": "Skills for everyday AI-assisted development work that is not tied to a single tool, forge or language, and has not yet been split into a focused plugin.",
|
||||
"author": {
|
||||
"name": "Defame1297",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: bin
|
||||
version: 1.1.5
|
||||
version: 1.1.6
|
||||
description: Skills for everyday AI-assisted development work that is not tied to a single tool, forge or language, and has not yet been split into a focused plugin.
|
||||
author:
|
||||
name: Defame1297
|
||||
|
||||
@@ -26,11 +26,6 @@ trigger_tests:
|
||||
query: "Research why these integration tests are failing"
|
||||
should_trigger: false
|
||||
|
||||
- id: negative-neuledge
|
||||
name: "Negative — MCP server setup goes to neuledge-context"
|
||||
query: "Install the neuledge context server and set it up"
|
||||
should_trigger: false
|
||||
|
||||
- id: negative-context7-direct-question
|
||||
name: "Negative — direct doc question goes to context7-mcp, not research"
|
||||
query: "What are the Next.js middleware options?"
|
||||
|
||||
29
plugins/bin/skills/caveman/README.md
Normal file
29
plugins/bin/skills/caveman/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# caveman
|
||||
|
||||
Ultra-compressed output mode: drop articles, filler and pleasantries, keep the technical substance exact.
|
||||
|
||||
## What it does
|
||||
|
||||
Switches the agent into a terse register — no articles, no hedging, no pleasantries, fragments allowed, arrows for causality — while leaving technical terms, code blocks and quoted error strings untouched. The mode is *sticky*: once turned on it stays on for every subsequent response until the user says "stop caveman" or "normal mode", rather than decaying back to normal prose after a few turns.
|
||||
|
||||
It carries one built-in escape hatch. Security warnings, confirmations for irreversible actions, multi-step sequences where fragment order could be misread, and any request to clarify are answered in normal prose, then the compressed register resumes.
|
||||
|
||||
## Hand-invoked only
|
||||
|
||||
`SKILL.md` sets `disable-model-invocation: true`. This is the single most important thing to know about this skill: **the model cannot route to it.** No other skill can hand off to it, and no phrasing in a user's request will cause it to be selected automatically. The only way in is the human typing `/caveman`.
|
||||
|
||||
That is deliberate — output style is the user's choice, not an inference the router should make on their behalf. It is also why the description reads as one plain human-facing sentence rather than carrying the trigger phrasing and boundary clause a routable skill needs.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/caveman
|
||||
```
|
||||
|
||||
Then keep working normally. To leave the mode, say "stop caveman" or "normal mode".
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The whole skill — persistence rule, compression rules, worked examples, and the auto-clarity exception |
|
||||
@@ -1,17 +1,16 @@
|
||||
---
|
||||
name: caveman
|
||||
disable-model-invocation: true
|
||||
description: >
|
||||
Ultra-compressed communication mode. Cuts token usage ~75% by dropping
|
||||
filler, articles, and pleasantries while keeping full technical accuracy.
|
||||
Use when user says "caveman mode", "talk like caveman", "use caveman",
|
||||
"less tokens", "be brief", or invokes /caveman.
|
||||
Ultra-compressed output mode that drops articles, filler and pleasantries while
|
||||
keeping technical substance exact, cutting token usage by roughly 75%.
|
||||
---
|
||||
|
||||
Respond terse like smart caveman. All technical substance stay. Only fluff die.
|
||||
|
||||
## Persistence
|
||||
|
||||
ACTIVE EVERY RESPONSE once triggered. No revert after many turns. No filler drift. Still active if unsure. Off only when user says "stop caveman" or "normal mode".
|
||||
ACTIVE EVERY RESPONSE once user type `/caveman`. No revert after many turns. No filler drift. Still active if unsure. Off only when user says "stop caveman" or "normal mode".
|
||||
|
||||
## Rules
|
||||
|
||||
|
||||
35
plugins/bin/skills/diagnose/README.md
Normal file
35
plugins/bin/skills/diagnose/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# diagnose
|
||||
|
||||
A six-phase discipline for hard bugs and performance regressions: feedback loop → reproduce → hypothesise → instrument → fix with a regression test → clean up.
|
||||
|
||||
## What it does
|
||||
|
||||
Imposes an order of operations on debugging so the agent cannot skip to guessing. The load-bearing phase is the first one: build a fast, deterministic, agent-runnable pass/fail signal for the bug. Everything downstream — bisection, hypothesis testing, instrumentation — just consumes that signal, so the skill refuses to advance to Phase 2 without one, and says so explicitly rather than hypothesising blind.
|
||||
|
||||
The remaining phases each carry a constraint worth knowing about: hypotheses are generated 3–5 at a time and must be falsifiable, so the first plausible idea cannot anchor the whole investigation; every debug log is tagged with a unique prefix (`[DEBUG-a4f2]`) so cleanup is a single grep; the regression test is written before the fix and only at a seam that exercises the real bug pattern; and the run closes by asking what would have prevented the bug, handing off to `improve-codebase-architecture` when the answer is architectural.
|
||||
|
||||
Performance regressions take a branch of their own inside Phase 4 — baseline measurement and bisection, not logs.
|
||||
|
||||
## Conditional reading
|
||||
|
||||
Neither reference file is read on every run; `SKILL.md` names the condition for each.
|
||||
|
||||
- `references/feedback-loops.md` is read when Phase 1 has no signal yet, or when the loop you have is slow or intermittent.
|
||||
- `references/regression-seams.md` is read when Phase 5 leaves you unsure whether the available seam is deep enough — or whether one exists at all.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/diagnose
|
||||
```
|
||||
|
||||
Describe the bug or the regression. For filing and triaging a reported bug rather than diagnosing it, use `triage`; for test-first feature work, use `tdd`.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The six phases and their gates — what must be true before each one ends |
|
||||
| `references/feedback-loops.md` | Loaded when Phase 1 has no loop or the loop is too weak: ten ways to construct one ordered by cost, how to sharpen an existing loop, handling intermittent bugs, and what to ask the user for when the bug resists reproduction |
|
||||
| `references/regression-seams.md` | Loaded when Phase 5 is unsure about the seam: what makes a seam correct, the four shapes of a too-shallow seam, and what to do when no correct seam exists |
|
||||
| `assets/hitl-loop.template.sh` | Copy-and-edit bash template for the last-resort human-in-the-loop feedback loop, cited by `references/feedback-loops.md`. Provides `step` and `capture` helpers and prints captured values as `KEY=VALUE` for the agent to parse |
|
||||
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: diagnose
|
||||
description: Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.
|
||||
description: >
|
||||
Use when the user says "diagnose this" or "debug this", reports something
|
||||
broken, throwing, or failing, or says something got slow. Not filing or
|
||||
triaging a reported bug -> `triage`. Not test-first feature work -> `tdd`.
|
||||
---
|
||||
|
||||
# Diagnose
|
||||
@@ -15,40 +18,11 @@ When exploring the codebase, use the project's domain glossary to get a clear me
|
||||
|
||||
Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
|
||||
|
||||
### Ways to construct one — try them in roughly this order
|
||||
**If you do not yet have such a signal, read `references/feedback-loops.md`** — ten ways to build one ordered by cost, and what to ask the user for when the bug resists reproduction entirely.
|
||||
|
||||
1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
|
||||
2. **Curl / HTTP script** against a running dev server.
|
||||
3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
|
||||
4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
|
||||
5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
|
||||
6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
|
||||
7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
|
||||
8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
|
||||
9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
|
||||
10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
|
||||
**If you do have one, it is probably not sharp enough yet.** Make it faster and more deterministic, and make it assert on the exact symptom rather than "didn't crash" — a 30-second flaky loop is barely better than no loop. If it stays slow or intermittent after that, read that file's "Iterate on the loop itself" and "Intermittent bugs" sections.
|
||||
|
||||
Build the right feedback loop, and the bug is 90% fixed.
|
||||
|
||||
### Iterate on the loop itself
|
||||
|
||||
Treat the loop as a product. Once you have _a_ loop, ask:
|
||||
|
||||
- Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
|
||||
- Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
|
||||
- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
|
||||
|
||||
A 30-second flaky loop is barely better than no loop. A 2-second deterministic loop is a debugging superpower.
|
||||
|
||||
### Non-deterministic bugs
|
||||
|
||||
The goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's debuggable.
|
||||
|
||||
### When you genuinely cannot build a loop
|
||||
|
||||
Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) permission to add temporary production instrumentation. Do **not** proceed to hypothesise without a loop.
|
||||
|
||||
Do not proceed to Phase 2 until you have a loop you believe in.
|
||||
Do not proceed to Phase 2 until you have a loop you believe in. If you cannot build one, stop and say so explicitly, listing what you tried — never hypothesise without a signal.
|
||||
|
||||
## Phase 2 — Reproduce
|
||||
|
||||
@@ -57,7 +31,7 @@ Run the loop. Watch the bug appear.
|
||||
Confirm:
|
||||
|
||||
- [ ] The loop produces the failure mode the **user** described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
|
||||
- [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
|
||||
- [ ] The failure is reproducible across multiple runs. If it is intermittent, `references/feedback-loops.md` defines the rate high enough to debug against — go back to Phase 1 and raise it.
|
||||
- [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
|
||||
|
||||
Do not proceed until you reproduce the bug.
|
||||
@@ -90,19 +64,17 @@ Tool preference:
|
||||
|
||||
## Phase 5 — Fix + regression test
|
||||
|
||||
Write the regression test **before the fix** — but only if there is a **correct seam** for it.
|
||||
Write the regression test **before the fix** — but only at a **correct seam**: one where the test exercises the real bug pattern as it occurs at the call site. If the available seam looks too shallow, or you cannot tell whether it is, read `references/regression-seams.md`.
|
||||
|
||||
A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
|
||||
**If no correct seam exists, that itself is the finding.** Note it and carry it into Phase 6 — the architecture is preventing the bug from being locked down.
|
||||
|
||||
**If no correct seam exists, that itself is the finding.** Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
|
||||
At a correct seam:
|
||||
|
||||
If a correct seam exists:
|
||||
|
||||
1. Turn the minimised repro into a failing test at that seam.
|
||||
1. Turn the Phase 1 loop into a failing test at that seam, narrowed to the symptom captured in Phase 2.
|
||||
2. Watch it fail.
|
||||
3. Apply the fix.
|
||||
4. Watch it pass.
|
||||
5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
|
||||
5. Re-run the Phase 1 feedback loop against the original, un-narrowed scenario.
|
||||
|
||||
## Phase 6 — Cleanup + post-mortem
|
||||
|
||||
|
||||
40
plugins/bin/skills/diagnose/references/feedback-loops.md
Normal file
40
plugins/bin/skills/diagnose/references/feedback-loops.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Constructing and sharpening a feedback loop
|
||||
|
||||
A feedback loop is a fast, deterministic, agent-runnable pass/fail signal for the bug. Build the right one and the bug is 90% fixed. This file covers the whole arc: building a loop, sharpening one you already have, and escalating when the bug resists reproduction.
|
||||
|
||||
## Ways to construct one — try them in roughly this order
|
||||
|
||||
1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
|
||||
2. **Curl / HTTP script** against a running dev server.
|
||||
3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
|
||||
4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
|
||||
5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
|
||||
6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
|
||||
7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
|
||||
8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
|
||||
9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
|
||||
10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `assets/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
|
||||
|
||||
## Iterate on the loop itself
|
||||
|
||||
Treat the loop as a product. Once you have _a_ loop, ask:
|
||||
|
||||
- Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
|
||||
- Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
|
||||
- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
|
||||
|
||||
A 30-second flaky loop is barely better than no loop. A 2-second deterministic loop is a debugging superpower.
|
||||
|
||||
## Intermittent bugs — raise the reproduction rate
|
||||
|
||||
If the loop only sometimes fails, the goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's debuggable.
|
||||
|
||||
## When you genuinely cannot build a loop
|
||||
|
||||
Stop and say so explicitly. List what you tried. Ask the user for:
|
||||
|
||||
- access to whatever environment reproduces it,
|
||||
- a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or
|
||||
- permission to add temporary production instrumentation.
|
||||
|
||||
Do **not** proceed to hypothesise without a loop. A hypothesis you cannot falsify against a signal is a guess, and the fix that follows it is unverifiable.
|
||||
24
plugins/bin/skills/diagnose/references/regression-seams.md
Normal file
24
plugins/bin/skills/diagnose/references/regression-seams.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Judging a regression-test seam
|
||||
|
||||
Read this when Phase 5 leaves you unsure whether the seam available for the regression test is the correct one — either because the obvious seam looks shallow, or because there appears to be no seam at all.
|
||||
|
||||
## What makes a seam correct
|
||||
|
||||
A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site: the same entry point, the same participants, the same ordering, and the same state the real caller holds when it goes wrong.
|
||||
|
||||
## Seams that are too shallow
|
||||
|
||||
- A single-caller test when the bug only appears with multiple callers.
|
||||
- A unit test that cannot replicate the chain of calls that triggered the bug.
|
||||
- A test that reproduces the symptom by construction — asserting on a value the test itself set — rather than by driving the code path that produces it.
|
||||
- A test that mocks out the collaborator the bug actually lives in.
|
||||
|
||||
A regression test at a shallow seam gives false confidence. It passes forever, including after a change reintroduces the bug at the real call site, and it will be read by the next maintainer as proof the bug is locked down.
|
||||
|
||||
## When there is no correct seam
|
||||
|
||||
Do not force one, and do not settle for a shallow seam to have something green. Instead:
|
||||
|
||||
1. Apply the fix and verify it against the Phase 1 loop directly.
|
||||
2. Write down which seams you considered and why each was too shallow.
|
||||
3. Carry that into Phase 6's "what would have prevented this bug" question. A missing seam is an architecture finding — tangled callers, hidden coupling, or a module with no testable boundary — and the handoff is the `improve-codebase-architecture` skill, with those specifics attached.
|
||||
27
plugins/bin/skills/grill-me/README.md
Normal file
27
plugins/bin/skills/grill-me/README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# grill-me
|
||||
|
||||
Interview the user relentlessly about a plan or design until the decision tree is fully resolved.
|
||||
|
||||
## What it does
|
||||
|
||||
Turns the agent into an interviewer rather than an implementer. It walks the design tree branch by branch, resolving dependencies between decisions one at a time, and offers its own recommended answer alongside each question so the user has something concrete to push against. Two rules give it its shape: **one question at a time**, and **never ask what the codebase can answer** — if a question is settleable by reading the code, the agent goes and reads the code instead of spending the user's attention on it.
|
||||
|
||||
## Composition
|
||||
|
||||
This is the plain grilling loop, with no documentation side effects. The sibling `grill-with-docs` skill runs the same interview but additionally challenges answers against the project's `CONTEXT.md` glossary and existing ADRs, and writes decisions back into those files as they crystallise. Reach for that one when the project has a domain model worth defending; reach for this one when it does not, or when nothing should be written down yet.
|
||||
|
||||
`triage` composes the documented variant, not this one, when an issue needs fleshing out.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/grill-me
|
||||
```
|
||||
|
||||
Describe the plan or design to be stress-tested. Expect questions one at a time, each with a recommended answer.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The whole skill — the interview instruction, the one-question-at-a-time rule, and the explore-instead-of-asking rule |
|
||||
@@ -1,6 +1,10 @@
|
||||
---
|
||||
name: grill-me
|
||||
description: Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
|
||||
description: >
|
||||
Use when the user says "grill me" or wants a plan or design stress-tested by
|
||||
relentless interview — one question at a time, down each branch of the
|
||||
decision tree. Not a plan to challenge against `CONTEXT.md` and ADRs ->
|
||||
`grill-with-docs`.
|
||||
---
|
||||
|
||||
Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
|
||||
|
||||
37
plugins/bin/skills/grill-with-docs/README.md
Normal file
37
plugins/bin/skills/grill-with-docs/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# grill-with-docs
|
||||
|
||||
The grilling interview, run against the project's domain model — and writing decisions back into `CONTEXT.md` and ADRs as they land.
|
||||
|
||||
## What it does
|
||||
|
||||
Runs the same relentless one-question-at-a-time interview as `grill-me`, with the project's own documentation as an active participant. During codebase exploration it also locates the domain documentation — a root `CONTEXT.md` and `docs/adr/`, or a `CONTEXT-MAP.md` pointing at per-context glossaries and ADR directories in a multi-context repo — and then uses it five ways:
|
||||
|
||||
- **Challenges terms against the glossary.** When the user's usage conflicts with what `CONTEXT.md` already defines, that is raised immediately rather than absorbed.
|
||||
- **Sharpens fuzzy language** by proposing a precise canonical term ("you're saying 'account' — do you mean the Customer or the User?").
|
||||
- **Stress-tests domain relationships with concrete scenarios**, inventing edge cases that force the user to be precise about where one concept ends and the next begins.
|
||||
- **Cross-references claims against the code**, and surfaces contradictions between what the user says happens and what the code does.
|
||||
- **Updates `CONTEXT.md` inline**, the moment a term is resolved, rather than batching changes to the end of the session where they get lost.
|
||||
|
||||
Files are created lazily — only when there is something real to write.
|
||||
|
||||
ADRs are offered *sparingly*, and only when all three tests pass: the decision is hard to reverse, it would surprise a future reader without the context, and it was a genuine trade-off with real alternatives. Missing any one of the three means no ADR.
|
||||
|
||||
## Composition
|
||||
|
||||
`grill-me` is the same interview without the documentation side effects — use it when there is no domain model to defend or nothing should be written down yet. `triage` composes this skill (not `grill-me`) at step 4 when an issue needs fleshing out. `improve-codebase-architecture` runs its own grilling loop and borrows this skill's `CONTEXT.md` and ADR discipline for the decisions that come out of it.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/grill-with-docs
|
||||
```
|
||||
|
||||
Describe the plan or design. Expect questions one at a time, each with a recommended answer, and expect `CONTEXT.md` to be edited during the session rather than after it.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The interview instruction plus the domain-awareness rules: file layout discovery, the five during-session behaviours, and the three-part ADR test |
|
||||
| `CONTEXT-FORMAT.md` | Skill-root document, cited when a term is resolved: the structure of a `CONTEXT.md` and how to write a Language entry |
|
||||
| `ADR-FORMAT.md` | Skill-root document, cited when an ADR is offered: `docs/adr/` naming, sequential numbering, and the ADR template |
|
||||
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: grill-with-docs
|
||||
description: Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.
|
||||
description: >
|
||||
Use when a plan should be stress-tested against the project's domain model —
|
||||
the interview challenges terms against `CONTEXT.md` and writes decisions into
|
||||
it and into ADRs as they land. Not a plain interview -> `grill-me`.
|
||||
---
|
||||
|
||||
<what-to-do>
|
||||
|
||||
36
plugins/bin/skills/improve-codebase-architecture/README.md
Normal file
36
plugins/bin/skills/improve-codebase-architecture/README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# improve-codebase-architecture
|
||||
|
||||
Surface architectural friction and propose deepening opportunities — refactors that turn shallow modules into deep ones.
|
||||
|
||||
## What it does
|
||||
|
||||
Looks for places where a codebase is hard to understand, hard to test, or hard for an agent to navigate, and proposes refactors that concentrate behaviour behind smaller interfaces. It runs in three stages:
|
||||
|
||||
1. **Explore.** Reads the domain glossary and any ADRs in the area first, then walks the codebase with an `Explore` sub-agent — organically, noting friction rather than applying fixed heuristics. The **deletion test** is the filter: imagine deleting the module; if complexity vanishes it was a pass-through, if complexity reappears across N callers it was earning its keep.
|
||||
2. **Present candidates.** A numbered list, each with files, problem, solution and benefits — benefits stated in terms of *locality* and *leverage* and of how tests would improve. No interfaces are proposed yet; the user picks one.
|
||||
3. **Grilling loop.** Walks the design tree for the chosen candidate, with documentation side effects landing inline as decisions crystallise.
|
||||
|
||||
The skill is opinionated about vocabulary, and that is the point: **module, interface, implementation, depth, seam, adapter, leverage, locality**, used exactly, with no drift into "component", "service", "API" or "boundary". Domain nouns come from `CONTEXT.md`, architecture nouns from `LANGUAGE.md` — so a proposal reads as "the Order intake module", never "the FooBarHandler".
|
||||
|
||||
ADRs are treated as decisions not to be re-litigated. A candidate that contradicts one is surfaced only when the friction is real enough to warrant reopening it, and is marked as such.
|
||||
|
||||
## Composition
|
||||
|
||||
`diagnose` hands off here when a bug's post-mortem concludes that no correct test seam exists, or that callers are tangled — the recommendation is made after the fix is in, not before. The grilling loop follows `grill-with-docs`'s discipline for `CONTEXT.md` entries and ADR offers, and `SKILL.md` names that skill's format documents directly.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/improve-codebase-architecture
|
||||
```
|
||||
|
||||
Point at a codebase or an area of one. Expect a numbered candidate list and a "which of these would you like to explore?" before any interface design happens.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | Condensed glossary, key principles, and the three-stage process |
|
||||
| `LANGUAGE.md` | Skill-root document, cited throughout `SKILL.md`: full definitions of every term, the words each one replaces, and the full principle list |
|
||||
| `INTERFACE-DESIGN.md` | Skill-root document, read at stage 3 when the user wants alternative interfaces explored: the parallel sub-agent "Design It Twice" pattern, framing the problem space, and the per-agent design constraints |
|
||||
| `DEEPENING.md` | Skill-root document, cited from `INTERFACE-DESIGN.md`: how to deepen a cluster of shallow modules safely, the four dependency categories (in-process, local-substitutable, remote-but-owned, true external), seam discipline, and the replace-don't-layer testing strategy |
|
||||
@@ -1,6 +1,11 @@
|
||||
---
|
||||
name: improve-codebase-architecture
|
||||
description: Find deepening opportunities in a codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/. Use when the user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more testable and AI-navigable.
|
||||
description: >
|
||||
Use when the user wants to improve architecture, find refactoring
|
||||
opportunities, consolidate tightly-coupled modules, or make a codebase more
|
||||
testable and AI-navigable — deepening opportunities that turn shallow modules
|
||||
into deep ones, informed by `CONTEXT.md` and `docs/adr/`. Not debugging a
|
||||
failure -> `diagnose`.
|
||||
---
|
||||
|
||||
# Improve Codebase Architecture
|
||||
@@ -9,7 +14,7 @@ Surface architectural friction and propose **deepening opportunities** — refac
|
||||
|
||||
## Glossary
|
||||
|
||||
Use these terms exactly in every suggestion. Consistent language is the point — don't drift into "component," "service," "API," or "boundary." Full definitions in [LANGUAGE.md](LANGUAGE.md).
|
||||
Use these terms exactly in every suggestion. Consistent language is the point — don't drift into "component," "service," "API," or "boundary."
|
||||
|
||||
- **Module** — anything with an interface and an implementation (function, class, package, slice).
|
||||
- **Interface** — everything a caller must know to use the module: types, invariants, error modes, ordering, config. Not just the type signature.
|
||||
@@ -20,12 +25,14 @@ Use these terms exactly in every suggestion. Consistent language is the point
|
||||
- **Leverage** — what callers get from depth.
|
||||
- **Locality** — what maintainers get from depth: change, bugs, knowledge concentrated in one place.
|
||||
|
||||
Key principles (see [LANGUAGE.md](LANGUAGE.md) for the full list):
|
||||
Key principles:
|
||||
|
||||
- **Deletion test**: imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
|
||||
- **The interface is the test surface.**
|
||||
- **One adapter = hypothetical seam. Two adapters = real seam.**
|
||||
|
||||
If a term or principle above is ambiguous in the case in front of you, or you need the definitions and the principles the two lists leave out, read `LANGUAGE.md`.
|
||||
|
||||
This skill is _informed_ by the project's domain model. The domain language gives names to good seams; ADRs record decisions the skill should not re-litigate.
|
||||
|
||||
## Process
|
||||
@@ -53,7 +60,7 @@ Present a numbered list of deepening opportunities. For each candidate:
|
||||
- **Solution** — plain English description of what would change
|
||||
- **Benefits** — explained in terms of locality and leverage, and also in how tests would improve
|
||||
|
||||
**Use CONTEXT.md vocabulary for the domain, and [LANGUAGE.md](LANGUAGE.md) vocabulary for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
|
||||
**Use CONTEXT.md vocabulary for the domain, and the architecture glossary above for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
|
||||
|
||||
**ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly (e.g. _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
|
||||
|
||||
@@ -65,7 +72,7 @@ Once the user picks a candidate, drop into a grilling conversation. Walk the des
|
||||
|
||||
Side effects happen inline as decisions crystallize:
|
||||
|
||||
- **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md` — same discipline as `/grill-with-docs` (see [CONTEXT-FORMAT.md](../grill-with-docs/CONTEXT-FORMAT.md)). Create the file lazily if it doesn't exist.
|
||||
- **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md` — same discipline as `grill-with-docs`, in the format `grill-with-docs`'s `CONTEXT-FORMAT.md` defines. Create the file lazily if it doesn't exist.
|
||||
- **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
|
||||
- **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones. See [ADR-FORMAT.md](../grill-with-docs/ADR-FORMAT.md).
|
||||
- **Want to explore alternative interfaces for the deepened module?** See [INTERFACE-DESIGN.md](INTERFACE-DESIGN.md).
|
||||
- **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones. See `grill-with-docs`'s `ADR-FORMAT.md`.
|
||||
- **Want to explore alternative interfaces for the deepened module?** Read `INTERFACE-DESIGN.md`.
|
||||
|
||||
32
plugins/bin/skills/prototype/README.md
Normal file
32
plugins/bin/skills/prototype/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# prototype
|
||||
|
||||
Build a throwaway prototype that answers one design question — either a runnable terminal app or several UI variations.
|
||||
|
||||
## What it does
|
||||
|
||||
Treats a prototype as **throwaway code that answers a question**, and lets the question decide the artifact. `SKILL.md` opens with a two-row dispatch table and the run resolves exactly one row before doing anything else:
|
||||
|
||||
- *"Does this logic / state model feel right?"* → a tiny interactive terminal app that pushes the state machine through the cases that are hard to reason about on paper.
|
||||
- *"What should this look like?"* → several radically different UI variations on one route, switchable from a floating bottom bar via a URL search param.
|
||||
|
||||
The two branches produce fundamentally different artifacts, so picking wrong wastes the whole prototype. When the question is genuinely ambiguous and the user is unreachable, the skill defaults on the shape of the surrounding code (backend module → logic, page or component → UI) and states the assumption at the top of the prototype rather than silently choosing.
|
||||
|
||||
Six rules apply to both branches: throwaway and visibly named as such, one command to run, no persistence by default, no polish, surface the full state after every action or variant switch, and delete or absorb the prototype when it is done. The *answer* is the only durable output — the skill captures it in a commit message, ADR, issue or `NOTES.md` before the code is deleted.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/prototype
|
||||
```
|
||||
|
||||
State the design question. For production code, use `tdd`; for talking a design through without building anything, use `grill-me`.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The branch dispatch table and the rules that apply to both branches |
|
||||
| `references/logic.md` | The logic branch, read only when that row is selected: when it is the right shape, and how to build the interactive terminal app |
|
||||
| `references/ui.md` | The UI branch, read only when that row is selected: when it is the right shape, and how to build and switch between the variations |
|
||||
|
||||
Each reference is self-contained — a run reads one of the two, never both.
|
||||
@@ -1,6 +1,10 @@
|
||||
---
|
||||
name: prototype
|
||||
description: Build a throwaway prototype to flush out a design before committing to it. Routes between two branches — a runnable terminal app for state/business-logic questions, or several radically different UI variations toggleable from one route. Use when the user wants to prototype, sanity-check a data model or state machine, mock up a UI, explore design options, or says "prototype this", "let me play with it", "try a few designs".
|
||||
description: >
|
||||
Use when the user wants a throwaway prototype to answer a design question about
|
||||
a data model, state machine or business logic, or to mock up a UI in several
|
||||
variations. Not production code -> `tdd`. Not talking a design through ->
|
||||
`grill-me`.
|
||||
---
|
||||
|
||||
# Prototype
|
||||
@@ -9,10 +13,12 @@ A prototype is **throwaway code that answers a question**. The question decides
|
||||
|
||||
## Pick a branch
|
||||
|
||||
Identify which question is being answered — from the user's prompt, the surrounding code, or by asking if the user is around:
|
||||
| Question being answered | Build | Reference |
|
||||
|---|---|---|
|
||||
| "Does this logic / state model feel right?" | A tiny interactive terminal app that pushes the state machine through cases that are hard to reason about on paper | `references/logic.md` |
|
||||
| "What should this look like?" | Several radically different UI variations on one route, switchable via a URL search param and a floating bottom bar | `references/ui.md` |
|
||||
|
||||
- **"Does this logic / state model feel right?"** → [LOGIC.md](LOGIC.md). Build a tiny interactive terminal app that pushes the state machine through cases that are hard to reason about on paper.
|
||||
- **"What should this look like?"** → [UI.md](UI.md). Generate several radically different UI variations on a single route, switchable via a URL search param and a floating bottom bar.
|
||||
Resolve the row from the user's prompt, the surrounding code, or by asking if the user is around, then read only that reference — each is self-contained.
|
||||
|
||||
The two branches produce fundamentally different artifacts — getting this wrong wastes the whole prototype. If the question is genuinely ambiguous and the user isn't reachable, default to whichever branch better matches the surrounding code (a backend module → logic; a page or component → UI) and state the assumption at the top of the prototype.
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ A tiny interactive terminal app that lets the user drive a state model by hand.
|
||||
- "I want to feel out what the API should look like before writing it."
|
||||
- Anything where the user wants to **press buttons and watch state change**.
|
||||
|
||||
If the question is "what should this look like" — wrong branch. Use [UI.md](UI.md).
|
||||
If the question is "what should this look like" — wrong branch. Read `references/ui.md`.
|
||||
|
||||
## Process
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Generate **several radically different UI variations** on a single route, switchable from a floating bottom bar. The user flips between variants in the browser, picks one (or steals bits from each), then throws the rest away.
|
||||
|
||||
If the question is about logic/state rather than what something looks like — wrong branch. Use [LOGIC.md](LOGIC.md).
|
||||
If the question is about logic/state rather than what something looks like — wrong branch. Read `references/logic.md`.
|
||||
|
||||
## When this is the right shape
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
```yaml
|
||||
version: "1.1"
|
||||
updated: 2026-06-21
|
||||
|
||||
when: >-
|
||||
Invoked when the user wants to gather structured reference documentation for a
|
||||
tool, library, or API from MCP documentation indexes or web sources. Typically
|
||||
run before writing a new skill that wraps an external tool, or any time
|
||||
reference files are needed for a topic. Triggered explicitly
|
||||
("/research <topic> <path>") or implicitly when the user asks to look up,
|
||||
gather, or pull docs for a topic before implementing something.
|
||||
|
||||
references:
|
||||
- .agents/skills/context7-mcp/SKILL.md # context7-mcp — MCP source channel integrated at step 2
|
||||
```
|
||||
31
plugins/bin/skills/research/README.md
Normal file
31
plugins/bin/skills/research/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# research
|
||||
|
||||
Research a tool, library or API from canonical documentation into a directory of structured per-topic reference files.
|
||||
|
||||
## What it does
|
||||
|
||||
Runs a six-step pipeline: scope against the working directory (what version is actually in use, what is already documented), resolve the topic through Context7, websearch for canonical docs covering whatever Context7 missed, read those sources, deepen one level into the links worth following, then write one markdown file per topic area plus a `sources.md` provenance record.
|
||||
|
||||
Four gotchas at the top of `SKILL.md` shape the whole run, and each exists because of a specific failure: the output path is never inferred (a guessed destination scatters a directory's worth of files through someone's source tree); nothing is written outside that path; no empty topic file is ever written (a stub `troubleshooting.md` reads downstream as researched and closed); and a Context7 "no results", redirect or header-only response does not count as coverage. If no topic area has content, the run writes nothing at all — `sources.md` included — and reports what it searched.
|
||||
|
||||
The frontmatter pins `model: sonnet` and a closed `allowed-tools` list. Notably it grants no subagent tool, so every `WebFetch` is serial and each fetched page lands in the run's own context — which is why steps 4 and 5 insist on reducing each page to notes before fetching the next, and cap deepening at roughly ten extra pages.
|
||||
|
||||
## Composition
|
||||
|
||||
Both reference files are read on condition, never on every run — `SKILL.md` inlines the minimum each step needs (the seven default topic areas at step 1, the four `sources.md` field names and the topic-file frontmatter keys at step 6) and sends the run to the reference only for what it does not carry. Those four field names are matched literally by the downstream provenance validator, so prose written in their place parses as nothing and the check passes having verified nothing — which is why they are inlined rather than deferred.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/research
|
||||
```
|
||||
|
||||
Name the topic and the output path — the skill will stop and ask if the path is missing. Supplying starting URLs is treated as a deliberate source choice and skips Context7 resolution and discovery. For documentation derived from existing code or specs, use `write-docs`; for a bug or incident, use `diagnose`.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The four gotchas and the six research steps |
|
||||
| `references/topics.md` | Read at Step 1 only when what belongs in a default topic is unclear or a custom topic is needed: the per-topic coverage table and the custom-topic naming rule |
|
||||
| `references/file-format.md` | Read at Step 6 only when the inlined field names do not settle the case: slug derivation, the Context7 slug and URL convention, and what belongs in a topic body |
|
||||
@@ -1,97 +1,78 @@
|
||||
---
|
||||
name: research
|
||||
description: >-
|
||||
Use when the user wants to research a topic and generate structured reference
|
||||
markdown files. Handles: finding canonical docs for a tool/library/API via
|
||||
Context7 MCP or web sources, reading and deepening into linked pages,
|
||||
organizing extracted content into topic files (overview, installation,
|
||||
configuration, cli-reference, api-reference, examples, troubleshooting). Do
|
||||
NOT use when the user wants to write documentation from existing code or specs
|
||||
(use write-docs), install or manage the neuledge-context MCP server (use
|
||||
neuledge-context), or research a bug/incident (use diagnose).
|
||||
Use when the user wants a tool, library, or API researched from canonical
|
||||
documentation into structured per-topic reference markdown files. Not
|
||||
documentation written from existing code or specs -> `write-docs`. Not a bug
|
||||
or incident -> `diagnose`.
|
||||
metadata:
|
||||
category: research
|
||||
allowed-tools:
|
||||
- WebSearch
|
||||
- WebFetch
|
||||
- Grep
|
||||
- Glob
|
||||
- Read
|
||||
- Write
|
||||
- WebSearch
|
||||
- WebFetch
|
||||
- mcp__context7__resolve-library-id
|
||||
- mcp__context7__query-docs
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
<requirements>
|
||||
## Gotchas
|
||||
|
||||
## Required inputs
|
||||
- Never infer the output path. A run writes a directory's worth of files, and a guessed destination scatters them through someone's source tree. If the user named no path, stop and ask.
|
||||
- Write nothing outside the given output path. A file placed beside the agreed directory is one the user never asked for and will not think to look for.
|
||||
- Never write an empty topic file. A stub `troubleshooting.md` reads downstream as researched and closed.
|
||||
- A Context7 response that is a "no results" message, a redirect notice, or header-only boilerplate is not coverage. A topic area counts as covered only when the response carries at least one substantive paragraph.
|
||||
|
||||
- **Topic** — the subject to research (tool, library, API, concept); inferred from user description if clear, ask if ambiguous
|
||||
- **Output path** — directory where reference files will be written; must be provided explicitly — do not infer or default
|
||||
- **Starting URLs** — optional; if provided, skip discovery websearch and read these first
|
||||
## Step 1 — Scope against the working directory
|
||||
|
||||
## Constraints
|
||||
Search for existing use of the topic — imports, config files, version pins, reference files already written — and narrow the research to what is missing: the version actually in use, the topics not yet documented.
|
||||
|
||||
- Never write files outside the explicitly provided output path
|
||||
- Skip any default topic file if no relevant content is found for it — do not create empty files
|
||||
- Create additional topic files beyond the default list when content warrants it (e.g. `webhooks.md`, `rate-limits.md`)
|
||||
- Subagents handle parallel source reading and link deepening — the orchestrator writes all files; subagents return summaries only, never write directly
|
||||
- Context7 MCP calls (`resolve-library-id`, `query-docs`) are made only by the orchestrator at step 2 — subagents must not call them
|
||||
- `sources.md` is always written, even if only one source was read
|
||||
- Each topic file must have frontmatter with `topic` and `source_keys`; body is prose only — no inline URLs
|
||||
- Source keys in `sources.md` must be kebab-case slugs: derived from the source domain or page title for web sources; for Context7 sources use `context7-<library-slug>` (e.g. `context7-vercel-next-js`)
|
||||
- Default topic list and file format spec live in `references/` sub-files — read them at step 1
|
||||
The default topic areas are `overview`, `installation`, `configuration`, `cli-reference`,
|
||||
`api-reference`, `examples` and `troubleshooting` — one file each, and only where content exists.
|
||||
If what belongs in one of them is unclear, or the topic needs a file outside that set, read
|
||||
`references/topics.md` for the per-topic coverage table and the custom-topic naming rule.
|
||||
|
||||
</requirements>
|
||||
## Step 2 — Resolve against Context7
|
||||
|
||||
<steps>
|
||||
If the topic is a library, framework, or API and the user gave no starting URLs, call `resolve-library-id` with the topic name and the user's full question — match quality depends on the question, not the bare name — then `query-docs` once per default topic area. Record each response as a source with slug `context7-<library-slug>`, and mark which topic areas it covered — those skip the web reads at step 4.
|
||||
|
||||
## Process
|
||||
If the library does not resolve, or the user gave starting URLs, go to step 3. Explicit URLs are a source choice; do not second-guess them with a resolution attempt.
|
||||
|
||||
1. **Scan codebase.** Search the working directory for existing usage of the topic — imports, config files, version pins, existing reference files. Use findings to narrow research scope (e.g. target the version already in use, skip topics already documented). Read `references/topics.md` for the default topic list and `references/file-format.md` for the output file format spec.
|
||||
## Step 3 — Discover sources
|
||||
|
||||
2. **Try Context7.** If the topic is a library, framework, or API and no starting URLs were provided, call `resolve-library-id` with the topic name and the user's question. If a match resolves, call `query-docs` once per default topic area (see `references/topics.md`). Treat each response as a source summary with slug `context7-<library-slug>` (e.g. `context7-vercel-next-js`). A topic area has sufficient content when the Context7 response contains at least one substantive paragraph — not a "no results" message, redirect notice, or header-only boilerplate. Mark covered topic areas — skip their subagent web reads in step 4. If the library does not resolve, or starting URLs were provided (explicit source choice by the user), skip this step entirely.
|
||||
If the user gave starting URLs, skip discovery: those URLs are the source list and go straight to step 4.
|
||||
|
||||
3. **Discover sources.** For topics not covered by Context7 (or when no starting URLs were provided and Context7 did not resolve), websearch for canonical documentation (prefer `llms.txt`, developer docs, official API references over tutorials or blog posts). Collect 3–5 candidate URLs before reading any.
|
||||
Otherwise, for every topic area Context7 did not cover, websearch for canonical documentation — `llms.txt`, official developer docs, and API references ahead of tutorials or blog posts. Collect three to five candidate URLs before reading any of them.
|
||||
|
||||
4. **Read sources in parallel.** Spawn one subagent per source URL. Each subagent fetches the page, extracts relevant content, identifies links worth deepening, and returns a structured summary (content by topic area + links to follow). Subagents do not write files.
|
||||
If nothing usable comes back, stop and report what was searched, then ask for starting URLs rather than settling for tutorials.
|
||||
|
||||
5. **Deepen.** For each subagent that returned links worth following, spawn child subagents per branch. Continue until content becomes repetitive or out of scope. Cap at ~10 additional pages total across all branches.
|
||||
## Step 4 — Read the sources
|
||||
|
||||
6. **Consolidate.** Merge all subagent summaries (Context7 and web) by topic area. Identify which default topics have sufficient content and which custom topics emerged.
|
||||
`WebFetch` each URL in turn. No subagent tool is granted here, so the reads are serial and every fetched page lands in this context: reduce each page to notes by topic area, plus the links worth deepening, before fetching the next one.
|
||||
|
||||
7. **Write topic files.** For each topic with content, write `<output-path>/<topic>.md` using the format in `references/file-format.md`. Orchestrator writes all files — never delegate file writing to a subagent.
|
||||
## Step 5 — Deepen
|
||||
|
||||
8. **Write `sources.md`.** Write `<output-path>/sources.md` mapping each source slug to its URL (use `context7:<library-id>` as the URL for Context7 sources), description, and list of topic files it contributed to. Include sources that yielded no content, marked `no content extracted`.
|
||||
`WebFetch` the links worth following, still one at a time and still reducing each page to notes. Stop a branch once its content turns repetitive or leaves the topic, and cap the whole step at roughly ten additional pages — serial reads make that cap a real budget, not a formality.
|
||||
|
||||
## Output format
|
||||
## Step 6 — Write
|
||||
|
||||
- `<output-path>/<topic>.md` per topic with content — formatted per `references/file-format.md`
|
||||
- `<output-path>/sources.md` — always produced; maps slug → URL, description, contributing files
|
||||
Merge every set of notes, Context7 and web alike, by topic area, then write, in the output path:
|
||||
|
||||
</steps>
|
||||
- `<topic>.md` for each topic area that has content, default or custom. Frontmatter carries `topic:` (the filename without `.md`) and `source_keys:` (kebab-case slugs matching `sources.md`); the body is prose in `##` sections, with no inline URLs.
|
||||
- `sources.md`, always, one `##` section per source — including sources that yielded nothing — with exactly these four fields:
|
||||
|
||||
<checks>
|
||||
```markdown
|
||||
- **URL:** <full URL>
|
||||
- **Description:** <one-line summary>
|
||||
- **Contributing files:** <topic files this source contributed to>
|
||||
- **Status:** `extracted` | `no content extracted`
|
||||
```
|
||||
|
||||
## Failure handling
|
||||
Spell those four field names exactly as given. The downstream provenance validator matches them literally; prose in their place parses as nothing, and the check passes having verified nothing.
|
||||
|
||||
- Output path not provided — stop and ask; do not infer or default
|
||||
- No sources found after websearch — report what was searched, ask user to provide starting URLs
|
||||
- Subagent returns no usable content — skip that source, log in `sources.md` as `no content extracted`
|
||||
- All topic files would be empty — stop, report what was searched, do not write any files
|
||||
Read `references/file-format.md` when the four fields above do not settle the case: what a slug should be, the `context7-<library-slug>` slug and `context7:<library-id>` URL convention for a Context7 source, or what belongs in a topic body versus a verbatim copy of the source.
|
||||
|
||||
## Self-check
|
||||
|
||||
- [ ] Codebase scanned before any websearch was performed
|
||||
- [ ] Output path was explicitly provided — not inferred
|
||||
- [ ] `references/topics.md` and `references/file-format.md` read at step 1
|
||||
- [ ] Context7 resolution attempted before websearch when topic is a library/framework/API
|
||||
- [ ] Context7 calls made only at orchestrator step 2 — no subagent called `resolve-library-id` or `query-docs`
|
||||
- [ ] Context7 sources recorded in `sources.md` with `context7:<library-id>` as URL
|
||||
- [ ] No topic file written without content
|
||||
- [ ] `sources.md` written with all sources read (including those with no content extracted)
|
||||
- [ ] All file writes performed by the orchestrator, not subagents
|
||||
- [ ] Each topic file has `topic` and `source_keys` frontmatter fields
|
||||
- [ ] All source keys in topic files have a matching entry in `sources.md`
|
||||
- [ ] No files written outside the provided output path
|
||||
|
||||
</checks>
|
||||
If no topic area has content, write nothing at all, `sources.md` included, and report what was searched.
|
||||
|
||||
32
plugins/bin/skills/tdd/README.md
Normal file
32
plugins/bin/skills/tdd/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# tdd
|
||||
|
||||
Test-driven development as a strict red-green-refactor loop, one behaviour at a time.
|
||||
|
||||
## What it does
|
||||
|
||||
Two convictions drive this skill. The first is about what a test is for: tests verify behaviour through public interfaces, not implementation details. A good test reads like a specification ("user can checkout with valid cart") and survives refactors because it does not care about internal structure. The warning sign for a bad one is precise — the test breaks when you refactor but behaviour has not changed.
|
||||
|
||||
The second is an explicit anti-pattern: **do not write all the tests first, then all the implementation.** Horizontal slicing treats RED as "write every test" and GREEN as "write every implementation", and it produces tests of *imagined* behaviour — tests of the shape of things, insensitive to real change, committed to before the implementation was understood. The correct shape is vertical: one test → one implementation → repeat, each cycle informed by what the last one taught you.
|
||||
|
||||
The workflow is four stages: plan (confirm the interface and which behaviours matter, with the user — you cannot test everything), fire a tracer bullet (one test proving the path works end to end), loop incrementally one behaviour at a time, then refactor once everything is green. Refactoring while RED is forbidden.
|
||||
|
||||
Codebase exploration uses the project's domain glossary, so test names and interface vocabulary match the project's language, and ADRs in the area are respected.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/tdd
|
||||
```
|
||||
|
||||
Describe the feature or bug. Expect the skill to ask what the public interface should look like and which behaviours matter most before any code is written. For diagnosing an existing bug rather than building test-first, use `diagnose`; for throwaway exploratory code, use `prototype`.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | Philosophy, the horizontal-slicing anti-pattern, the four-stage workflow, and the per-cycle checklist |
|
||||
| `tests.md` | Skill-root document, cited from Philosophy: worked good and bad test examples |
|
||||
| `mocking.md` | Skill-root document, cited from Philosophy: mock at system boundaries only, and what not to mock |
|
||||
| `deep-modules.md` | Skill-root document, cited from stage 1: what a deep module is (small interface, large implementation) and why it is the design to aim for |
|
||||
| `interface-design.md` | Skill-root document, cited from stage 1: designing interfaces for testability, starting with accepting dependencies rather than creating them |
|
||||
| `refactoring.md` | Skill-root document, cited from stage 4: the refactor-candidate checklist — duplication, long methods, shallow modules, feature envy, primitive obsession |
|
||||
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: tdd
|
||||
description: Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
|
||||
description: >
|
||||
Use when the user wants a feature built or a bug fixed test-first, in a strict
|
||||
red-green-refactor loop, one behaviour at a time. Not diagnosing an existing
|
||||
bug -> `diagnose`. Not throwaway exploratory code -> `prototype`.
|
||||
---
|
||||
|
||||
# Test-Driven Development
|
||||
@@ -13,7 +16,7 @@ description: Test-driven development with red-green-refactor loop. Use when user
|
||||
|
||||
**Bad tests** are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.
|
||||
|
||||
See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
|
||||
If you need worked examples of the difference — a behaviour-level test beside the implementation-coupled version of the same check — read `tests.md`. If a test needs a collaborator faked, read `mocking.md` before reaching for a mock.
|
||||
|
||||
## Anti-Pattern: Horizontal Slices
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Writing Agent Briefs
|
||||
|
||||
An agent brief is a structured comment posted on a GitHub issue when it moves to `ready-for-agent`. It is the authoritative specification that an AFK agent will work from. The original issue body and discussion are context — the agent brief is the contract.
|
||||
An agent brief is a structured comment posted on an issue in the issue tracker when it moves to `ready-for-agent`. It is the authoritative specification that an AFK agent will work from. The original issue body and discussion are context — the agent brief is the contract.
|
||||
|
||||
## Principles
|
||||
|
||||
@@ -27,7 +27,7 @@ Describe **what** the system should do, not **how** to implement it. The agent w
|
||||
|
||||
The agent needs to know when it's done. Every agent brief must have concrete, testable acceptance criteria. Each criterion should be independently verifiable.
|
||||
|
||||
- **Good:** "Running `gh issue list --label needs-triage` returns issues that have been through initial classification"
|
||||
- **Good:** "Querying the issue tracker for the `needs-triage` label returns issues that have been through initial classification"
|
||||
- **Bad:** "Triage should work correctly"
|
||||
|
||||
### Explicit scope boundaries
|
||||
|
||||
35
plugins/bin/skills/triage/README.md
Normal file
35
plugins/bin/skills/triage/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# triage
|
||||
|
||||
Move issues on the project issue tracker through a small state machine of triage roles.
|
||||
|
||||
## What it does
|
||||
|
||||
Gives issue triage an explicit state model and a fixed set of moves. Every issue carries exactly one **category** role (`bug`, `enhancement`) and one **state** role (`needs-triage`, `needs-info`, `ready-for-agent`, `ready-for-human`, `wontfix`); conflicting state roles are flagged to the maintainer before anything else happens. Unlabeled issues normally enter at `needs-triage`; `needs-info` returns there once the reporter replies. The maintainer can override at any point, and unusual transitions are questioned rather than executed silently.
|
||||
|
||||
A run does one of three things depending on what the maintainer asks for:
|
||||
|
||||
- **Show what needs attention** — three buckets, oldest first: unlabeled, `needs-triage`, and `needs-info` with reporter activity since the last triage notes.
|
||||
- **Triage a specific issue** — gather context (including prior triage notes, so resolved questions are not re-asked, and `.out-of-scope/` records that resemble the issue), recommend a category and state with reasoning, attempt reproduction for bugs *before* any grilling, run a `grill-with-docs` session if the issue needs fleshing out, then apply the outcome.
|
||||
- **Quick state override** — "move #42 to ready-for-agent" is trusted and applied directly, skipping grilling, after confirming the exact changes.
|
||||
|
||||
Two hard rules: every comment or issue the skill posts during triage must open with the AI-generated disclaimer, and the canonical role names above are *not* necessarily the label strings in the tracker — each is resolved against the tracker's live label set before it is applied, and a name with no counterpart there is reported to the maintainer as a gap rather than guessed at.
|
||||
|
||||
## Composition
|
||||
|
||||
`grill-with-docs` is invoked at step 4 when an issue needs fleshing out; whatever that session establishes is carried into the triage notes so the work is not lost. The reverse direction also exists: `diagnose` names this skill as the place to send a *reported* bug that needs filing rather than debugging.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/triage
|
||||
```
|
||||
|
||||
Then describe what you want in natural language — "show me anything that needs my attention", "let's look at #42", "move #42 to ready-for-agent", "what's ready for agents to pick up?".
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The roles and state machine, the three invocation modes, the needs-info template, and how to resume a prior session |
|
||||
| `AGENT-BRIEF.md` | Skill-root document, cited when an issue moves to `ready-for-agent` (and reused for `ready-for-human`): how to write a brief that stays durable for weeks while the codebase moves under it — describe interfaces and behavioural contracts, not line numbers |
|
||||
| `OUT-OF-SCOPE.md` | Skill-root document, cited when an enhancement is closed `wontfix` and when checking for prior rejections: how the `.out-of-scope/` knowledge base is laid out and what it is for — institutional memory, and deduplication against re-litigated requests |
|
||||
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: triage
|
||||
description: Triage issues through a state machine driven by triage roles. Use when user wants to create an issue, triage issues, review incoming bugs or feature requests, prepare issues for an AFK agent, or manage issue workflow.
|
||||
description: >
|
||||
Use when the user wants an issue created, triaged, or moved through the
|
||||
tracker's triage states, or an issue prepared for an AFK agent. Not debugging
|
||||
the bug itself -> `diagnose`. Not fleshing out a design -> `grill-with-docs`.
|
||||
---
|
||||
|
||||
# Triage
|
||||
@@ -35,7 +38,7 @@ Five **state** roles:
|
||||
|
||||
Every triaged issue should carry exactly one category role and one state role. If state roles conflict, flag it and ask the maintainer before doing anything else.
|
||||
|
||||
These are canonical role names — the actual label strings used in the issue tracker may differ. The mapping should have been provided to you - run `/setup-matt-pocock-skills` if not.
|
||||
These are canonical role names — the actual label strings used in the issue tracker may differ. Resolve each canonical name against the tracker's live label set before applying it, using whichever tracker skill this install provides. If a name has no counterpart there, report the gap and ask the maintainer for the mapping — never substitute a guess.
|
||||
|
||||
State transitions: an unlabeled issue normally goes to `needs-triage` first; from there it moves to `needs-info`, `ready-for-agent`, `ready-for-human`, or `wontfix`. `needs-info` returns to `needs-triage` once the reporter replies. The maintainer can override at any time — flag transitions that look unusual and ask before proceeding.
|
||||
|
||||
|
||||
30
plugins/bin/skills/write-docs/README.md
Normal file
30
plugins/bin/skills/write-docs/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# write-docs
|
||||
|
||||
Produce technical documentation derived from code and spec, one section at a time, with a confirmation gate on every section.
|
||||
|
||||
## What it does
|
||||
|
||||
Casts the agent as a technical writer with one non-negotiable constraint: **every claim must be traceable to a source file line, a spec section, or an explicit user statement.** Nothing is invented, and behaviour that genuinely cannot be documented from the available sources is marked out-of-scope rather than explained away.
|
||||
|
||||
The process is eight steps — identify scope, read and extract, gap check, draft section by section, confirmation gate, delta summary, reader testing, finalise — and several of them are deliberately gated on the human:
|
||||
|
||||
- Files are read only after the user approves them by name. The skill may propose candidates; it waits.
|
||||
- The **gap check** presents what the code does say and asks the user to fill only what it does not: caller intent, error-handling rationale, non-obvious side effects.
|
||||
- No section is finalised until the full revised text has been shown. The skill never gates on output the user has not seen, and never reprints the whole document — all edits are surgical.
|
||||
- **Reader testing** predicts 5–10 questions a target reader would ask, then spawns a sub-agent that receives only the finished doc and the questions — no source files. If the doc cannot answer them, neither can the sub-agent, and the run loops back to drafting.
|
||||
|
||||
Summary and overview sections are written last, once the detail sections are stable.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/write-docs
|
||||
```
|
||||
|
||||
Name the files or modules to document, the target audience (developer / user / contributor / internal), and the documentation type (reference, guide, README section, inline comment, changelog entry). For a PRD, ADR or decision doc, use `grill-me` or `grill-with-docs` instead — those have dedicated handling.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The whole skill — role, use/do-not-use boundaries, required inputs, constraints, the eight-step process, output format, failure handling, and a nine-item self-check |
|
||||
@@ -1,6 +1,11 @@
|
||||
---
|
||||
name: write-docs
|
||||
description: Write documentation for X, document this module, create docs for this feature. Use when the user wants to produce or update technical documentation derived from code, spec, or existing artifacts. Do NOT use when the user wants a PRD, ADR, decision doc, or skill file — those have dedicated skills.
|
||||
description: >
|
||||
Use when the user wants technical documentation produced or updated from code
|
||||
or spec, every claim traced to a source — "write docs for X", "document this
|
||||
module", "create docs for this feature", "write a README for this". Not an ADR
|
||||
or other decision record -> `grill-with-docs`. Not an external tool researched
|
||||
from its docs -> `research`.
|
||||
version: "1.0"
|
||||
updated: 2026-05-17
|
||||
when: invoked by explicit trigger ("write docs for X", "document this module", "create docs for this feature") or implicit request to produce technical documentation from code or spec
|
||||
@@ -35,7 +40,8 @@ You are a technical writer that produces documentation by reading code and spec
|
||||
- User says "write docs for X", "document this", "create docs for this feature", "write a README for this"
|
||||
|
||||
**Do not use when:**
|
||||
- User wants a PRD, decision doc, or architecture proposal → `to-prd` or `grill-me`
|
||||
- User wants an ADR, decision doc, or architecture proposal → `grill-with-docs`, which writes ADRs
|
||||
- User wants a PRD → no skill in this set produces one; say so rather than redirecting
|
||||
- User wants to document a skill file (skill files are self-describing)
|
||||
- User wants marketing or blog copy
|
||||
- Documentation requires tacit organisational knowledge that cannot be read from code or spec
|
||||
@@ -88,7 +94,7 @@ You are a technical writer that produces documentation by reading code and spec
|
||||
- Stage skipped without a logged reason → flag and require the one-sentence log before continuing
|
||||
- Code behaviour is undocumentable (internal implementation detail, no public spec) → note as out-of-scope in the doc; do not invent an explanation
|
||||
- Reader Testing sub-agent fails on multiple questions → surface the failures, return to step 4; do not mark complete
|
||||
- Requested output is a PRD, decision doc, or architecture proposal → redirect to `to-prd`, `grill-me`, or `grill-with-docs`
|
||||
- Requested output is an ADR, decision doc, or architecture proposal → redirect to `grill-with-docs`; for a PRD, say no skill here produces one instead of redirecting
|
||||
|
||||
## Self-check
|
||||
|
||||
|
||||
25
plugins/bin/skills/zoom-out/README.md
Normal file
25
plugins/bin/skills/zoom-out/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# zoom-out
|
||||
|
||||
Ask the agent to go up a layer of abstraction and map the modules and callers around unfamiliar code.
|
||||
|
||||
## What it does
|
||||
|
||||
A single-purpose prompt for the moment you land in a part of the codebase you do not know. Instead of answering at the level of the file in front of it, the agent climbs one layer and produces a map of the relevant modules and their callers — and names them using the project's own domain glossary vocabulary, so the map lines up with the language the rest of the repo already uses.
|
||||
|
||||
## Hand-invoked only
|
||||
|
||||
`SKILL.md` sets `disable-model-invocation: true`, so the router never selects this skill on its own and no other skill can hand off to it. It runs when the human asks for it. That also means its description is written as one plain human-facing sentence — it carries no trigger phrasing or boundary clause, because nothing routes on it.
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
/zoom-out
|
||||
```
|
||||
|
||||
Best used with the unfamiliar code already in context — the skill widens the view around what you are looking at rather than picking a starting point for you.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | The whole skill — a single instruction, no supporting files |
|
||||
@@ -14,6 +14,9 @@ Runs a single combined pass across every AGENTS.md file in a repo (root and any
|
||||
|
||||
Provide the path to the repo root to audit when invoking.
|
||||
|
||||
Also invoke it proactively after `agentsmd-author` creates or updates an AGENTS.md, or after a
|
||||
hand-edit made outside `agentsmd-author` — the audit is what confirms the result is safe to commit.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
@@ -30,6 +33,6 @@ Provide the path to the repo root to audit when invoking.
|
||||
| `tests/validate-drift.bats` | (source-only) Bats test suite for `scripts/validate-drift.sh` |
|
||||
|
||||
Rows marked **(source-only)** exist in the authoring source (`.apm/skills/agentsmd-audit/`) but are
|
||||
not present in an installed plugin: `scripts/sync-plugin-content.sh` strips `<category>/<name>/tests`
|
||||
when it generates the flat mirror, because these are dev-time fixtures no plugin host needs to
|
||||
discover (ADR-0017). Run them from a repo checkout, not from an install.
|
||||
not present in an installed plugin: the repo's `scripts/sync-plugin-content.sh` strips
|
||||
`<category>/<name>/tests` when it generates the flat mirror, because these are dev-time fixtures no
|
||||
plugin host needs to discover (ADR-0017). Run them from a repo checkout, not from an install.
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
---
|
||||
name: agentsmd-audit
|
||||
description: >
|
||||
Use when the user wants to review a repo's AGENTS.md file, says "audit this
|
||||
AGENTS.md", "check my AGENTS.md", "is this AGENTS.md any good", or wants to
|
||||
know if AGENTS.md is safe to commit — even if they don't use the word
|
||||
"audit". Also invoke proactively after agentsmd-author creates or updates
|
||||
AGENTS.md, or after a hand-edit made outside agentsmd-author. Audits a
|
||||
target repo's AGENTS.md file(s) — root and any nested monorepo files — for
|
||||
embedded secrets/credentials, structural completeness against the
|
||||
agents.md common-sections checklist, and drift (referenced commands or
|
||||
paths that no longer resolve against the repo). Produces a compact
|
||||
findings report (findings only, no PASS noise) with Why and Fix per
|
||||
finding. Do not use to audit CLAUDE.md, .cursor/rules, or other
|
||||
provider-specific adapter files — that's provider-adapter-author's
|
||||
self-contained concern. Do not use to fix or write AGENTS.md content — use
|
||||
agentsmd-author instead.
|
||||
Use when the user wants a repo's AGENTS.md audited for secrets, structure
|
||||
and drift — "is this AGENTS.md safe to commit" — or after a hand-edit
|
||||
outside `agentsmd-author`.
|
||||
Not converting a provider file -> `provider-adapter-author`.
|
||||
Not writing AGENTS.md -> `agentsmd-author`.
|
||||
allowed-tools: Bash Read
|
||||
metadata:
|
||||
category: docs
|
||||
@@ -23,14 +14,13 @@ metadata:
|
||||
- context7-websites-agents-md
|
||||
- context7-agentsmd-agents-md
|
||||
- governance-secrets-hard-prohibition
|
||||
version: "0.1.1"
|
||||
version: "0.1.2"
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
|
||||
- Always run all three checks — this skill does a single combined pass, not staged/gated passes. Don't skip structure or drift checks just because a secrets FAIL was found.
|
||||
- Never inspect or mention provider-specific adapter files (`CLAUDE.md`, `.cursor/rules/*.mdc`, `copilot-instructions.md`, etc.) — that's out of scope. If one exists and duplicates AGENTS.md content, that's `provider-adapter-author`'s concern, not this skill's.
|
||||
- A missing common section (e.g. no "Security" heading) is informational, not a failure — not every repo needs every section from the checklist. Only flag a FAIL when the file is empty, entirely unfilled placeholder text, or contains a real embedded secret/stale reference.
|
||||
- Never inspect or mention provider-specific adapter files (`CLAUDE.md`, `.cursor/rules/*.mdc`, `copilot-instructions.md`, etc.) — that's out of scope.
|
||||
- Gather findings internally; don't narrate PASS/FAIL per check as you go — surface them only in the final report.
|
||||
|
||||
## Step 1 — Run the validators
|
||||
@@ -41,7 +31,7 @@ bash scripts/validate-structure.sh <repo-root>
|
||||
bash scripts/validate-drift.sh <repo-root>
|
||||
```
|
||||
|
||||
Each script walks the repo for every `AGENTS.md` file (root and nested, excluding `.git`, `node_modules`, `vendor`, and similar) and prints `FAIL`/`INFO`/`SUGGESTION` lines with `Why`/`Fix` (or `Note`) per finding. A nonzero exit means at least one FAIL was found in that dimension. If a script cannot execute (`python3` unavailable, Bash denied), fall back to manual review: scan for real-looking credentials, check common sections are present, and spot-check a few referenced commands/paths by hand.
|
||||
Each script walks the repo for every `AGENTS.md` file (root and nested, excluding `.git`, `node_modules`, `vendor`, and similar) and prints `FAIL` lines, plus `INFO`/`SUGGESTION` where applicable, with `Why`/`Fix` (or `Note`) per finding. A nonzero exit means at least one FAIL was found in that dimension. If a script cannot execute (`python3` unavailable, Bash denied), fall back to manual review: scan for real-looking credentials, check common sections are present, and spot-check a few referenced commands/paths by hand. Grade a manual finding the way the scripts grade theirs: a missing common section (e.g. no "Security" heading) is informational, not a failure — not every repo needs every section from the checklist. Only flag a FAIL when the file is empty, entirely unfilled placeholder text, or contains a real embedded secret/stale reference.
|
||||
|
||||
## Step 2 — Report
|
||||
|
||||
@@ -53,16 +43,4 @@ Checked: secrets · structure · drift
|
||||
|
||||
Then output only findings that were found, in this order within a repo: `### Secrets`, `### Structure`, `### Drift`. Omit a dimension heading entirely if it produced nothing — its absence confirms it passed. Report each finding verbatim as emitted by the scripts (they already carry file:line, Why/Fix or Note).
|
||||
|
||||
Close with a result block:
|
||||
|
||||
```text
|
||||
## Result
|
||||
|
||||
PASS
|
||||
PASS · P info
|
||||
PASS (N suggestions) · P info
|
||||
FAIL (N fails)
|
||||
FAIL (N fails) · P info
|
||||
```
|
||||
|
||||
INFO and SUGGESTION findings are observational — they never flip PASS to FAIL. Do not fix anything — this skill reports and proposes only. Point the user to `agentsmd-author` to apply fixes.
|
||||
Close with a `## Result` block holding one line: `PASS`, `PASS (N suggestions)`, or `FAIL (N fails · M suggestions)`, each optionally followed by ` · P info`. Omit the suggestion count when there are none, and omit `· P info` when there are none. INFO and SUGGESTION findings are observational — they never flip PASS to FAIL. Do not fix anything — this skill reports and proposes only. Point the user to `agentsmd-author` to apply fixes.
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
---
|
||||
name: agentsmd-author
|
||||
description: >
|
||||
Use when the user wants to create or update a repo's AGENTS.md file
|
||||
("write an AGENTS.md for this repo", "add setup/test instructions for
|
||||
agents", "update AGENTS.md", "give this package its own AGENTS.md") — even
|
||||
if they don't name the file explicitly, e.g. "document this for AI coding
|
||||
tools" or "make sure agents know how to run tests here". Writes/updates
|
||||
AGENTS.md by exploring the target repo for real build, test, lint, and
|
||||
style conventions — never invents commands. Supports nested monorepo
|
||||
placement (a subdirectory can get its own AGENTS.md following
|
||||
nearest-file-wins precedence). Closes every run by invoking agentsmd-audit
|
||||
inline, and calls provider-adapter-author when an existing provider file
|
||||
(CLAUDE.md, etc.) now duplicates what AGENTS.md owns. Do not use to review
|
||||
an existing AGENTS.md without changing it — use agentsmd-audit instead. Do
|
||||
not use to convert CLAUDE.md/.cursor/rules into a thin adapter — use
|
||||
provider-adapter-author instead.
|
||||
Use when the user wants a repo's AGENTS.md written or updated, root or
|
||||
nested, including "document this for AI coding tools". Writes only verified
|
||||
conventions. Not review-only -> `agentsmd-audit`. Not converting CLAUDE.md ->
|
||||
`provider-adapter-author`.
|
||||
allowed-tools: Bash Read Write Edit
|
||||
metadata:
|
||||
category: docs
|
||||
@@ -22,16 +12,13 @@ metadata:
|
||||
- agents-md-official
|
||||
- context7-websites-agents-md
|
||||
- context7-agentsmd-agents-md
|
||||
version: "0.1.1"
|
||||
version: "0.1.2"
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
|
||||
- Never invent a command. Every line under a setup/test/build section must come from something you actually found in the repo (`package.json` scripts, a `Makefile` target, a CI workflow step, a README). If you can't verify a command, don't include it.
|
||||
- AGENTS.md has no required schema — don't force every common-sections-checklist heading into every repo. Include only sections that reflect something real about this repo; a thin, accurate file beats a padded, generic one.
|
||||
- Nested placement is for genuinely different conventions, not convenience. Only create a subdirectory AGENTS.md when that subtree has its own build tool, stack, or conventions distinct from the root — otherwise you're duplicating content the root already covers, which the nearest-file-wins rule doesn't merge back together.
|
||||
- This skill never touches CLAUDE.md, `.cursor/rules/*.mdc`, `copilot-instructions.md`, or similar provider files directly — that's `provider-adapter-author`'s job. Detect and hand off; don't reconcile it yourself.
|
||||
- This skill never audits on its own judgment — the closing `agentsmd-audit` invocation is mandatory, not optional, even when the change looks trivial.
|
||||
- Never write to a provider file yourself, in any circumstance: `CLAUDE.md`, `.cursor/rules/*.mdc`, `.github/copilot-instructions.md` and their equivalents are `provider-adapter-author`'s to own. That holds even when the user asks for one in the same breath as AGENTS.md, and even when the file is merely stale or missing a pointer rather than duplicating anything. Detect it and hand off.
|
||||
|
||||
## Step 1 — Explore the target repo
|
||||
|
||||
@@ -40,17 +27,17 @@ Before writing anything, gather real facts: package manager and scripts (`packag
|
||||
## Step 2 — Decide placement
|
||||
|
||||
- No `AGENTS.md` at the repo root yet → create one there first, covering whole-repo conventions.
|
||||
- A subdirectory has materially different build/test tooling or conventions than the root → create or update a nested `AGENTS.md` there, scoped to what's different. Don't repeat root-level content — the nearest-file-wins rule means the nested file is read alone, not merged with the root.
|
||||
- A subdirectory has materially different build/test tooling or conventions than the root → create or update a nested `AGENTS.md` there, scoped to what's different. Convenience is not a reason to create one — without a distinct stack you are duplicating content the root already covers. **Don't repeat root-level content** in a nested file: the nearest-file-wins rule means it is read alone, never merged back with the root.
|
||||
- Otherwise → update the existing file(s) in place.
|
||||
|
||||
## Step 3 — Write or update
|
||||
|
||||
Use only sections that reflect something real about the repo — never fill in every common-sections-checklist heading just because it exists. Read `references/content-guide.md` for section-by-section guidance, a worked example, and what separates useful content from generic padding, before writing.
|
||||
AGENTS.md has no required schema. Use only sections that reflect something real about the repo — never fill in every common-sections-checklist heading just because it exists, because a thin accurate file beats a padded generic one. Read `references/content-guide.md` for section-by-section guidance, a worked example, and what separates useful content from generic padding, before writing.
|
||||
|
||||
## Step 4 — Check for an existing provider file
|
||||
|
||||
Look for `CLAUDE.md`, `.cursor/rules/*.mdc`, `.github/copilot-instructions.md`, or similar in the target repo. If one exists and now duplicates content the AGENTS.md you just wrote/updated already owns, invoke the `provider-adapter-author` skill on it to reconcile — don't rewrite it yourself.
|
||||
Look for `CLAUDE.md`, `.cursor/rules/*.mdc`, `.github/copilot-instructions.md`, or similar in the target repo. If one exists, invoke the `provider-adapter-author` skill on it to reconcile — whether it duplicates content the AGENTS.md you just wrote/updated now owns, or is merely stale or missing a pointer to it. Never edit it yourself in either case.
|
||||
|
||||
## Step 5 — Audit and report
|
||||
|
||||
Invoke the `agentsmd-audit` skill directly on the AGENTS.md file(s) you just wrote or updated. Resolve any FAIL findings before considering the work done — re-invoke this skill's own writing steps to fix them, then re-run the audit, same as any other close-the-loop check. Report what was created/changed, whether a provider file was reconciled, and the audit's final result.
|
||||
Invoke the `agentsmd-audit` skill on the target repo root — its validators take a `<repo-root>` and walk the tree for every AGENTS.md themselves; there is no per-file entry point. This closeout is mandatory, not optional, even when the change looks trivial — never sign the work off on your own judgment. Resolve any FAIL findings before considering the work done — re-invoke this skill's own writing steps to fix them, then re-run the audit, same as any other close-the-loop check. Report what was created/changed, whether a provider file was reconciled, and the audit's final result.
|
||||
|
||||
@@ -23,6 +23,7 @@ Provide the path to the provider-specific file to convert (and the target repo r
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | Skill instructions for agents |
|
||||
| `references/provider-matrix.md` | Loaded at Step 1 before searching, unless the target is already a known root `CLAUDE.md`: known files per provider, which ones resolve a cross-file import, the validator flag each needs, and the rule that a standalone run and a run composed into by `agentsmd-author` behave identically |
|
||||
| `references/sources.md` | Provenance record — the in-repo ADR precedent this skill's design is modeled on |
|
||||
| `scripts/validate-adapter.sh` | Self-check gate: reference to AGENTS.md present, no excessive duplication, adapter stays thin |
|
||||
| `scripts/README.md` | Directory documentation for `scripts/` |
|
||||
@@ -30,6 +31,6 @@ Provide the path to the provider-specific file to convert (and the target repo r
|
||||
| `tests/validate-adapter.bats` | (source-only) Bats test suite for `scripts/validate-adapter.sh` |
|
||||
|
||||
Rows marked **(source-only)** exist in the authoring source (`.apm/skills/provider-adapter-author/`)
|
||||
but are not present in an installed plugin: `scripts/sync-plugin-content.sh` strips
|
||||
but are not present in an installed plugin: the repo's `scripts/sync-plugin-content.sh` strips
|
||||
`<category>/<name>/tests` when it generates the flat mirror, because these are dev-time fixtures no
|
||||
plugin host needs to discover (ADR-0017). Run them from a repo checkout, not from an install.
|
||||
|
||||
@@ -1,43 +1,41 @@
|
||||
---
|
||||
name: provider-adapter-author
|
||||
description: >
|
||||
Use when the user wants to convert a provider-specific AI instruction file
|
||||
(CLAUDE.md, .cursor/rules/*.mdc, copilot-instructions.md, etc.) into a
|
||||
thin adapter that defers to a repo's AGENTS.md — e.g. "reduce duplication
|
||||
between CLAUDE.md and AGENTS.md", "make CLAUDE.md just import AGENTS.md"
|
||||
— even if the pattern isn't named explicitly. Also invoke when
|
||||
agentsmd-author detects an existing provider file overlapping with
|
||||
AGENTS.md it just wrote. Detects redundant content in a provider file
|
||||
relative to AGENTS.md and rewrites it down to a minimal reference (an
|
||||
`@AGENTS.md`-style import where supported, or a text pointer otherwise)
|
||||
plus genuinely provider-specific additions. Self-validates via a bundled
|
||||
deterministic script before finishing. Do not use to write or audit
|
||||
AGENTS.md itself — use agentsmd-author or agentsmd-audit.
|
||||
Use when a provider file (CLAUDE.md, .cursor rules, copilot-instructions)
|
||||
duplicating the repo's AGENTS.md should be cut to a thin adapter — "make
|
||||
CLAUDE.md just import AGENTS.md".
|
||||
Not writing the AGENTS file -> `agentsmd-author`.
|
||||
Not auditing the AGENTS file -> `agentsmd-audit`.
|
||||
allowed-tools: Bash Read Edit Write
|
||||
metadata:
|
||||
category: docs
|
||||
source_keys:
|
||||
- adr-0002-0003-two-tier-claude-md
|
||||
version: "0.1.0"
|
||||
version: "0.1.1"
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
|
||||
- Not every provider supports cross-file imports. Claude Code does — a `CLAUDE.md` can consist of nothing but one or more `@path` lines (e.g. `@AGENTS.md`), with no other content required. Cursor's `.cursor/rules/*.mdc` and GitHub Copilot's `copilot-instructions.md` have no native import mechanism as of current tooling — for those, "thin" means a short text pointer to AGENTS.md plus only what that tool actually needs, not a literal import line. Pass `--no-import-syntax` to `scripts/validate-adapter.sh` for these providers.
|
||||
- This skill never creates or edits `AGENTS.md` itself. If the target repo has no `AGENTS.md` yet, stop and point the user to `agentsmd-author` first — there's nothing to adapt to.
|
||||
- Only strip content from the provider file that's genuinely redundant with AGENTS.md. Provider-specific material (IDE settings, tool-only syntax, model-specific instructions) stays — the goal is thin, not empty.
|
||||
- Works standalone or composed-into by `agentsmd-author` — behave identically either way; don't assume a caller skill exists.
|
||||
- Assume a provider has no cross-file import mechanism until you have confirmed it has one. Claude Code is the exception, not the rule: a `CLAUDE.md` may consist of nothing but `@path` lines, while the same `@AGENTS.md` line in a Cursor rule or a Copilot instructions file is inert text no tool resolves. Pass `--no-import-syntax` to `scripts/validate-adapter.sh` for those providers.
|
||||
|
||||
- Works standalone or composed-into by `agentsmd-author` — behave identically either way; do not assume a caller skill exists. Detect the provider file, confirm `AGENTS.md`, and run the closeout validator yourself in both cases (`references/provider-matrix.md`).
|
||||
|
||||
## Step 1 — Detect
|
||||
|
||||
Look for known provider instruction files in the target repo: `CLAUDE.md` (repo root, and any deployed copies), `.cursor/rules/*.mdc`, `.github/copilot-instructions.md`, and similar tool-specific files. Confirm `AGENTS.md` exists at the repo root — if not, stop and tell the user to run `agentsmd-author` first.
|
||||
Find the provider instruction file to convert. Before searching, read `references/provider-matrix.md` — skip it only when the target is already a known root `CLAUDE.md`, which is the common case.
|
||||
|
||||
Then confirm `AGENTS.md` exists at the repo root. If it does not, stop and tell the user to run `agentsmd-author` first — there is nothing to adapt to.
|
||||
|
||||
## Step 2 — Diff and rewrite
|
||||
|
||||
Read the provider file and `AGENTS.md` side by side. Separate the provider file's content into two buckets: lines that restate what `AGENTS.md` already owns (universal rules, conventions, project overview) versus lines that are genuinely provider-specific (tool syntax, IDE behavior, model-specific instructions). Rewrite the provider file:
|
||||
|
||||
- **Providers with import syntax** (Claude Code): replace the redundant bucket with an `@AGENTS.md` (or correct relative path) import line, keep the provider-specific bucket below it.
|
||||
- **Providers without import syntax** (Cursor, Copilot, etc.): replace the redundant bucket with a short pointer sentence mentioning `AGENTS.md`, keep the provider-specific bucket.
|
||||
- **Providers with import syntax** (Claude Code): replace the redundant bucket with an `@AGENTS.md` (or correct relative path) import on a line of its own, keep the provider-specific bucket below it. An import folded into a sentence is not the thin-adapter shape and `scripts/validate-adapter.sh` will not credit it — nor one inside a code fence, an indented block, or an HTML comment, nor one whose path does not resolve to a real, non-empty file on disk.
|
||||
- **Providers without import syntax** (Cursor, Copilot, etc.): replace the redundant bucket with a short sentence pointing at `AGENTS.md` ("See AGENTS.md at the repo root for ..."), keep the provider-specific bucket. A bare or negated mention is not a pointer and will not be credited.
|
||||
|
||||
The provider file is the only file this skill ever writes. Never create or edit `AGENTS.md` — not in this step, not in any step, whatever the payoff looks like.
|
||||
|
||||
Strip only what is genuinely redundant. Provider-specific material stays even when it is short — the goal is thin, not empty.
|
||||
|
||||
## Step 3 — Self-validate
|
||||
|
||||
@@ -47,7 +45,7 @@ Run the bundled check before finishing — this is the skill's own closeout gate
|
||||
bash scripts/validate-adapter.sh [--no-import-syntax] [--max-lines N] <adapter-file> <agents-md-file>
|
||||
```
|
||||
|
||||
Fix any `FAIL` and re-run until it exits `0`.
|
||||
Fix any `FAIL` by editing the provider file, and re-run until it exits `0`. Exits `2` and `3` are not `FAIL`s and nothing was graded under either, so neither is a reason to touch the adapter: `2` means the invocation or the input is wrong (a bad, missing, or extra argument, an unknown option, or a file that is not UTF-8), and `3` means a named file exists but could not be read.
|
||||
|
||||
## Step 4 — Report
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
source_keys:
|
||||
- adr-0002-0003-two-tier-claude-md
|
||||
---
|
||||
|
||||
# Known provider instruction files
|
||||
|
||||
Which files to look for when detecting a provider-specific instruction file, whether each provider
|
||||
resolves a cross-file import, and what a thin adapter therefore looks like for it.
|
||||
|
||||
| Provider | File(s) | Import syntax | Thin adapter shape | Validator flag |
|
||||
|---|---|---|---|---|
|
||||
| Claude Code | `CLAUDE.md` at the repo root, plus any deployed copies | Yes — `@path` lines, e.g. `@AGENTS.md` | One or more `@` import lines; no other content is required | none |
|
||||
| Cursor | `.cursor/rules/*.mdc` | No | A short sentence pointing at `AGENTS.md`, plus the rule's own frontmatter and provider-specific body | `--no-import-syntax` |
|
||||
| GitHub Copilot | `.github/copilot-instructions.md` | No | A short sentence pointing at `AGENTS.md`, plus Copilot-only instructions | `--no-import-syntax` |
|
||||
| Anything else | tool-specific instruction file at whatever path the tool documents | Assume no | Text pointer, as above | `--no-import-syntax` |
|
||||
|
||||
A provider not listed here is not evidence it has an import mechanism. Confirm against that tool's
|
||||
own documentation before emitting an `@`-style line; an unresolved import reads as literal text and
|
||||
silently drops every rule the adapter was supposed to defer to.
|
||||
|
||||
Detection is a search, not a lookup: a repo may hold more than one of these, and each one converts
|
||||
independently against the same `AGENTS.md`.
|
||||
|
||||
## Standalone and composed runs behave identically
|
||||
|
||||
This skill is reached two ways: invoked directly by a user, and composed into by `agentsmd-author`
|
||||
once it has written or updated the repo's `AGENTS.md`. Behave identically either way — do not
|
||||
assume a caller skill exists. Detect the provider file yourself, confirm `AGENTS.md` yourself, and
|
||||
run the closeout validator yourself, rather than treating any step as already done by the caller or
|
||||
as something the caller will do afterwards. No handshake exists to rely on, and no state is
|
||||
passed in beyond the file paths.
|
||||
@@ -5,5 +5,5 @@
|
||||
- **URL:** (in-repo precedent — not an external source or plugin research corpus entry)
|
||||
- **Description:** This repo's own two-tier CLAUDE.md/AGENTS.md pattern: AGENTS.md is the provider-agnostic source of always-on rules; provider-specific files (CLAUDE.md) become thin adapters that import it (`@AGENTS.md` plus provider-specific additions). Grounds this skill's entire adapter-conversion design — the "thin adapter" shape, the `@`-import convention, and the size/duplication expectations enforced by `scripts/validate-adapter.sh`.
|
||||
- **Research doc:** docs/adr/0002-two-tier-claude-md.md, docs/adr/0003-agents-md-provider-agnostic-entry-point.md, providers/claude-code/CLAUDE.md (in-repo ADRs and a live example, not a plugin research corpus entry; referenced here since this skill's design is modeled directly on an existing implementation rather than external research)
|
||||
- **Contributing files:** SKILL.md
|
||||
- **Contributing files:** SKILL.md, references/provider-matrix.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
@@ -4,6 +4,25 @@ Deterministic self-check this skill shells out to instead of relying on LLM judg
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `validate-adapter.sh` | Checks a rewritten provider file (CLAUDE.md, etc.) has a reference to AGENTS.md, doesn't duplicate its content, and stays under a thin-file line threshold |
|
||||
| `validate-adapter.sh` | Checks a rewritten provider file (CLAUDE.md, etc.) has a working reference to AGENTS.md, doesn't duplicate its content, and stays under a thin-file line threshold |
|
||||
|
||||
Takes `<adapter-file> <agents-md-file>`, with optional `--no-import-syntax` and `--max-lines N` flags. Prints `FAIL` findings to stdout and exits non-zero on any failure.
|
||||
Takes exactly `<adapter-file> <agents-md-file>`, with optional `--no-import-syntax` and `--max-lines N` flags (also accepted as `--max-lines=N`). A third positional argument or an unknown option is an error, not something quietly ignored.
|
||||
|
||||
## What counts as a reference to AGENTS.md
|
||||
|
||||
Both modes require the named path to be a real path segment ending in `AGENTS.md` — `AGENTS.md` or `…/AGENTS.md`, not `NOTAGENTS.md` — that resolves on disk, relative to the adapter file, to a non-empty file. An adapter deferring to a path that is not there defers to nothing, so the check has to touch the disk rather than pattern-match the line.
|
||||
|
||||
A reference only counts where something would actually resolve it. A line inside a fenced code block, an indented code block, or an HTML comment is not credited in either mode: Claude Code resolves an import in none of those, so a fenced `@AGENTS.md` is the silent-drop failure this gate exists to catch, not a pass.
|
||||
|
||||
Default mode wants a real import: `@AGENTS.md` alone on its own line, indented no more than three spaces. `--no-import-syntax` wants a prose pointer that reads as one — the sentence naming `AGENTS.md` must carry a deference cue (see, read, refer to, documented in, conventions, …) and must not be negated. `Do NOT read AGENTS.md; it is obsolete.` and `We deleted AGENTS.md last year.` name the file while pointing the reader away from it, and neither is a pointer.
|
||||
|
||||
## Exit codes
|
||||
|
||||
The distinction matters because the skill's closeout tells the agent to fix any non-zero exit by editing the provider file. That is right for exactly one of these.
|
||||
|
||||
| Code | Meaning | What to do |
|
||||
|------|---------|------------|
|
||||
| `0` | Passes every check | Nothing |
|
||||
| `1` | One or more `FAIL` findings printed to stdout — empty adapter, no working reference to AGENTS.md, excessive duplication, or not thin | Edit the provider file |
|
||||
| `2` | Usage or input error: a bad, missing, or extra argument, an unknown option, a path that is not a file, or a file that is not UTF-8. Nothing was graded, so there is no `FAIL` line | Fix the invocation or the file's encoding — do not edit the adapter |
|
||||
| `3` | A named input file exists but could not be read (permissions, I/O error). Nothing was graded and the adapter's contents are unknown | Fix the file's readability — do not edit the adapter |
|
||||
|
||||
@@ -14,27 +14,85 @@ Arguments:
|
||||
adapter-file Path to the provider-specific file to check.
|
||||
agents-md-file Path to the AGENTS.md file it should defer to.
|
||||
|
||||
Exactly two positional arguments are accepted. Extra ones are rejected
|
||||
rather than ignored: a third path silently graded nothing but the first
|
||||
two, so a typo'd invocation passed against the wrong file.
|
||||
|
||||
Options:
|
||||
--no-import-syntax The target provider has no native cross-file import
|
||||
mechanism. Accept a plain-text pointer mention of
|
||||
"AGENTS.md" instead of requiring an @import-style line.
|
||||
mechanism. Require a plain-text pointer line naming
|
||||
"AGENTS.md" instead of an @import-style line; an
|
||||
@AGENTS.md line alone does not satisfy it, because
|
||||
such a provider never resolves it. Without this flag
|
||||
an actual @import line is required, and naming
|
||||
AGENTS.md in prose alone does not satisfy it.
|
||||
--max-lines N Max non-blank lines allowed in the adapter file before
|
||||
it's considered no longer "thin". Default: 60.
|
||||
it's considered no longer "thin". Must be a
|
||||
non-negative integer. Default: 60.
|
||||
--help, -h Show this help and exit 0.
|
||||
-- End of options; every later argument is positional.
|
||||
|
||||
Both flags also accept the --flag=value form (--max-lines=40). An unknown
|
||||
option is reported as an unknown option, not as a missing file.
|
||||
|
||||
What counts as a reference:
|
||||
|
||||
In both modes the named path must be a real path segment ending in
|
||||
AGENTS.md ("AGENTS.md" or ".../AGENTS.md" — not NOTAGENTS.md), and it must
|
||||
resolve on disk, relative to the adapter file, to a non-empty file. An
|
||||
adapter deferring to a path that is not there defers to nothing.
|
||||
|
||||
A mention inside a fenced code block, an indented code block, or an HTML
|
||||
comment is not credited in either mode. Nothing resolves those, so an
|
||||
adapter whose only "import" is fenced silently defers to nothing.
|
||||
|
||||
With --no-import-syntax the pointer must read as a pointer: the sentence
|
||||
naming AGENTS.md has to carry a deference cue (see, read, refer to,
|
||||
documented in, conventions, ...) and must not be a negation ("do not read
|
||||
AGENTS.md", "we deleted AGENTS.md"). A bare mention is not a pointer.
|
||||
|
||||
Exit codes:
|
||||
0 Adapter file passes all checks
|
||||
1 One or more checks failed (empty file, no reference to AGENTS.md,
|
||||
excessive duplication, or file too long)
|
||||
2 Usage or input error — a bad, missing, or extra argument, an unknown
|
||||
option, a path that is not a file, or a file that is not UTF-8. Nothing
|
||||
was graded, so there is no FAIL line and no adapter edit to make: fix
|
||||
the invocation or the file's encoding and re-run. Kept distinct from 1
|
||||
because the skill's own closeout tells the agent to fix every non-zero
|
||||
exit by editing the provider file, which for a mistyped flag edits the
|
||||
wrong file forever.
|
||||
3 A named input file exists but could not be read (permissions, a
|
||||
directory swapped in mid-run, I/O error). Also not a FAIL: nothing was
|
||||
graded and the adapter's contents are unknown, so editing it is
|
||||
guesswork. Fix the file's readability and re-run.
|
||||
EOF
|
||||
}
|
||||
|
||||
NO_IMPORT_SYNTAX=0
|
||||
MAX_LINES=60
|
||||
ARGS=()
|
||||
END_OF_OPTS=0
|
||||
|
||||
require_int() {
|
||||
# $1 = the value to validate
|
||||
if [[ ! "$1" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: --max-lines expects a non-negative integer, got '$1'." >&2
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $END_OF_OPTS -eq 1 ]]; then
|
||||
ARGS+=("$1")
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
case "$1" in
|
||||
--)
|
||||
END_OF_OPTS=1
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
usage
|
||||
exit 0
|
||||
@@ -43,10 +101,38 @@ while [[ $# -gt 0 ]]; do
|
||||
NO_IMPORT_SYNTAX=1
|
||||
shift
|
||||
;;
|
||||
--no-import-syntax=*)
|
||||
echo "Error: --no-import-syntax is a flag and takes no value (got '$1')." >&2
|
||||
exit 2
|
||||
;;
|
||||
--max-lines)
|
||||
MAX_LINES="${2:-}"
|
||||
if [[ $# -lt 2 ]]; then
|
||||
echo "Error: --max-lines requires a value (a non-negative integer)." >&2
|
||||
exit 2
|
||||
fi
|
||||
MAX_LINES="$2"
|
||||
require_int "$MAX_LINES"
|
||||
shift 2
|
||||
;;
|
||||
--max-lines=*)
|
||||
MAX_LINES="${1#--max-lines=}"
|
||||
if [[ -z "$MAX_LINES" ]]; then
|
||||
echo "Error: --max-lines requires a value (a non-negative integer)." >&2
|
||||
exit 2
|
||||
fi
|
||||
require_int "$MAX_LINES"
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
# Reported as an unknown option rather than falling through to the
|
||||
# positional bucket, where it used to surface as "'--bogus' is not a
|
||||
# file" — the right exit code attached to a diagnostic that sends the
|
||||
# reader looking for a path they never typed.
|
||||
echo "Error: unknown option '$1'." >&2
|
||||
echo "" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
ARGS+=("$1")
|
||||
shift
|
||||
@@ -58,7 +144,14 @@ if [[ ${#ARGS[@]} -lt 2 ]]; then
|
||||
echo "Error: adapter-file and agents-md-file are required." >&2
|
||||
echo "" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ ${#ARGS[@]} -gt 2 ]]; then
|
||||
echo "Error: expected exactly 2 positional arguments (adapter-file and agents-md-file), got ${#ARGS[@]}: ${ARGS[*]}." >&2
|
||||
echo "" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
python3 -u - "${ARGS[0]}" "${ARGS[1]}" "$NO_IMPORT_SYNTAX" "$MAX_LINES" <<'PYTHON'
|
||||
@@ -70,17 +163,80 @@ adapter_path, agents_md_path, no_import_syntax, max_lines = sys.argv[1:5]
|
||||
no_import_syntax = no_import_syntax == "1"
|
||||
max_lines = int(max_lines)
|
||||
|
||||
EXIT_FAIL = 1
|
||||
EXIT_USAGE = 2
|
||||
EXIT_UNREADABLE = 3
|
||||
|
||||
if not os.path.isfile(adapter_path):
|
||||
print(f"Error: '{adapter_path}' is not a file.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
sys.exit(EXIT_USAGE)
|
||||
if not os.path.isfile(agents_md_path):
|
||||
print(f"Error: '{agents_md_path}' is not a file.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
sys.exit(EXIT_USAGE)
|
||||
|
||||
with open(adapter_path, encoding="utf-8", errors="replace") as f:
|
||||
adapter_content = f.read()
|
||||
with open(agents_md_path, encoding="utf-8", errors="replace") as f:
|
||||
agents_md_content = f.read()
|
||||
|
||||
def read_text(path):
|
||||
r"""File contents as text, UTF-8, every BOM stripped.
|
||||
|
||||
The BOM strip is not cosmetic. IMPORT_RE anchors on `^ {0,3}@`, and a BOM
|
||||
is not whitespace in Python, so a CLAUDE.md saved by an editor that emits
|
||||
one had its first line — the `@AGENTS.md` import, which is the whole
|
||||
adapter — silently treated as prose. The check then said "no reference to
|
||||
AGENTS.md" and told the author to add the line already sitting in front of
|
||||
them. Same class of silent BOM miss recorded in scripts/skill-size-check.sh;
|
||||
strip it at the reader so no later check has to know about it.
|
||||
|
||||
Every U+FEFF goes, not just one at offset 0. Stripping exactly the first
|
||||
one left the mirror-image false FAIL for a doubled BOM (two concatenated
|
||||
files, or a tool that re-adds one) and for a BOM mid-file at the head of
|
||||
the import line. U+FEFF has no meaning as a character in a markdown
|
||||
instruction file, so removing all of them cannot lose signal.
|
||||
|
||||
Decoding is strict, not errors="replace". Replacement mangles the file and
|
||||
the checks then grade the mangling: a UTF-16 adapter whose first line is
|
||||
`@AGENTS.md` decoded to interleaved NULs and failed as "no reference",
|
||||
which is a true FAIL for a false reason and points the fix at the wrong
|
||||
thing. But strict UTF-8 alone does not catch it — BOM-less UTF-16LE/BE and
|
||||
UTF-32LE are *valid* UTF-8, because NUL is a legal code point, so they
|
||||
decoded clean and produced exactly that false diagnosis anyway. The NUL
|
||||
byte is the complete signal and is checked first: no plausible markdown
|
||||
adapter contains one, and every UTF-16/32 encoding of ASCII is full of
|
||||
them. A file this gate cannot read gets an encoding diagnostic and exit 2,
|
||||
the same policy the ADR-0020 validators' read_text() uses.
|
||||
|
||||
A file that exists but cannot be read at all is neither a pass nor a FAIL —
|
||||
nothing was graded — so it exits 3 rather than 1. Exit 1 sends the skill's
|
||||
closeout into "fix the FAIL by editing the provider file", which for a file
|
||||
it cannot open is an instruction to edit blind.
|
||||
"""
|
||||
try:
|
||||
with open(path, "rb") as fh:
|
||||
raw = fh.read()
|
||||
except OSError as exc:
|
||||
print(f"Error: '{path}' exists but could not be read ({exc.strerror}). "
|
||||
"Nothing was checked — fix whatever is blocking the read "
|
||||
"(permissions, ownership, the underlying device) and re-run; do "
|
||||
"not edit the adapter on the strength of this.", file=sys.stderr)
|
||||
sys.exit(EXIT_UNREADABLE)
|
||||
if b"\x00" in raw:
|
||||
print(f"Error: '{path}' is not valid UTF-8 — it contains NUL bytes, so "
|
||||
"it is almost certainly UTF-16 or UTF-32 (with or without a BOM). "
|
||||
"Re-save it as UTF-8; this check does not guess at other "
|
||||
"encodings.", file=sys.stderr)
|
||||
sys.exit(EXIT_USAGE)
|
||||
try:
|
||||
text = raw.decode("utf-8")
|
||||
except UnicodeDecodeError as exc:
|
||||
print(f"Error: '{path}' is not valid UTF-8 ({exc.reason} at byte "
|
||||
f"{exc.start}) — re-save it as UTF-8; this check does not guess "
|
||||
"at other encodings.", file=sys.stderr)
|
||||
sys.exit(EXIT_USAGE)
|
||||
return text.replace("\ufeff", "")
|
||||
|
||||
|
||||
adapter_content = read_text(adapter_path)
|
||||
agents_md_content = read_text(agents_md_path)
|
||||
adapter_dir = os.path.dirname(os.path.abspath(adapter_path))
|
||||
|
||||
has_fail = False
|
||||
|
||||
@@ -89,30 +245,229 @@ if not adapter_content.strip():
|
||||
print(" Why: An empty adapter carries no reference to AGENTS.md and no provider-specific content.")
|
||||
print(" Fix: Add at least an import (or text pointer) to AGENTS.md.")
|
||||
print()
|
||||
sys.exit(1)
|
||||
sys.exit(EXIT_FAIL)
|
||||
|
||||
IMPORT_RE = re.compile(r'(?m)^\s*@\S*AGENTS\.md\s*$')
|
||||
lines = adapter_content.splitlines()
|
||||
import_lines = [ln for ln in lines if IMPORT_RE.match(ln)]
|
||||
|
||||
# --- Inert regions -----------------------------------------------------------
|
||||
#
|
||||
# A reference only counts where something would actually resolve it. Fenced
|
||||
# code blocks, indented code blocks and HTML comments are shown to the reader
|
||||
# (or hidden from them) as literal text; Claude Code resolves an @import in
|
||||
# none of them. Without this, a ```-fenced `@AGENTS.md` — the exact
|
||||
# copy-the-example-into-the-file mistake this gate exists to catch — exited 0
|
||||
# with the adapter deferring to nothing.
|
||||
#
|
||||
# Indented code blocks are handled by IMPORT_RE's `^ {0,3}` instead of by the
|
||||
# mask: four leading spaces is what opens an indented code block in CommonMark,
|
||||
# so an import has to sit within three. The mask deliberately does not apply
|
||||
# that rule to prose pointers, where four-space indentation is ordinary list
|
||||
# continuation rather than code.
|
||||
FENCE_RE = re.compile(r'^( {0,3})(`{3,}|~{3,})(.*)$')
|
||||
COMMENT_RE = re.compile(r'<!--.*?(?:-->|\Z)', re.DOTALL)
|
||||
|
||||
|
||||
def line_offsets(text):
|
||||
"""[(char offset, line without its terminator)] over `text`."""
|
||||
out = []
|
||||
off = 0
|
||||
for raw in text.splitlines(keepends=True):
|
||||
out.append((off, raw.rstrip("\r\n")))
|
||||
off += len(raw)
|
||||
return out
|
||||
|
||||
|
||||
def build_inert_mask(text, offsets):
|
||||
"""Per-character flags: 1 where a reference would never be resolved."""
|
||||
mask = bytearray(len(text))
|
||||
fence = None # (fence char, opening run length)
|
||||
for start, line in offsets:
|
||||
m = FENCE_RE.match(line)
|
||||
if fence is None:
|
||||
if m:
|
||||
fence = (m.group(2)[0], len(m.group(2)))
|
||||
for i in range(start, start + len(line)):
|
||||
mask[i] = 1
|
||||
continue
|
||||
for i in range(start, start + len(line)):
|
||||
mask[i] = 1
|
||||
if (m and m.group(2)[0] == fence[0]
|
||||
and len(m.group(2)) >= fence[1]
|
||||
and not m.group(3).strip()):
|
||||
fence = None
|
||||
for m in COMMENT_RE.finditer(text):
|
||||
if m.start() < len(mask) and mask[m.start()]:
|
||||
continue # a literal "<!--" printed inside a fence opens nothing
|
||||
for i in range(m.start(), min(m.end(), len(mask))):
|
||||
mask[i] = 1
|
||||
return mask
|
||||
|
||||
|
||||
# --- Reference shapes --------------------------------------------------------
|
||||
#
|
||||
# `\S*AGENTS\.md` had no path-separator boundary, so `@NOTAGENTS.md` and
|
||||
# `@zzzAGENTS.md` counted as imports of AGENTS.md. The matched path must end in
|
||||
# AGENTS.md as a whole segment.
|
||||
IMPORT_RE = re.compile(r'^ {0,3}@(?P<path>\S+?)\s*$')
|
||||
# A mention in prose: an optional relative path, then AGENTS.md, with no
|
||||
# identifier character glued to the front (so NOTAGENTS.md does not match) and
|
||||
# nothing glued to the back.
|
||||
MENTION_RE = re.compile(r'(?<![0-9A-Za-z_.\-/])((?:[\w.\-~]+/)*AGENTS\.md)(?![0-9A-Za-z])')
|
||||
|
||||
# A pointer has to read as a pointer. `"AGENTS.md" in ln` passed
|
||||
# "Do NOT read AGENTS.md; it is obsolete." and "We deleted AGENTS.md last
|
||||
# year." — both of which point the reader away from the file. Require a
|
||||
# deference cue in the naming sentence, and reject a negated one.
|
||||
DIRECTIVE_RE = re.compile(
|
||||
r'\b(see|read|refer|refers|referring|consult|consults|follow|follows|'
|
||||
r'defer|defers|deferring|described|documented|documents|covered|covers|'
|
||||
r'found|listed|specified|defined|governed|per|use|uses|using|apply|obey|'
|
||||
r'start|check|live|lives|contains|holds|carries|inherit|inherits|import|'
|
||||
r'imports|conventions|instructions|guidelines|guidance|rules|standards|'
|
||||
r'reference|setup)\b', re.I)
|
||||
NEGATION_RE = re.compile(
|
||||
r"(\bnot\b|n't\b|\bnever\b|\bno longer\b|\bdeleted\b|\bremoved\b|"
|
||||
r"\bobsolete\b|\bdeprecated\b|\bignore\b|\bignores\b|\bignoring\b|"
|
||||
r"\bdisregard\b|\bsuperseded\b|\bgone\b|\bunused\b|\bstale\b)", re.I)
|
||||
SENTENCE_SPLIT_RE = re.compile(r'(?<=[.;:!?])\s+')
|
||||
|
||||
|
||||
def sentence_around(line, index):
|
||||
"""(sentence of `line` containing character `index`, its start offset)."""
|
||||
bounds = [0]
|
||||
for m in SENTENCE_SPLIT_RE.finditer(line):
|
||||
bounds.append(m.end())
|
||||
bounds.append(len(line) + 1)
|
||||
for i in range(len(bounds) - 1):
|
||||
if bounds[i] <= index < bounds[i + 1]:
|
||||
return line[bounds[i]:bounds[i + 1]], bounds[i]
|
||||
return line, 0
|
||||
|
||||
|
||||
def reads_as_pointer(line, match):
|
||||
"""Does the sentence naming AGENTS.md actually point the reader at it?
|
||||
|
||||
The matched path is blanked out before the cues are applied. It is a
|
||||
filename, not prose, and leaving it in let its own characters vote: the
|
||||
perfectly ordinary `docs/does/not/exist/AGENTS.md` tripped the negation
|
||||
cue on the `not` path segment, so a pointer got rejected for the wrong
|
||||
reason and the near-miss line then reported the wrong diagnosis.
|
||||
"""
|
||||
sentence, sentence_start = sentence_around(line, match.start())
|
||||
rel_start = match.start() - sentence_start
|
||||
rel_end = match.end() - sentence_start
|
||||
probe = sentence[:rel_start] + " AGENTS.md " + sentence[rel_end:]
|
||||
if NEGATION_RE.search(probe):
|
||||
return False
|
||||
return bool(DIRECTIVE_RE.search(probe))
|
||||
|
||||
|
||||
def resolve(raw_path):
|
||||
"""An import/pointer path resolved the way the provider would resolve it."""
|
||||
p = os.path.expanduser(raw_path)
|
||||
if not os.path.isabs(p):
|
||||
p = os.path.join(adapter_dir, p)
|
||||
return os.path.normpath(p)
|
||||
|
||||
|
||||
def target_problem(raw_path):
|
||||
"""None if `raw_path` names a real, non-empty file; else why not."""
|
||||
resolved = resolve(raw_path)
|
||||
if not os.path.isfile(resolved):
|
||||
return f"'{raw_path}' resolves to {resolved}, which does not exist"
|
||||
try:
|
||||
if os.path.getsize(resolved) == 0:
|
||||
return f"'{raw_path}' resolves to {resolved}, which is empty"
|
||||
with open(resolved, "rb") as fh:
|
||||
if not fh.read().strip():
|
||||
return f"'{raw_path}' resolves to {resolved}, which is blank"
|
||||
except OSError as exc:
|
||||
return f"'{raw_path}' resolves to {resolved}, which cannot be read ({exc.strerror})"
|
||||
return None
|
||||
|
||||
|
||||
def names_agents_md(path):
|
||||
return path == "AGENTS.md" or path.endswith("/AGENTS.md")
|
||||
|
||||
|
||||
offsets = line_offsets(adapter_content)
|
||||
lines = [line for _, line in offsets]
|
||||
mask = build_inert_mask(adapter_content, offsets)
|
||||
|
||||
|
||||
def is_inert(abs_index):
|
||||
return abs_index < len(mask) and bool(mask[abs_index])
|
||||
|
||||
|
||||
# Lines shaped like an @AGENTS.md import, whether or not the target resolves.
|
||||
# Used to exclude them from the duplication denominator and from the prose
|
||||
# pointer scan, both of which only care about the shape.
|
||||
import_shaped_lines = set()
|
||||
# (line, raw path) for every import whose target actually resolves.
|
||||
live_imports = []
|
||||
# Diagnostics for imports that are the right shape but resolve to nothing.
|
||||
dead_imports = []
|
||||
# Imports that exist only inside a fence or an HTML comment.
|
||||
inert_imports = []
|
||||
|
||||
for start, line in offsets:
|
||||
m = IMPORT_RE.match(line)
|
||||
if not m or not names_agents_md(m.group("path")):
|
||||
continue
|
||||
at_index = start + line.index("@")
|
||||
if is_inert(at_index):
|
||||
inert_imports.append(line.strip())
|
||||
continue
|
||||
import_shaped_lines.add(line)
|
||||
problem = target_problem(m.group("path"))
|
||||
if problem:
|
||||
dead_imports.append(problem)
|
||||
else:
|
||||
live_imports.append(line)
|
||||
|
||||
live_pointers = []
|
||||
dead_pointers = []
|
||||
inert_pointers = []
|
||||
mention_only = []
|
||||
|
||||
for start, line in offsets:
|
||||
if line in import_shaped_lines:
|
||||
continue
|
||||
for m in MENTION_RE.finditer(line):
|
||||
if is_inert(start + m.start()):
|
||||
inert_pointers.append(line.strip())
|
||||
continue
|
||||
if not reads_as_pointer(line, m):
|
||||
mention_only.append(sentence_around(line, m.start())[0].strip())
|
||||
continue
|
||||
problem = target_problem(m.group(1))
|
||||
if problem:
|
||||
dead_pointers.append(problem)
|
||||
else:
|
||||
live_pointers.append(line)
|
||||
|
||||
if no_import_syntax:
|
||||
has_reference = "AGENTS.md" in adapter_content
|
||||
has_reference = bool(live_pointers)
|
||||
near_misses = dead_pointers + [f"{d} (inside a code fence or HTML comment)" for d in inert_pointers]
|
||||
near_misses += [f"'{s}' names AGENTS.md but does not point at it" for s in mention_only]
|
||||
else:
|
||||
has_reference = bool(import_lines) or "AGENTS.md" in adapter_content
|
||||
has_reference = bool(live_imports)
|
||||
near_misses = dead_imports + [f"'{d}' is inside a code fence or HTML comment, where no import is resolved" for d in inert_imports]
|
||||
|
||||
if not has_reference:
|
||||
has_fail = True
|
||||
print(f"FAIL Adapter has no reference to AGENTS.md — {adapter_path}")
|
||||
if no_import_syntax:
|
||||
print(" Why: This provider has no import syntax, so the adapter must at least mention AGENTS.md as a text pointer.")
|
||||
print(" Fix: Add a sentence like \"See AGENTS.md at the repo root for shared conventions.\"")
|
||||
print(" Why: This provider resolves no cross-file import, so the adapter must point at AGENTS.md in prose; an `@AGENTS.md` line here is inert text. The pointer has to read as a pointer and name a file that is really there — a bare or negated mention (\"we deleted AGENTS.md\") defers nothing, and neither does a mention buried in a code fence or an HTML comment.")
|
||||
print(" Fix: Add a sentence like \"See AGENTS.md at the repo root for shared conventions.\", outside any fence, naming a path that exists relative to this file.")
|
||||
else:
|
||||
print(" Why: A thin adapter must import AGENTS.md (e.g. `@AGENTS.md`) rather than silently omitting it.")
|
||||
print(" Fix: Add an `@AGENTS.md` (or equivalent relative path) import line.")
|
||||
print(" Why: A thin adapter must import AGENTS.md with an `@AGENTS.md` line of its own, indented no more than three spaces, and the path must resolve to a real non-empty file. Naming the file mid-sentence or inside backticks is prose this check will not credit; putting the line inside a ``` fence, an indented code block, or an HTML comment is worse, because nothing resolves it and it looks right.")
|
||||
print(" Fix: Put `@AGENTS.md` (or the equivalent relative path) alone on its own line at the top level of the file, or pass --no-import-syntax if this provider resolves no imports.")
|
||||
for miss in near_misses:
|
||||
print(f" Near miss: {miss}")
|
||||
print()
|
||||
|
||||
# --- Duplication check ---
|
||||
non_import_lines = [ln for ln in lines if not IMPORT_RE.match(ln)]
|
||||
non_import_lines = [ln for ln in lines if ln not in import_shaped_lines]
|
||||
adapter_lines = [ln.strip() for ln in non_import_lines if ln.strip()]
|
||||
agents_lines = {ln.strip() for ln in agents_md_content.splitlines() if ln.strip()}
|
||||
|
||||
@@ -132,10 +487,10 @@ if non_blank_count > max_lines:
|
||||
has_fail = True
|
||||
print(f"FAIL Adapter is not thin — {adapter_path}")
|
||||
print(f" Why: {non_blank_count} non-blank lines exceeds the {max_lines}-line threshold for a thin adapter.")
|
||||
print(" Fix: Move provider-agnostic content into AGENTS.md; keep only genuinely provider-specific additions here.")
|
||||
print(" Fix: Delete the lines already covered by AGENTS.md; keep only genuinely provider-specific additions here.")
|
||||
print()
|
||||
|
||||
if has_fail:
|
||||
sys.exit(1)
|
||||
sys.exit(EXIT_FAIL)
|
||||
sys.exit(0)
|
||||
PYTHON
|
||||
|
||||
@@ -115,6 +115,51 @@ EOF
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "the two --no-import-syntax branches disagree: a text-pointer-only adapter fails in default mode" {
|
||||
ADAPTER="$TMPDIR/copilot-instructions.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
See AGENTS.md at the repo root for setup, style, and testing conventions.
|
||||
|
||||
## Copilot-specific
|
||||
Prefer inline suggestions over chat for one-line edits.
|
||||
EOF
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure
|
||||
assert_output --partial "no reference"
|
||||
|
||||
run bash "$SCRIPT" --no-import-syntax "$ADAPTER" "$AGENTS_MD"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "with --no-import-syntax, an inert @AGENTS.md line alone is not a prose pointer" {
|
||||
ADAPTER="$TMPDIR/copilot-instructions.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
@AGENTS.md
|
||||
|
||||
## Copilot-specific
|
||||
Prefer inline suggestions over chat for one-line edits.
|
||||
EOF
|
||||
run bash "$SCRIPT" --no-import-syntax "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "--max-lines as the final argument reports a real error instead of failing silently" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
echo "@AGENTS.md" > "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD" --max-lines
|
||||
assert_failure 2
|
||||
assert_output --partial "--max-lines requires a value"
|
||||
}
|
||||
|
||||
@test "--max-lines rejects a non-numeric value with a real error" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
echo "@AGENTS.md" > "$ADAPTER"
|
||||
run bash "$SCRIPT" --max-lines abc "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 2
|
||||
assert_output --partial "non-negative integer"
|
||||
}
|
||||
|
||||
@test "--help exits 0 and documents usage" {
|
||||
run bash "$SCRIPT" --help
|
||||
assert_success
|
||||
@@ -123,6 +168,352 @@ EOF
|
||||
|
||||
@test "fails with a clear error when the adapter file argument is missing" {
|
||||
run bash "$SCRIPT"
|
||||
assert_failure
|
||||
assert_failure 2
|
||||
assert_output --partial "required"
|
||||
}
|
||||
|
||||
@test "a UTF-8 BOM before the @import line does not hide it" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
python3 -c "import sys; open(sys.argv[1], 'w', encoding='utf-8-sig').write('@AGENTS.md\n')" "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "a usage error exits 2, a genuine finding exits 1" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
echo "@AGENTS.md" > "$ADAPTER"
|
||||
|
||||
run bash "$SCRIPT" --max-lines -3 "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 2
|
||||
refute_output --partial "FAIL"
|
||||
|
||||
: > "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "FAIL"
|
||||
}
|
||||
|
||||
@test "a non-UTF-8 adapter is reported as an encoding error, not as a missing reference" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
python3 -c "import sys; open(sys.argv[1], 'wb').write('@AGENTS.md\n'.encode('utf-16'))" "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 2
|
||||
assert_output --partial "not valid UTF-8"
|
||||
refute_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "an @AGENTS.md folded into a sentence fails, and the message says the import needs its own line" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
See @AGENTS.md for shared conventions.
|
||||
EOF
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
assert_output --partial "line of its own"
|
||||
}
|
||||
|
||||
# --- Q1: a reference only counts where something would resolve it -------------
|
||||
|
||||
@test "an @AGENTS.md inside a backtick code fence is not credited as an import" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
# Claude notes
|
||||
|
||||
Put this at the top of the file:
|
||||
|
||||
```
|
||||
@AGENTS.md
|
||||
```
|
||||
EOF
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "an @AGENTS.md inside a tilde code fence is not credited as an import" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
~~~
|
||||
@AGENTS.md
|
||||
~~~
|
||||
EOF
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "an @AGENTS.md in a four-space indented code block is not credited as an import" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
# Claude notes
|
||||
|
||||
@AGENTS.md
|
||||
EOF
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "an @AGENTS.md inside a multi-line HTML comment is not credited as an import" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
# Claude notes
|
||||
|
||||
<!--
|
||||
@AGENTS.md
|
||||
-->
|
||||
EOF
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "an @AGENTS.md indented up to three spaces is still credited" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
printf ' @AGENTS.md\n' > "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_success
|
||||
}
|
||||
|
||||
# --- Q2: encodings that decode as valid UTF-8 but are not UTF-8 ---------------
|
||||
|
||||
@test "a BOM-less UTF-16LE adapter is an encoding error, not a missing reference" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
python3 -c "import sys; open(sys.argv[1], 'wb').write('@AGENTS.md\n'.encode('utf-16-le'))" "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 2
|
||||
assert_output --partial "not valid UTF-8"
|
||||
refute_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "a BOM-less UTF-32LE adapter is an encoding error, not a missing reference" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
python3 -c "import sys; open(sys.argv[1], 'wb').write('@AGENTS.md\n'.encode('utf-32-le'))" "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 2
|
||||
assert_output --partial "not valid UTF-8"
|
||||
refute_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "a doubled UTF-8 BOM does not hide the @import line" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
python3 -c "import sys; open(sys.argv[1], 'wb').write(('@AGENTS.md\n').encode('utf-8'))" "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "a BOM in front of a mid-file @import line does not hide it" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
python3 -c "import sys; open(sys.argv[1], 'wb').write(('# Claude notes\n\n@AGENTS.md\n').encode('utf-8'))" "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_success
|
||||
}
|
||||
|
||||
# --- Q3: a file that exists but cannot be read is not a FAIL -----------------
|
||||
|
||||
@test "an adapter that exists but cannot be read exits 3 with a diagnostic and no FAIL" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
echo "@AGENTS.md" > "$ADAPTER"
|
||||
chmod 000 "$ADAPTER"
|
||||
# chmod is not enough under a uid that bypasses it (root in CI containers).
|
||||
# /proc/self/mem is a regular file whose read returns EIO for every uid, so
|
||||
# it exercises the same branch where chmod cannot.
|
||||
if cat "$ADAPTER" >/dev/null 2>&1; then
|
||||
if [ -e /proc/self/mem ]; then
|
||||
ADAPTER=/proc/self/mem
|
||||
else
|
||||
chmod 644 "$TMPDIR/CLAUDE.md"
|
||||
skip "no way to make a readable-by-stat, unreadable-by-open file here"
|
||||
fi
|
||||
fi
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
chmod 644 "$TMPDIR/CLAUDE.md"
|
||||
assert_failure 3
|
||||
assert_output --partial "could not be read"
|
||||
refute_output --partial "FAIL"
|
||||
}
|
||||
|
||||
# --- Q4: the reference has to name, and resolve to, a real AGENTS.md ---------
|
||||
|
||||
@test "an @import naming a path that does not exist is not credited" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
echo "@docs/does/not/exist/AGENTS.md" > "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
assert_output --partial "does not exist"
|
||||
}
|
||||
|
||||
@test "@NOTAGENTS.md and @zzzAGENTS.md are not imports of AGENTS.md" {
|
||||
# The decoys are real files, so the on-disk resolution check cannot be what
|
||||
# rejects them. Only the path-segment boundary can — without the fixtures
|
||||
# this test passes against a substring match and proves nothing.
|
||||
cp "$AGENTS_MD" "$TMPDIR/NOTAGENTS.md"
|
||||
cp "$AGENTS_MD" "$TMPDIR/zzzAGENTS.md"
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
echo "@NOTAGENTS.md" > "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
|
||||
echo "@zzzAGENTS.md" > "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "an @import resolving to a zero-byte AGENTS.md is not credited" {
|
||||
SUB="$TMPDIR/empty"
|
||||
mkdir -p "$SUB"
|
||||
: > "$SUB/AGENTS.md"
|
||||
ADAPTER="$SUB/CLAUDE.md"
|
||||
echo "@AGENTS.md" > "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
assert_output --partial "empty"
|
||||
}
|
||||
|
||||
@test "an @import naming a real relative path to AGENTS.md is credited" {
|
||||
mkdir -p "$TMPDIR/docs"
|
||||
cp "$AGENTS_MD" "$TMPDIR/docs/AGENTS.md"
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
echo "@docs/AGENTS.md" > "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_success
|
||||
}
|
||||
|
||||
# --- Q5: --no-import-syntax needs a pointer, not a mention -------------------
|
||||
|
||||
@test "with --no-import-syntax, a negated mention of AGENTS.md is not a pointer" {
|
||||
ADAPTER="$TMPDIR/copilot-instructions.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
Do NOT read AGENTS.md; it is obsolete.
|
||||
EOF
|
||||
run bash "$SCRIPT" --no-import-syntax "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "with --no-import-syntax, a past-tense mention of a deleted AGENTS.md is not a pointer" {
|
||||
ADAPTER="$TMPDIR/copilot-instructions.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
We deleted AGENTS.md last year.
|
||||
EOF
|
||||
run bash "$SCRIPT" --no-import-syntax "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "with --no-import-syntax, a pointer inside a code fence is not credited" {
|
||||
ADAPTER="$TMPDIR/copilot-instructions.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
Example of what to write:
|
||||
|
||||
```
|
||||
See AGENTS.md at the repo root for shared conventions.
|
||||
```
|
||||
EOF
|
||||
run bash "$SCRIPT" --no-import-syntax "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "with --no-import-syntax, a pointer inside an HTML comment is not credited" {
|
||||
ADAPTER="$TMPDIR/copilot-instructions.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
# Copilot instructions
|
||||
|
||||
<!-- See AGENTS.md at the repo root for shared conventions. -->
|
||||
EOF
|
||||
run bash "$SCRIPT" --no-import-syntax "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "with --no-import-syntax, a name merely ending in AGENTS.md is not a pointer to it" {
|
||||
# Real decoy files, so the on-disk resolution check cannot be what rejects
|
||||
# these — only the token boundary in the mention pattern can. zzzAGENTS.md
|
||||
# is the load-bearing case: dropping the boundary from NOTAGENTS.md leaves
|
||||
# the fragment "NOT" behind, which the negation cue then rejects for an
|
||||
# unrelated reason, so that case alone would prove nothing.
|
||||
cp "$AGENTS_MD" "$TMPDIR/zzzAGENTS.md"
|
||||
cp "$AGENTS_MD" "$TMPDIR/NOTAGENTS.md"
|
||||
ADAPTER="$TMPDIR/copilot-instructions.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
See zzzAGENTS.md at the repo root for shared conventions.
|
||||
EOF
|
||||
run bash "$SCRIPT" --no-import-syntax "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
See NOTAGENTS.md at the repo root for shared conventions.
|
||||
EOF
|
||||
run bash "$SCRIPT" --no-import-syntax "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@test "with --no-import-syntax, a pointer naming a path that does not exist is not credited" {
|
||||
ADAPTER="$TMPDIR/copilot-instructions.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
See docs/does/not/exist/AGENTS.md for shared conventions.
|
||||
EOF
|
||||
run bash "$SCRIPT" --no-import-syntax "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
assert_output --partial "does not exist"
|
||||
}
|
||||
|
||||
# --- argument handling -------------------------------------------------------
|
||||
|
||||
@test "a third positional argument is rejected instead of silently ignored" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
echo "@AGENTS.md" > "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD" "$TMPDIR/also-not-graded.md"
|
||||
assert_failure 2
|
||||
assert_output --partial "exactly 2 positional arguments"
|
||||
# The usage text this prints mentions the word FAIL, so refute the shape of
|
||||
# a real finding line rather than the bare word.
|
||||
refute_output --partial "FAIL Adapter"
|
||||
}
|
||||
|
||||
@test "an unknown option is reported as an unknown option, not as a missing file" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
echo "@AGENTS.md" > "$ADAPTER"
|
||||
run bash "$SCRIPT" --bogus "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 2
|
||||
assert_output --partial "unknown option '--bogus'"
|
||||
refute_output --partial "'--bogus' is not a file"
|
||||
refute_output --partial "FAIL Adapter"
|
||||
}
|
||||
|
||||
@test "--max-lines=N is accepted in the equals form" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
{
|
||||
echo "@AGENTS.md"
|
||||
for i in $(seq 1 10); do echo "Provider-specific line $i unrelated to AGENTS.md content."; done
|
||||
} > "$ADAPTER"
|
||||
run bash "$SCRIPT" --max-lines=5 "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "thin"
|
||||
|
||||
run bash "$SCRIPT" --max-lines=40 "$ADAPTER" "$AGENTS_MD"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "with --no-import-syntax, a bare mention with no deference cue is not a pointer" {
|
||||
ADAPTER="$TMPDIR/copilot-instructions.md"
|
||||
cat > "$ADAPTER" <<'EOF'
|
||||
# Copilot instructions
|
||||
|
||||
This repo also has an AGENTS.md.
|
||||
|
||||
Prefer inline suggestions over chat for one-line edits.
|
||||
EOF
|
||||
run bash "$SCRIPT" --no-import-syntax "$ADAPTER" "$AGENTS_MD"
|
||||
assert_failure 1
|
||||
assert_output --partial "no reference"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "core",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
"description": "Skills for authoring and auditing a repo's AGENTS.md and the provider adapter files that defer to it.",
|
||||
"author": {
|
||||
"name": "Defame1297",
|
||||
|
||||
2
plugins/core/.github/plugin/plugin.json
vendored
2
plugins/core/.github/plugin/plugin.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "core",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
"description": "Skills for authoring and auditing a repo's AGENTS.md and the provider adapter files that defer to it.",
|
||||
"author": {
|
||||
"name": "Defame1297",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: core
|
||||
version: 1.1.1
|
||||
version: 1.1.2
|
||||
description: Skills for authoring and auditing a repo's AGENTS.md and the provider adapter files that defer to it.
|
||||
author:
|
||||
name: Defame1297
|
||||
|
||||
@@ -14,6 +14,9 @@ Runs a single combined pass across every AGENTS.md file in a repo (root and any
|
||||
|
||||
Provide the path to the repo root to audit when invoking.
|
||||
|
||||
Also invoke it proactively after `agentsmd-author` creates or updates an AGENTS.md, or after a
|
||||
hand-edit made outside `agentsmd-author` — the audit is what confirms the result is safe to commit.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
@@ -30,6 +33,6 @@ Provide the path to the repo root to audit when invoking.
|
||||
| `tests/validate-drift.bats` | (source-only) Bats test suite for `scripts/validate-drift.sh` |
|
||||
|
||||
Rows marked **(source-only)** exist in the authoring source (`.apm/skills/agentsmd-audit/`) but are
|
||||
not present in an installed plugin: `scripts/sync-plugin-content.sh` strips `<category>/<name>/tests`
|
||||
when it generates the flat mirror, because these are dev-time fixtures no plugin host needs to
|
||||
discover (ADR-0017). Run them from a repo checkout, not from an install.
|
||||
not present in an installed plugin: the repo's `scripts/sync-plugin-content.sh` strips
|
||||
`<category>/<name>/tests` when it generates the flat mirror, because these are dev-time fixtures no
|
||||
plugin host needs to discover (ADR-0017). Run them from a repo checkout, not from an install.
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
---
|
||||
name: agentsmd-audit
|
||||
description: >
|
||||
Use when the user wants to review a repo's AGENTS.md file, says "audit this
|
||||
AGENTS.md", "check my AGENTS.md", "is this AGENTS.md any good", or wants to
|
||||
know if AGENTS.md is safe to commit — even if they don't use the word
|
||||
"audit". Also invoke proactively after agentsmd-author creates or updates
|
||||
AGENTS.md, or after a hand-edit made outside agentsmd-author. Audits a
|
||||
target repo's AGENTS.md file(s) — root and any nested monorepo files — for
|
||||
embedded secrets/credentials, structural completeness against the
|
||||
agents.md common-sections checklist, and drift (referenced commands or
|
||||
paths that no longer resolve against the repo). Produces a compact
|
||||
findings report (findings only, no PASS noise) with Why and Fix per
|
||||
finding. Do not use to audit CLAUDE.md, .cursor/rules, or other
|
||||
provider-specific adapter files — that's provider-adapter-author's
|
||||
self-contained concern. Do not use to fix or write AGENTS.md content — use
|
||||
agentsmd-author instead.
|
||||
Use when the user wants a repo's AGENTS.md audited for secrets, structure
|
||||
and drift — "is this AGENTS.md safe to commit" — or after a hand-edit
|
||||
outside `agentsmd-author`.
|
||||
Not converting a provider file -> `provider-adapter-author`.
|
||||
Not writing AGENTS.md -> `agentsmd-author`.
|
||||
allowed-tools: Bash Read
|
||||
metadata:
|
||||
category: docs
|
||||
@@ -23,14 +14,13 @@ metadata:
|
||||
- context7-websites-agents-md
|
||||
- context7-agentsmd-agents-md
|
||||
- governance-secrets-hard-prohibition
|
||||
version: "0.1.1"
|
||||
version: "0.1.2"
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
|
||||
- Always run all three checks — this skill does a single combined pass, not staged/gated passes. Don't skip structure or drift checks just because a secrets FAIL was found.
|
||||
- Never inspect or mention provider-specific adapter files (`CLAUDE.md`, `.cursor/rules/*.mdc`, `copilot-instructions.md`, etc.) — that's out of scope. If one exists and duplicates AGENTS.md content, that's `provider-adapter-author`'s concern, not this skill's.
|
||||
- A missing common section (e.g. no "Security" heading) is informational, not a failure — not every repo needs every section from the checklist. Only flag a FAIL when the file is empty, entirely unfilled placeholder text, or contains a real embedded secret/stale reference.
|
||||
- Never inspect or mention provider-specific adapter files (`CLAUDE.md`, `.cursor/rules/*.mdc`, `copilot-instructions.md`, etc.) — that's out of scope.
|
||||
- Gather findings internally; don't narrate PASS/FAIL per check as you go — surface them only in the final report.
|
||||
|
||||
## Step 1 — Run the validators
|
||||
@@ -41,7 +31,7 @@ bash scripts/validate-structure.sh <repo-root>
|
||||
bash scripts/validate-drift.sh <repo-root>
|
||||
```
|
||||
|
||||
Each script walks the repo for every `AGENTS.md` file (root and nested, excluding `.git`, `node_modules`, `vendor`, and similar) and prints `FAIL`/`INFO`/`SUGGESTION` lines with `Why`/`Fix` (or `Note`) per finding. A nonzero exit means at least one FAIL was found in that dimension. If a script cannot execute (`python3` unavailable, Bash denied), fall back to manual review: scan for real-looking credentials, check common sections are present, and spot-check a few referenced commands/paths by hand.
|
||||
Each script walks the repo for every `AGENTS.md` file (root and nested, excluding `.git`, `node_modules`, `vendor`, and similar) and prints `FAIL` lines, plus `INFO`/`SUGGESTION` where applicable, with `Why`/`Fix` (or `Note`) per finding. A nonzero exit means at least one FAIL was found in that dimension. If a script cannot execute (`python3` unavailable, Bash denied), fall back to manual review: scan for real-looking credentials, check common sections are present, and spot-check a few referenced commands/paths by hand. Grade a manual finding the way the scripts grade theirs: a missing common section (e.g. no "Security" heading) is informational, not a failure — not every repo needs every section from the checklist. Only flag a FAIL when the file is empty, entirely unfilled placeholder text, or contains a real embedded secret/stale reference.
|
||||
|
||||
## Step 2 — Report
|
||||
|
||||
@@ -53,16 +43,4 @@ Checked: secrets · structure · drift
|
||||
|
||||
Then output only findings that were found, in this order within a repo: `### Secrets`, `### Structure`, `### Drift`. Omit a dimension heading entirely if it produced nothing — its absence confirms it passed. Report each finding verbatim as emitted by the scripts (they already carry file:line, Why/Fix or Note).
|
||||
|
||||
Close with a result block:
|
||||
|
||||
```text
|
||||
## Result
|
||||
|
||||
PASS
|
||||
PASS · P info
|
||||
PASS (N suggestions) · P info
|
||||
FAIL (N fails)
|
||||
FAIL (N fails) · P info
|
||||
```
|
||||
|
||||
INFO and SUGGESTION findings are observational — they never flip PASS to FAIL. Do not fix anything — this skill reports and proposes only. Point the user to `agentsmd-author` to apply fixes.
|
||||
Close with a `## Result` block holding one line: `PASS`, `PASS (N suggestions)`, or `FAIL (N fails · M suggestions)`, each optionally followed by ` · P info`. Omit the suggestion count when there are none, and omit `· P info` when there are none. INFO and SUGGESTION findings are observational — they never flip PASS to FAIL. Do not fix anything — this skill reports and proposes only. Point the user to `agentsmd-author` to apply fixes.
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
---
|
||||
name: agentsmd-author
|
||||
description: >
|
||||
Use when the user wants to create or update a repo's AGENTS.md file
|
||||
("write an AGENTS.md for this repo", "add setup/test instructions for
|
||||
agents", "update AGENTS.md", "give this package its own AGENTS.md") — even
|
||||
if they don't name the file explicitly, e.g. "document this for AI coding
|
||||
tools" or "make sure agents know how to run tests here". Writes/updates
|
||||
AGENTS.md by exploring the target repo for real build, test, lint, and
|
||||
style conventions — never invents commands. Supports nested monorepo
|
||||
placement (a subdirectory can get its own AGENTS.md following
|
||||
nearest-file-wins precedence). Closes every run by invoking agentsmd-audit
|
||||
inline, and calls provider-adapter-author when an existing provider file
|
||||
(CLAUDE.md, etc.) now duplicates what AGENTS.md owns. Do not use to review
|
||||
an existing AGENTS.md without changing it — use agentsmd-audit instead. Do
|
||||
not use to convert CLAUDE.md/.cursor/rules into a thin adapter — use
|
||||
provider-adapter-author instead.
|
||||
Use when the user wants a repo's AGENTS.md written or updated, root or
|
||||
nested, including "document this for AI coding tools". Writes only verified
|
||||
conventions. Not review-only -> `agentsmd-audit`. Not converting CLAUDE.md ->
|
||||
`provider-adapter-author`.
|
||||
allowed-tools: Bash Read Write Edit
|
||||
metadata:
|
||||
category: docs
|
||||
@@ -22,16 +12,13 @@ metadata:
|
||||
- agents-md-official
|
||||
- context7-websites-agents-md
|
||||
- context7-agentsmd-agents-md
|
||||
version: "0.1.1"
|
||||
version: "0.1.2"
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
|
||||
- Never invent a command. Every line under a setup/test/build section must come from something you actually found in the repo (`package.json` scripts, a `Makefile` target, a CI workflow step, a README). If you can't verify a command, don't include it.
|
||||
- AGENTS.md has no required schema — don't force every common-sections-checklist heading into every repo. Include only sections that reflect something real about this repo; a thin, accurate file beats a padded, generic one.
|
||||
- Nested placement is for genuinely different conventions, not convenience. Only create a subdirectory AGENTS.md when that subtree has its own build tool, stack, or conventions distinct from the root — otherwise you're duplicating content the root already covers, which the nearest-file-wins rule doesn't merge back together.
|
||||
- This skill never touches CLAUDE.md, `.cursor/rules/*.mdc`, `copilot-instructions.md`, or similar provider files directly — that's `provider-adapter-author`'s job. Detect and hand off; don't reconcile it yourself.
|
||||
- This skill never audits on its own judgment — the closing `agentsmd-audit` invocation is mandatory, not optional, even when the change looks trivial.
|
||||
- Never write to a provider file yourself, in any circumstance: `CLAUDE.md`, `.cursor/rules/*.mdc`, `.github/copilot-instructions.md` and their equivalents are `provider-adapter-author`'s to own. That holds even when the user asks for one in the same breath as AGENTS.md, and even when the file is merely stale or missing a pointer rather than duplicating anything. Detect it and hand off.
|
||||
|
||||
## Step 1 — Explore the target repo
|
||||
|
||||
@@ -40,17 +27,17 @@ Before writing anything, gather real facts: package manager and scripts (`packag
|
||||
## Step 2 — Decide placement
|
||||
|
||||
- No `AGENTS.md` at the repo root yet → create one there first, covering whole-repo conventions.
|
||||
- A subdirectory has materially different build/test tooling or conventions than the root → create or update a nested `AGENTS.md` there, scoped to what's different. Don't repeat root-level content — the nearest-file-wins rule means the nested file is read alone, not merged with the root.
|
||||
- A subdirectory has materially different build/test tooling or conventions than the root → create or update a nested `AGENTS.md` there, scoped to what's different. Convenience is not a reason to create one — without a distinct stack you are duplicating content the root already covers. **Don't repeat root-level content** in a nested file: the nearest-file-wins rule means it is read alone, never merged back with the root.
|
||||
- Otherwise → update the existing file(s) in place.
|
||||
|
||||
## Step 3 — Write or update
|
||||
|
||||
Use only sections that reflect something real about the repo — never fill in every common-sections-checklist heading just because it exists. Read `references/content-guide.md` for section-by-section guidance, a worked example, and what separates useful content from generic padding, before writing.
|
||||
AGENTS.md has no required schema. Use only sections that reflect something real about the repo — never fill in every common-sections-checklist heading just because it exists, because a thin accurate file beats a padded generic one. Read `references/content-guide.md` for section-by-section guidance, a worked example, and what separates useful content from generic padding, before writing.
|
||||
|
||||
## Step 4 — Check for an existing provider file
|
||||
|
||||
Look for `CLAUDE.md`, `.cursor/rules/*.mdc`, `.github/copilot-instructions.md`, or similar in the target repo. If one exists and now duplicates content the AGENTS.md you just wrote/updated already owns, invoke the `provider-adapter-author` skill on it to reconcile — don't rewrite it yourself.
|
||||
Look for `CLAUDE.md`, `.cursor/rules/*.mdc`, `.github/copilot-instructions.md`, or similar in the target repo. If one exists, invoke the `provider-adapter-author` skill on it to reconcile — whether it duplicates content the AGENTS.md you just wrote/updated now owns, or is merely stale or missing a pointer to it. Never edit it yourself in either case.
|
||||
|
||||
## Step 5 — Audit and report
|
||||
|
||||
Invoke the `agentsmd-audit` skill directly on the AGENTS.md file(s) you just wrote or updated. Resolve any FAIL findings before considering the work done — re-invoke this skill's own writing steps to fix them, then re-run the audit, same as any other close-the-loop check. Report what was created/changed, whether a provider file was reconciled, and the audit's final result.
|
||||
Invoke the `agentsmd-audit` skill on the target repo root — its validators take a `<repo-root>` and walk the tree for every AGENTS.md themselves; there is no per-file entry point. This closeout is mandatory, not optional, even when the change looks trivial — never sign the work off on your own judgment. Resolve any FAIL findings before considering the work done — re-invoke this skill's own writing steps to fix them, then re-run the audit, same as any other close-the-loop check. Report what was created/changed, whether a provider file was reconciled, and the audit's final result.
|
||||
|
||||
@@ -23,6 +23,7 @@ Provide the path to the provider-specific file to convert (and the target repo r
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | Skill instructions for agents |
|
||||
| `references/provider-matrix.md` | Loaded at Step 1 before searching, unless the target is already a known root `CLAUDE.md`: known files per provider, which ones resolve a cross-file import, the validator flag each needs, and the rule that a standalone run and a run composed into by `agentsmd-author` behave identically |
|
||||
| `references/sources.md` | Provenance record — the in-repo ADR precedent this skill's design is modeled on |
|
||||
| `scripts/validate-adapter.sh` | Self-check gate: reference to AGENTS.md present, no excessive duplication, adapter stays thin |
|
||||
| `scripts/README.md` | Directory documentation for `scripts/` |
|
||||
@@ -30,6 +31,6 @@ Provide the path to the provider-specific file to convert (and the target repo r
|
||||
| `tests/validate-adapter.bats` | (source-only) Bats test suite for `scripts/validate-adapter.sh` |
|
||||
|
||||
Rows marked **(source-only)** exist in the authoring source (`.apm/skills/provider-adapter-author/`)
|
||||
but are not present in an installed plugin: `scripts/sync-plugin-content.sh` strips
|
||||
but are not present in an installed plugin: the repo's `scripts/sync-plugin-content.sh` strips
|
||||
`<category>/<name>/tests` when it generates the flat mirror, because these are dev-time fixtures no
|
||||
plugin host needs to discover (ADR-0017). Run them from a repo checkout, not from an install.
|
||||
|
||||
@@ -1,43 +1,41 @@
|
||||
---
|
||||
name: provider-adapter-author
|
||||
description: >
|
||||
Use when the user wants to convert a provider-specific AI instruction file
|
||||
(CLAUDE.md, .cursor/rules/*.mdc, copilot-instructions.md, etc.) into a
|
||||
thin adapter that defers to a repo's AGENTS.md — e.g. "reduce duplication
|
||||
between CLAUDE.md and AGENTS.md", "make CLAUDE.md just import AGENTS.md"
|
||||
— even if the pattern isn't named explicitly. Also invoke when
|
||||
agentsmd-author detects an existing provider file overlapping with
|
||||
AGENTS.md it just wrote. Detects redundant content in a provider file
|
||||
relative to AGENTS.md and rewrites it down to a minimal reference (an
|
||||
`@AGENTS.md`-style import where supported, or a text pointer otherwise)
|
||||
plus genuinely provider-specific additions. Self-validates via a bundled
|
||||
deterministic script before finishing. Do not use to write or audit
|
||||
AGENTS.md itself — use agentsmd-author or agentsmd-audit.
|
||||
Use when a provider file (CLAUDE.md, .cursor rules, copilot-instructions)
|
||||
duplicating the repo's AGENTS.md should be cut to a thin adapter — "make
|
||||
CLAUDE.md just import AGENTS.md".
|
||||
Not writing the AGENTS file -> `agentsmd-author`.
|
||||
Not auditing the AGENTS file -> `agentsmd-audit`.
|
||||
allowed-tools: Bash Read Edit Write
|
||||
metadata:
|
||||
category: docs
|
||||
source_keys:
|
||||
- adr-0002-0003-two-tier-claude-md
|
||||
version: "0.1.0"
|
||||
version: "0.1.1"
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
|
||||
- Not every provider supports cross-file imports. Claude Code does — a `CLAUDE.md` can consist of nothing but one or more `@path` lines (e.g. `@AGENTS.md`), with no other content required. Cursor's `.cursor/rules/*.mdc` and GitHub Copilot's `copilot-instructions.md` have no native import mechanism as of current tooling — for those, "thin" means a short text pointer to AGENTS.md plus only what that tool actually needs, not a literal import line. Pass `--no-import-syntax` to `scripts/validate-adapter.sh` for these providers.
|
||||
- This skill never creates or edits `AGENTS.md` itself. If the target repo has no `AGENTS.md` yet, stop and point the user to `agentsmd-author` first — there's nothing to adapt to.
|
||||
- Only strip content from the provider file that's genuinely redundant with AGENTS.md. Provider-specific material (IDE settings, tool-only syntax, model-specific instructions) stays — the goal is thin, not empty.
|
||||
- Works standalone or composed-into by `agentsmd-author` — behave identically either way; don't assume a caller skill exists.
|
||||
- Assume a provider has no cross-file import mechanism until you have confirmed it has one. Claude Code is the exception, not the rule: a `CLAUDE.md` may consist of nothing but `@path` lines, while the same `@AGENTS.md` line in a Cursor rule or a Copilot instructions file is inert text no tool resolves. Pass `--no-import-syntax` to `scripts/validate-adapter.sh` for those providers.
|
||||
|
||||
- Works standalone or composed-into by `agentsmd-author` — behave identically either way; do not assume a caller skill exists. Detect the provider file, confirm `AGENTS.md`, and run the closeout validator yourself in both cases (`references/provider-matrix.md`).
|
||||
|
||||
## Step 1 — Detect
|
||||
|
||||
Look for known provider instruction files in the target repo: `CLAUDE.md` (repo root, and any deployed copies), `.cursor/rules/*.mdc`, `.github/copilot-instructions.md`, and similar tool-specific files. Confirm `AGENTS.md` exists at the repo root — if not, stop and tell the user to run `agentsmd-author` first.
|
||||
Find the provider instruction file to convert. Before searching, read `references/provider-matrix.md` — skip it only when the target is already a known root `CLAUDE.md`, which is the common case.
|
||||
|
||||
Then confirm `AGENTS.md` exists at the repo root. If it does not, stop and tell the user to run `agentsmd-author` first — there is nothing to adapt to.
|
||||
|
||||
## Step 2 — Diff and rewrite
|
||||
|
||||
Read the provider file and `AGENTS.md` side by side. Separate the provider file's content into two buckets: lines that restate what `AGENTS.md` already owns (universal rules, conventions, project overview) versus lines that are genuinely provider-specific (tool syntax, IDE behavior, model-specific instructions). Rewrite the provider file:
|
||||
|
||||
- **Providers with import syntax** (Claude Code): replace the redundant bucket with an `@AGENTS.md` (or correct relative path) import line, keep the provider-specific bucket below it.
|
||||
- **Providers without import syntax** (Cursor, Copilot, etc.): replace the redundant bucket with a short pointer sentence mentioning `AGENTS.md`, keep the provider-specific bucket.
|
||||
- **Providers with import syntax** (Claude Code): replace the redundant bucket with an `@AGENTS.md` (or correct relative path) import on a line of its own, keep the provider-specific bucket below it. An import folded into a sentence is not the thin-adapter shape and `scripts/validate-adapter.sh` will not credit it — nor one inside a code fence, an indented block, or an HTML comment, nor one whose path does not resolve to a real, non-empty file on disk.
|
||||
- **Providers without import syntax** (Cursor, Copilot, etc.): replace the redundant bucket with a short sentence pointing at `AGENTS.md` ("See AGENTS.md at the repo root for ..."), keep the provider-specific bucket. A bare or negated mention is not a pointer and will not be credited.
|
||||
|
||||
The provider file is the only file this skill ever writes. Never create or edit `AGENTS.md` — not in this step, not in any step, whatever the payoff looks like.
|
||||
|
||||
Strip only what is genuinely redundant. Provider-specific material stays even when it is short — the goal is thin, not empty.
|
||||
|
||||
## Step 3 — Self-validate
|
||||
|
||||
@@ -47,7 +45,7 @@ Run the bundled check before finishing — this is the skill's own closeout gate
|
||||
bash scripts/validate-adapter.sh [--no-import-syntax] [--max-lines N] <adapter-file> <agents-md-file>
|
||||
```
|
||||
|
||||
Fix any `FAIL` and re-run until it exits `0`.
|
||||
Fix any `FAIL` by editing the provider file, and re-run until it exits `0`. Exits `2` and `3` are not `FAIL`s and nothing was graded under either, so neither is a reason to touch the adapter: `2` means the invocation or the input is wrong (a bad, missing, or extra argument, an unknown option, or a file that is not UTF-8), and `3` means a named file exists but could not be read.
|
||||
|
||||
## Step 4 — Report
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
source_keys:
|
||||
- adr-0002-0003-two-tier-claude-md
|
||||
---
|
||||
|
||||
# Known provider instruction files
|
||||
|
||||
Which files to look for when detecting a provider-specific instruction file, whether each provider
|
||||
resolves a cross-file import, and what a thin adapter therefore looks like for it.
|
||||
|
||||
| Provider | File(s) | Import syntax | Thin adapter shape | Validator flag |
|
||||
|---|---|---|---|---|
|
||||
| Claude Code | `CLAUDE.md` at the repo root, plus any deployed copies | Yes — `@path` lines, e.g. `@AGENTS.md` | One or more `@` import lines; no other content is required | none |
|
||||
| Cursor | `.cursor/rules/*.mdc` | No | A short sentence pointing at `AGENTS.md`, plus the rule's own frontmatter and provider-specific body | `--no-import-syntax` |
|
||||
| GitHub Copilot | `.github/copilot-instructions.md` | No | A short sentence pointing at `AGENTS.md`, plus Copilot-only instructions | `--no-import-syntax` |
|
||||
| Anything else | tool-specific instruction file at whatever path the tool documents | Assume no | Text pointer, as above | `--no-import-syntax` |
|
||||
|
||||
A provider not listed here is not evidence it has an import mechanism. Confirm against that tool's
|
||||
own documentation before emitting an `@`-style line; an unresolved import reads as literal text and
|
||||
silently drops every rule the adapter was supposed to defer to.
|
||||
|
||||
Detection is a search, not a lookup: a repo may hold more than one of these, and each one converts
|
||||
independently against the same `AGENTS.md`.
|
||||
|
||||
## Standalone and composed runs behave identically
|
||||
|
||||
This skill is reached two ways: invoked directly by a user, and composed into by `agentsmd-author`
|
||||
once it has written or updated the repo's `AGENTS.md`. Behave identically either way — do not
|
||||
assume a caller skill exists. Detect the provider file yourself, confirm `AGENTS.md` yourself, and
|
||||
run the closeout validator yourself, rather than treating any step as already done by the caller or
|
||||
as something the caller will do afterwards. No handshake exists to rely on, and no state is
|
||||
passed in beyond the file paths.
|
||||
@@ -5,5 +5,5 @@
|
||||
- **URL:** (in-repo precedent — not an external source or plugin research corpus entry)
|
||||
- **Description:** This repo's own two-tier CLAUDE.md/AGENTS.md pattern: AGENTS.md is the provider-agnostic source of always-on rules; provider-specific files (CLAUDE.md) become thin adapters that import it (`@AGENTS.md` plus provider-specific additions). Grounds this skill's entire adapter-conversion design — the "thin adapter" shape, the `@`-import convention, and the size/duplication expectations enforced by `scripts/validate-adapter.sh`.
|
||||
- **Research doc:** docs/adr/0002-two-tier-claude-md.md, docs/adr/0003-agents-md-provider-agnostic-entry-point.md, providers/claude-code/CLAUDE.md (in-repo ADRs and a live example, not a plugin research corpus entry; referenced here since this skill's design is modeled directly on an existing implementation rather than external research)
|
||||
- **Contributing files:** SKILL.md
|
||||
- **Contributing files:** SKILL.md, references/provider-matrix.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
@@ -4,6 +4,25 @@ Deterministic self-check this skill shells out to instead of relying on LLM judg
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `validate-adapter.sh` | Checks a rewritten provider file (CLAUDE.md, etc.) has a reference to AGENTS.md, doesn't duplicate its content, and stays under a thin-file line threshold |
|
||||
| `validate-adapter.sh` | Checks a rewritten provider file (CLAUDE.md, etc.) has a working reference to AGENTS.md, doesn't duplicate its content, and stays under a thin-file line threshold |
|
||||
|
||||
Takes `<adapter-file> <agents-md-file>`, with optional `--no-import-syntax` and `--max-lines N` flags. Prints `FAIL` findings to stdout and exits non-zero on any failure.
|
||||
Takes exactly `<adapter-file> <agents-md-file>`, with optional `--no-import-syntax` and `--max-lines N` flags (also accepted as `--max-lines=N`). A third positional argument or an unknown option is an error, not something quietly ignored.
|
||||
|
||||
## What counts as a reference to AGENTS.md
|
||||
|
||||
Both modes require the named path to be a real path segment ending in `AGENTS.md` — `AGENTS.md` or `…/AGENTS.md`, not `NOTAGENTS.md` — that resolves on disk, relative to the adapter file, to a non-empty file. An adapter deferring to a path that is not there defers to nothing, so the check has to touch the disk rather than pattern-match the line.
|
||||
|
||||
A reference only counts where something would actually resolve it. A line inside a fenced code block, an indented code block, or an HTML comment is not credited in either mode: Claude Code resolves an import in none of those, so a fenced `@AGENTS.md` is the silent-drop failure this gate exists to catch, not a pass.
|
||||
|
||||
Default mode wants a real import: `@AGENTS.md` alone on its own line, indented no more than three spaces. `--no-import-syntax` wants a prose pointer that reads as one — the sentence naming `AGENTS.md` must carry a deference cue (see, read, refer to, documented in, conventions, …) and must not be negated. `Do NOT read AGENTS.md; it is obsolete.` and `We deleted AGENTS.md last year.` name the file while pointing the reader away from it, and neither is a pointer.
|
||||
|
||||
## Exit codes
|
||||
|
||||
The distinction matters because the skill's closeout tells the agent to fix any non-zero exit by editing the provider file. That is right for exactly one of these.
|
||||
|
||||
| Code | Meaning | What to do |
|
||||
|------|---------|------------|
|
||||
| `0` | Passes every check | Nothing |
|
||||
| `1` | One or more `FAIL` findings printed to stdout — empty adapter, no working reference to AGENTS.md, excessive duplication, or not thin | Edit the provider file |
|
||||
| `2` | Usage or input error: a bad, missing, or extra argument, an unknown option, a path that is not a file, or a file that is not UTF-8. Nothing was graded, so there is no `FAIL` line | Fix the invocation or the file's encoding — do not edit the adapter |
|
||||
| `3` | A named input file exists but could not be read (permissions, I/O error). Nothing was graded and the adapter's contents are unknown | Fix the file's readability — do not edit the adapter |
|
||||
|
||||
@@ -14,27 +14,85 @@ Arguments:
|
||||
adapter-file Path to the provider-specific file to check.
|
||||
agents-md-file Path to the AGENTS.md file it should defer to.
|
||||
|
||||
Exactly two positional arguments are accepted. Extra ones are rejected
|
||||
rather than ignored: a third path silently graded nothing but the first
|
||||
two, so a typo'd invocation passed against the wrong file.
|
||||
|
||||
Options:
|
||||
--no-import-syntax The target provider has no native cross-file import
|
||||
mechanism. Accept a plain-text pointer mention of
|
||||
"AGENTS.md" instead of requiring an @import-style line.
|
||||
mechanism. Require a plain-text pointer line naming
|
||||
"AGENTS.md" instead of an @import-style line; an
|
||||
@AGENTS.md line alone does not satisfy it, because
|
||||
such a provider never resolves it. Without this flag
|
||||
an actual @import line is required, and naming
|
||||
AGENTS.md in prose alone does not satisfy it.
|
||||
--max-lines N Max non-blank lines allowed in the adapter file before
|
||||
it's considered no longer "thin". Default: 60.
|
||||
it's considered no longer "thin". Must be a
|
||||
non-negative integer. Default: 60.
|
||||
--help, -h Show this help and exit 0.
|
||||
-- End of options; every later argument is positional.
|
||||
|
||||
Both flags also accept the --flag=value form (--max-lines=40). An unknown
|
||||
option is reported as an unknown option, not as a missing file.
|
||||
|
||||
What counts as a reference:
|
||||
|
||||
In both modes the named path must be a real path segment ending in
|
||||
AGENTS.md ("AGENTS.md" or ".../AGENTS.md" — not NOTAGENTS.md), and it must
|
||||
resolve on disk, relative to the adapter file, to a non-empty file. An
|
||||
adapter deferring to a path that is not there defers to nothing.
|
||||
|
||||
A mention inside a fenced code block, an indented code block, or an HTML
|
||||
comment is not credited in either mode. Nothing resolves those, so an
|
||||
adapter whose only "import" is fenced silently defers to nothing.
|
||||
|
||||
With --no-import-syntax the pointer must read as a pointer: the sentence
|
||||
naming AGENTS.md has to carry a deference cue (see, read, refer to,
|
||||
documented in, conventions, ...) and must not be a negation ("do not read
|
||||
AGENTS.md", "we deleted AGENTS.md"). A bare mention is not a pointer.
|
||||
|
||||
Exit codes:
|
||||
0 Adapter file passes all checks
|
||||
1 One or more checks failed (empty file, no reference to AGENTS.md,
|
||||
excessive duplication, or file too long)
|
||||
2 Usage or input error — a bad, missing, or extra argument, an unknown
|
||||
option, a path that is not a file, or a file that is not UTF-8. Nothing
|
||||
was graded, so there is no FAIL line and no adapter edit to make: fix
|
||||
the invocation or the file's encoding and re-run. Kept distinct from 1
|
||||
because the skill's own closeout tells the agent to fix every non-zero
|
||||
exit by editing the provider file, which for a mistyped flag edits the
|
||||
wrong file forever.
|
||||
3 A named input file exists but could not be read (permissions, a
|
||||
directory swapped in mid-run, I/O error). Also not a FAIL: nothing was
|
||||
graded and the adapter's contents are unknown, so editing it is
|
||||
guesswork. Fix the file's readability and re-run.
|
||||
EOF
|
||||
}
|
||||
|
||||
NO_IMPORT_SYNTAX=0
|
||||
MAX_LINES=60
|
||||
ARGS=()
|
||||
END_OF_OPTS=0
|
||||
|
||||
require_int() {
|
||||
# $1 = the value to validate
|
||||
if [[ ! "$1" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: --max-lines expects a non-negative integer, got '$1'." >&2
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $END_OF_OPTS -eq 1 ]]; then
|
||||
ARGS+=("$1")
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
case "$1" in
|
||||
--)
|
||||
END_OF_OPTS=1
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
usage
|
||||
exit 0
|
||||
@@ -43,10 +101,38 @@ while [[ $# -gt 0 ]]; do
|
||||
NO_IMPORT_SYNTAX=1
|
||||
shift
|
||||
;;
|
||||
--no-import-syntax=*)
|
||||
echo "Error: --no-import-syntax is a flag and takes no value (got '$1')." >&2
|
||||
exit 2
|
||||
;;
|
||||
--max-lines)
|
||||
MAX_LINES="${2:-}"
|
||||
if [[ $# -lt 2 ]]; then
|
||||
echo "Error: --max-lines requires a value (a non-negative integer)." >&2
|
||||
exit 2
|
||||
fi
|
||||
MAX_LINES="$2"
|
||||
require_int "$MAX_LINES"
|
||||
shift 2
|
||||
;;
|
||||
--max-lines=*)
|
||||
MAX_LINES="${1#--max-lines=}"
|
||||
if [[ -z "$MAX_LINES" ]]; then
|
||||
echo "Error: --max-lines requires a value (a non-negative integer)." >&2
|
||||
exit 2
|
||||
fi
|
||||
require_int "$MAX_LINES"
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
# Reported as an unknown option rather than falling through to the
|
||||
# positional bucket, where it used to surface as "'--bogus' is not a
|
||||
# file" — the right exit code attached to a diagnostic that sends the
|
||||
# reader looking for a path they never typed.
|
||||
echo "Error: unknown option '$1'." >&2
|
||||
echo "" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
ARGS+=("$1")
|
||||
shift
|
||||
@@ -58,7 +144,14 @@ if [[ ${#ARGS[@]} -lt 2 ]]; then
|
||||
echo "Error: adapter-file and agents-md-file are required." >&2
|
||||
echo "" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ ${#ARGS[@]} -gt 2 ]]; then
|
||||
echo "Error: expected exactly 2 positional arguments (adapter-file and agents-md-file), got ${#ARGS[@]}: ${ARGS[*]}." >&2
|
||||
echo "" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
python3 -u - "${ARGS[0]}" "${ARGS[1]}" "$NO_IMPORT_SYNTAX" "$MAX_LINES" <<'PYTHON'
|
||||
@@ -70,17 +163,80 @@ adapter_path, agents_md_path, no_import_syntax, max_lines = sys.argv[1:5]
|
||||
no_import_syntax = no_import_syntax == "1"
|
||||
max_lines = int(max_lines)
|
||||
|
||||
EXIT_FAIL = 1
|
||||
EXIT_USAGE = 2
|
||||
EXIT_UNREADABLE = 3
|
||||
|
||||
if not os.path.isfile(adapter_path):
|
||||
print(f"Error: '{adapter_path}' is not a file.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
sys.exit(EXIT_USAGE)
|
||||
if not os.path.isfile(agents_md_path):
|
||||
print(f"Error: '{agents_md_path}' is not a file.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
sys.exit(EXIT_USAGE)
|
||||
|
||||
with open(adapter_path, encoding="utf-8", errors="replace") as f:
|
||||
adapter_content = f.read()
|
||||
with open(agents_md_path, encoding="utf-8", errors="replace") as f:
|
||||
agents_md_content = f.read()
|
||||
|
||||
def read_text(path):
|
||||
r"""File contents as text, UTF-8, every BOM stripped.
|
||||
|
||||
The BOM strip is not cosmetic. IMPORT_RE anchors on `^ {0,3}@`, and a BOM
|
||||
is not whitespace in Python, so a CLAUDE.md saved by an editor that emits
|
||||
one had its first line — the `@AGENTS.md` import, which is the whole
|
||||
adapter — silently treated as prose. The check then said "no reference to
|
||||
AGENTS.md" and told the author to add the line already sitting in front of
|
||||
them. Same class of silent BOM miss recorded in scripts/skill-size-check.sh;
|
||||
strip it at the reader so no later check has to know about it.
|
||||
|
||||
Every U+FEFF goes, not just one at offset 0. Stripping exactly the first
|
||||
one left the mirror-image false FAIL for a doubled BOM (two concatenated
|
||||
files, or a tool that re-adds one) and for a BOM mid-file at the head of
|
||||
the import line. U+FEFF has no meaning as a character in a markdown
|
||||
instruction file, so removing all of them cannot lose signal.
|
||||
|
||||
Decoding is strict, not errors="replace". Replacement mangles the file and
|
||||
the checks then grade the mangling: a UTF-16 adapter whose first line is
|
||||
`@AGENTS.md` decoded to interleaved NULs and failed as "no reference",
|
||||
which is a true FAIL for a false reason and points the fix at the wrong
|
||||
thing. But strict UTF-8 alone does not catch it — BOM-less UTF-16LE/BE and
|
||||
UTF-32LE are *valid* UTF-8, because NUL is a legal code point, so they
|
||||
decoded clean and produced exactly that false diagnosis anyway. The NUL
|
||||
byte is the complete signal and is checked first: no plausible markdown
|
||||
adapter contains one, and every UTF-16/32 encoding of ASCII is full of
|
||||
them. A file this gate cannot read gets an encoding diagnostic and exit 2,
|
||||
the same policy the ADR-0020 validators' read_text() uses.
|
||||
|
||||
A file that exists but cannot be read at all is neither a pass nor a FAIL —
|
||||
nothing was graded — so it exits 3 rather than 1. Exit 1 sends the skill's
|
||||
closeout into "fix the FAIL by editing the provider file", which for a file
|
||||
it cannot open is an instruction to edit blind.
|
||||
"""
|
||||
try:
|
||||
with open(path, "rb") as fh:
|
||||
raw = fh.read()
|
||||
except OSError as exc:
|
||||
print(f"Error: '{path}' exists but could not be read ({exc.strerror}). "
|
||||
"Nothing was checked — fix whatever is blocking the read "
|
||||
"(permissions, ownership, the underlying device) and re-run; do "
|
||||
"not edit the adapter on the strength of this.", file=sys.stderr)
|
||||
sys.exit(EXIT_UNREADABLE)
|
||||
if b"\x00" in raw:
|
||||
print(f"Error: '{path}' is not valid UTF-8 — it contains NUL bytes, so "
|
||||
"it is almost certainly UTF-16 or UTF-32 (with or without a BOM). "
|
||||
"Re-save it as UTF-8; this check does not guess at other "
|
||||
"encodings.", file=sys.stderr)
|
||||
sys.exit(EXIT_USAGE)
|
||||
try:
|
||||
text = raw.decode("utf-8")
|
||||
except UnicodeDecodeError as exc:
|
||||
print(f"Error: '{path}' is not valid UTF-8 ({exc.reason} at byte "
|
||||
f"{exc.start}) — re-save it as UTF-8; this check does not guess "
|
||||
"at other encodings.", file=sys.stderr)
|
||||
sys.exit(EXIT_USAGE)
|
||||
return text.replace("\ufeff", "")
|
||||
|
||||
|
||||
adapter_content = read_text(adapter_path)
|
||||
agents_md_content = read_text(agents_md_path)
|
||||
adapter_dir = os.path.dirname(os.path.abspath(adapter_path))
|
||||
|
||||
has_fail = False
|
||||
|
||||
@@ -89,30 +245,229 @@ if not adapter_content.strip():
|
||||
print(" Why: An empty adapter carries no reference to AGENTS.md and no provider-specific content.")
|
||||
print(" Fix: Add at least an import (or text pointer) to AGENTS.md.")
|
||||
print()
|
||||
sys.exit(1)
|
||||
sys.exit(EXIT_FAIL)
|
||||
|
||||
IMPORT_RE = re.compile(r'(?m)^\s*@\S*AGENTS\.md\s*$')
|
||||
lines = adapter_content.splitlines()
|
||||
import_lines = [ln for ln in lines if IMPORT_RE.match(ln)]
|
||||
|
||||
# --- Inert regions -----------------------------------------------------------
|
||||
#
|
||||
# A reference only counts where something would actually resolve it. Fenced
|
||||
# code blocks, indented code blocks and HTML comments are shown to the reader
|
||||
# (or hidden from them) as literal text; Claude Code resolves an @import in
|
||||
# none of them. Without this, a ```-fenced `@AGENTS.md` — the exact
|
||||
# copy-the-example-into-the-file mistake this gate exists to catch — exited 0
|
||||
# with the adapter deferring to nothing.
|
||||
#
|
||||
# Indented code blocks are handled by IMPORT_RE's `^ {0,3}` instead of by the
|
||||
# mask: four leading spaces is what opens an indented code block in CommonMark,
|
||||
# so an import has to sit within three. The mask deliberately does not apply
|
||||
# that rule to prose pointers, where four-space indentation is ordinary list
|
||||
# continuation rather than code.
|
||||
FENCE_RE = re.compile(r'^( {0,3})(`{3,}|~{3,})(.*)$')
|
||||
COMMENT_RE = re.compile(r'<!--.*?(?:-->|\Z)', re.DOTALL)
|
||||
|
||||
|
||||
def line_offsets(text):
|
||||
"""[(char offset, line without its terminator)] over `text`."""
|
||||
out = []
|
||||
off = 0
|
||||
for raw in text.splitlines(keepends=True):
|
||||
out.append((off, raw.rstrip("\r\n")))
|
||||
off += len(raw)
|
||||
return out
|
||||
|
||||
|
||||
def build_inert_mask(text, offsets):
|
||||
"""Per-character flags: 1 where a reference would never be resolved."""
|
||||
mask = bytearray(len(text))
|
||||
fence = None # (fence char, opening run length)
|
||||
for start, line in offsets:
|
||||
m = FENCE_RE.match(line)
|
||||
if fence is None:
|
||||
if m:
|
||||
fence = (m.group(2)[0], len(m.group(2)))
|
||||
for i in range(start, start + len(line)):
|
||||
mask[i] = 1
|
||||
continue
|
||||
for i in range(start, start + len(line)):
|
||||
mask[i] = 1
|
||||
if (m and m.group(2)[0] == fence[0]
|
||||
and len(m.group(2)) >= fence[1]
|
||||
and not m.group(3).strip()):
|
||||
fence = None
|
||||
for m in COMMENT_RE.finditer(text):
|
||||
if m.start() < len(mask) and mask[m.start()]:
|
||||
continue # a literal "<!--" printed inside a fence opens nothing
|
||||
for i in range(m.start(), min(m.end(), len(mask))):
|
||||
mask[i] = 1
|
||||
return mask
|
||||
|
||||
|
||||
# --- Reference shapes --------------------------------------------------------
|
||||
#
|
||||
# `\S*AGENTS\.md` had no path-separator boundary, so `@NOTAGENTS.md` and
|
||||
# `@zzzAGENTS.md` counted as imports of AGENTS.md. The matched path must end in
|
||||
# AGENTS.md as a whole segment.
|
||||
IMPORT_RE = re.compile(r'^ {0,3}@(?P<path>\S+?)\s*$')
|
||||
# A mention in prose: an optional relative path, then AGENTS.md, with no
|
||||
# identifier character glued to the front (so NOTAGENTS.md does not match) and
|
||||
# nothing glued to the back.
|
||||
MENTION_RE = re.compile(r'(?<![0-9A-Za-z_.\-/])((?:[\w.\-~]+/)*AGENTS\.md)(?![0-9A-Za-z])')
|
||||
|
||||
# A pointer has to read as a pointer. `"AGENTS.md" in ln` passed
|
||||
# "Do NOT read AGENTS.md; it is obsolete." and "We deleted AGENTS.md last
|
||||
# year." — both of which point the reader away from the file. Require a
|
||||
# deference cue in the naming sentence, and reject a negated one.
|
||||
DIRECTIVE_RE = re.compile(
|
||||
r'\b(see|read|refer|refers|referring|consult|consults|follow|follows|'
|
||||
r'defer|defers|deferring|described|documented|documents|covered|covers|'
|
||||
r'found|listed|specified|defined|governed|per|use|uses|using|apply|obey|'
|
||||
r'start|check|live|lives|contains|holds|carries|inherit|inherits|import|'
|
||||
r'imports|conventions|instructions|guidelines|guidance|rules|standards|'
|
||||
r'reference|setup)\b', re.I)
|
||||
NEGATION_RE = re.compile(
|
||||
r"(\bnot\b|n't\b|\bnever\b|\bno longer\b|\bdeleted\b|\bremoved\b|"
|
||||
r"\bobsolete\b|\bdeprecated\b|\bignore\b|\bignores\b|\bignoring\b|"
|
||||
r"\bdisregard\b|\bsuperseded\b|\bgone\b|\bunused\b|\bstale\b)", re.I)
|
||||
SENTENCE_SPLIT_RE = re.compile(r'(?<=[.;:!?])\s+')
|
||||
|
||||
|
||||
def sentence_around(line, index):
|
||||
"""(sentence of `line` containing character `index`, its start offset)."""
|
||||
bounds = [0]
|
||||
for m in SENTENCE_SPLIT_RE.finditer(line):
|
||||
bounds.append(m.end())
|
||||
bounds.append(len(line) + 1)
|
||||
for i in range(len(bounds) - 1):
|
||||
if bounds[i] <= index < bounds[i + 1]:
|
||||
return line[bounds[i]:bounds[i + 1]], bounds[i]
|
||||
return line, 0
|
||||
|
||||
|
||||
def reads_as_pointer(line, match):
|
||||
"""Does the sentence naming AGENTS.md actually point the reader at it?
|
||||
|
||||
The matched path is blanked out before the cues are applied. It is a
|
||||
filename, not prose, and leaving it in let its own characters vote: the
|
||||
perfectly ordinary `docs/does/not/exist/AGENTS.md` tripped the negation
|
||||
cue on the `not` path segment, so a pointer got rejected for the wrong
|
||||
reason and the near-miss line then reported the wrong diagnosis.
|
||||
"""
|
||||
sentence, sentence_start = sentence_around(line, match.start())
|
||||
rel_start = match.start() - sentence_start
|
||||
rel_end = match.end() - sentence_start
|
||||
probe = sentence[:rel_start] + " AGENTS.md " + sentence[rel_end:]
|
||||
if NEGATION_RE.search(probe):
|
||||
return False
|
||||
return bool(DIRECTIVE_RE.search(probe))
|
||||
|
||||
|
||||
def resolve(raw_path):
|
||||
"""An import/pointer path resolved the way the provider would resolve it."""
|
||||
p = os.path.expanduser(raw_path)
|
||||
if not os.path.isabs(p):
|
||||
p = os.path.join(adapter_dir, p)
|
||||
return os.path.normpath(p)
|
||||
|
||||
|
||||
def target_problem(raw_path):
|
||||
"""None if `raw_path` names a real, non-empty file; else why not."""
|
||||
resolved = resolve(raw_path)
|
||||
if not os.path.isfile(resolved):
|
||||
return f"'{raw_path}' resolves to {resolved}, which does not exist"
|
||||
try:
|
||||
if os.path.getsize(resolved) == 0:
|
||||
return f"'{raw_path}' resolves to {resolved}, which is empty"
|
||||
with open(resolved, "rb") as fh:
|
||||
if not fh.read().strip():
|
||||
return f"'{raw_path}' resolves to {resolved}, which is blank"
|
||||
except OSError as exc:
|
||||
return f"'{raw_path}' resolves to {resolved}, which cannot be read ({exc.strerror})"
|
||||
return None
|
||||
|
||||
|
||||
def names_agents_md(path):
|
||||
return path == "AGENTS.md" or path.endswith("/AGENTS.md")
|
||||
|
||||
|
||||
offsets = line_offsets(adapter_content)
|
||||
lines = [line for _, line in offsets]
|
||||
mask = build_inert_mask(adapter_content, offsets)
|
||||
|
||||
|
||||
def is_inert(abs_index):
|
||||
return abs_index < len(mask) and bool(mask[abs_index])
|
||||
|
||||
|
||||
# Lines shaped like an @AGENTS.md import, whether or not the target resolves.
|
||||
# Used to exclude them from the duplication denominator and from the prose
|
||||
# pointer scan, both of which only care about the shape.
|
||||
import_shaped_lines = set()
|
||||
# (line, raw path) for every import whose target actually resolves.
|
||||
live_imports = []
|
||||
# Diagnostics for imports that are the right shape but resolve to nothing.
|
||||
dead_imports = []
|
||||
# Imports that exist only inside a fence or an HTML comment.
|
||||
inert_imports = []
|
||||
|
||||
for start, line in offsets:
|
||||
m = IMPORT_RE.match(line)
|
||||
if not m or not names_agents_md(m.group("path")):
|
||||
continue
|
||||
at_index = start + line.index("@")
|
||||
if is_inert(at_index):
|
||||
inert_imports.append(line.strip())
|
||||
continue
|
||||
import_shaped_lines.add(line)
|
||||
problem = target_problem(m.group("path"))
|
||||
if problem:
|
||||
dead_imports.append(problem)
|
||||
else:
|
||||
live_imports.append(line)
|
||||
|
||||
live_pointers = []
|
||||
dead_pointers = []
|
||||
inert_pointers = []
|
||||
mention_only = []
|
||||
|
||||
for start, line in offsets:
|
||||
if line in import_shaped_lines:
|
||||
continue
|
||||
for m in MENTION_RE.finditer(line):
|
||||
if is_inert(start + m.start()):
|
||||
inert_pointers.append(line.strip())
|
||||
continue
|
||||
if not reads_as_pointer(line, m):
|
||||
mention_only.append(sentence_around(line, m.start())[0].strip())
|
||||
continue
|
||||
problem = target_problem(m.group(1))
|
||||
if problem:
|
||||
dead_pointers.append(problem)
|
||||
else:
|
||||
live_pointers.append(line)
|
||||
|
||||
if no_import_syntax:
|
||||
has_reference = "AGENTS.md" in adapter_content
|
||||
has_reference = bool(live_pointers)
|
||||
near_misses = dead_pointers + [f"{d} (inside a code fence or HTML comment)" for d in inert_pointers]
|
||||
near_misses += [f"'{s}' names AGENTS.md but does not point at it" for s in mention_only]
|
||||
else:
|
||||
has_reference = bool(import_lines) or "AGENTS.md" in adapter_content
|
||||
has_reference = bool(live_imports)
|
||||
near_misses = dead_imports + [f"'{d}' is inside a code fence or HTML comment, where no import is resolved" for d in inert_imports]
|
||||
|
||||
if not has_reference:
|
||||
has_fail = True
|
||||
print(f"FAIL Adapter has no reference to AGENTS.md — {adapter_path}")
|
||||
if no_import_syntax:
|
||||
print(" Why: This provider has no import syntax, so the adapter must at least mention AGENTS.md as a text pointer.")
|
||||
print(" Fix: Add a sentence like \"See AGENTS.md at the repo root for shared conventions.\"")
|
||||
print(" Why: This provider resolves no cross-file import, so the adapter must point at AGENTS.md in prose; an `@AGENTS.md` line here is inert text. The pointer has to read as a pointer and name a file that is really there — a bare or negated mention (\"we deleted AGENTS.md\") defers nothing, and neither does a mention buried in a code fence or an HTML comment.")
|
||||
print(" Fix: Add a sentence like \"See AGENTS.md at the repo root for shared conventions.\", outside any fence, naming a path that exists relative to this file.")
|
||||
else:
|
||||
print(" Why: A thin adapter must import AGENTS.md (e.g. `@AGENTS.md`) rather than silently omitting it.")
|
||||
print(" Fix: Add an `@AGENTS.md` (or equivalent relative path) import line.")
|
||||
print(" Why: A thin adapter must import AGENTS.md with an `@AGENTS.md` line of its own, indented no more than three spaces, and the path must resolve to a real non-empty file. Naming the file mid-sentence or inside backticks is prose this check will not credit; putting the line inside a ``` fence, an indented code block, or an HTML comment is worse, because nothing resolves it and it looks right.")
|
||||
print(" Fix: Put `@AGENTS.md` (or the equivalent relative path) alone on its own line at the top level of the file, or pass --no-import-syntax if this provider resolves no imports.")
|
||||
for miss in near_misses:
|
||||
print(f" Near miss: {miss}")
|
||||
print()
|
||||
|
||||
# --- Duplication check ---
|
||||
non_import_lines = [ln for ln in lines if not IMPORT_RE.match(ln)]
|
||||
non_import_lines = [ln for ln in lines if ln not in import_shaped_lines]
|
||||
adapter_lines = [ln.strip() for ln in non_import_lines if ln.strip()]
|
||||
agents_lines = {ln.strip() for ln in agents_md_content.splitlines() if ln.strip()}
|
||||
|
||||
@@ -132,10 +487,10 @@ if non_blank_count > max_lines:
|
||||
has_fail = True
|
||||
print(f"FAIL Adapter is not thin — {adapter_path}")
|
||||
print(f" Why: {non_blank_count} non-blank lines exceeds the {max_lines}-line threshold for a thin adapter.")
|
||||
print(" Fix: Move provider-agnostic content into AGENTS.md; keep only genuinely provider-specific additions here.")
|
||||
print(" Fix: Delete the lines already covered by AGENTS.md; keep only genuinely provider-specific additions here.")
|
||||
print()
|
||||
|
||||
if has_fail:
|
||||
sys.exit(1)
|
||||
sys.exit(EXIT_FAIL)
|
||||
sys.exit(0)
|
||||
PYTHON
|
||||
|
||||
@@ -16,7 +16,7 @@ You are the orchestrator for the git plugin—a composable workflow dispatcher d
|
||||
|
||||
You act on the caller's real branch and session context (you explicitly carry forward `current_branch`), not a disposable copy — you do not run in an isolated worktree.
|
||||
|
||||
**Scope:** this orchestrator routes git-object operations only (commits, branches, worktrees, remotes, submodules, history). `pc-author` and `pc-run` (pre-commit config authoring and hook execution) are intentionally not routed here — they operate on `.pre-commit-config.yaml` and hook installation, not git objects. `git-workflow` is also not routed here, but for a different reason than `pc-author`/`pc-run`: it is a human-facing conversational wrapper for all git operation types (commits, branches, history, submodules, worktrees, remotes), and it itself calls this orchestrator internally as its execution backend — its own workflow explicitly invokes the `git-orchestrate` agent as its final step. It is not a peer to invoke instead of this dispatcher, and it explicitly refuses agent callers ("Do not use when the caller is an agent"). Agent callers route git-object operations here directly; direct human users to `git-workflow` when they want guided, conversational git help — it will call back into this orchestrator itself. Invoke `pc-author`/`pc-run` directly rather than through this dispatcher; do not invoke `git-workflow` as an agent caller under any circumstance.
|
||||
**Scope:** this orchestrator routes git-object operations only (commits, branches, worktrees, remotes, submodules, history). `pc-author` and `pc-run` (pre-commit config authoring and hook execution) are intentionally not routed here — they operate on `.pre-commit-config.yaml` and hook installation, not git objects. `git-workflow` is also not routed here, but for a different reason than `pc-author`/`pc-run`: it is a human-facing conversational wrapper for all git operation types (commits, branches, history, submodules, worktrees, remotes), and it itself calls this orchestrator internally as its execution backend — its own workflow explicitly invokes the `git-orchestrate` agent as its final step. It is not a peer to invoke instead of this dispatcher, and its own boundary clause sends agent callers here ("Not an agent caller -> `git-orchestrate`"). Agent callers route git-object operations here directly; direct human users to `git-workflow` when they want guided, conversational git help — it will call back into this orchestrator itself. Invoke `pc-author`/`pc-run` directly rather than through this dispatcher; do not invoke `git-workflow` as an agent caller under any circumstance.
|
||||
|
||||
## Hard rules
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# git-branches
|
||||
|
||||
Manage the full lifecycle of git branches — create, switch, delete, rename, and track feature/hotfix/release branches under GitHub Flow or Gitflow.
|
||||
Manage the full lifecycle of git branches — create, switch, delete, rename, track, merge, and compare feature/hotfix/release branches under GitHub Flow or Gitflow.
|
||||
|
||||
## What it does
|
||||
|
||||
@@ -12,11 +12,23 @@ This skill handles branch operations within the git workflow suite. It creates b
|
||||
/git-branches
|
||||
```
|
||||
|
||||
Describe your branch task: create a feature/hotfix/release branch, switch, delete, rename, or track. The skill will determine the branching pattern (GitHub Flow or Gitflow) from config or repo state and handle safety checks for destructive operations.
|
||||
Describe your branch task: create a feature/hotfix/release branch, switch, delete, rename, track, merge, or compare two branches. The skill will determine the branching pattern (GitHub Flow or Gitflow) from config or repo state and handle safety checks for destructive operations.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | Skill instructions for agents |
|
||||
| `references/branch-patterns.md` | Loaded when a branch's base, name prefix, or merge rule depends on GitHub Flow vs. Gitflow |
|
||||
| `references/branch-operations.md` | Loaded when running a create/switch/delete/rename/track/list/stash action, or resolving `get-intent` |
|
||||
| `references/merging.md` | Loaded when merging one branch into another or resolving merge conflicts |
|
||||
| `references/comparing-branches.md` | Loaded when comparing two branches or finding where they diverged |
|
||||
| `references/orchestrator-contract.md` | Loaded when `git-orchestrate` or another calling agent supplies a structured request rather than prose |
|
||||
| `references/sources.md` | Research sources backing the branching/gitflow guidance |
|
||||
|
||||
## Composition
|
||||
|
||||
`git-orchestrate` calls this skill for the branch step of a multi-step workflow and parses its
|
||||
structured result. Revert is `git-history`'s; commit authoring, rebase, reset and cherry-pick are
|
||||
`git-commits`'; deleting a remote branch is `git-remotes`'; branch operations against a
|
||||
Gitea-hosted remote are `gitea-branches`'.
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
name: git-branches
|
||||
|
||||
description: >
|
||||
Use when managing the full lifecycle of git branches: create feature/hotfix/release branches
|
||||
(gitflow, GitHub Flow, or custom patterns from config), switch, delete, rename, and track branches,
|
||||
or retrieve branch intent metadata. Handles branch protection safety checks and returns structured
|
||||
results for agent composition. Use even if the user doesn't explicitly mention branch names — they
|
||||
may be asking about "fixing something" or "shipping a feature", which implicitly requires branch
|
||||
management. Do not use when the user needs only commit operations (use git-commits) or history
|
||||
inspection (use git-history).
|
||||
Use when creating, switching, deleting, renaming, tracking, merging, or comparing
|
||||
local git branches under GitHub Flow or Gitflow.
|
||||
Not writing or rewriting commits -> `git-commits`.
|
||||
Not history inspection -> `git-history`.
|
||||
Not a Gitea remote's branches -> `gitea-branches`.
|
||||
|
||||
metadata:
|
||||
category: git
|
||||
@@ -21,92 +19,57 @@ metadata:
|
||||
|
||||
## Gotchas
|
||||
|
||||
- **Branches are cheap; deletion is cheap but risky.** Deleting one requires checking if commits on it are reachable elsewhere; always confirm before deleting, as it may lose unmerged work.
|
||||
- **Uncommitted changes can block branch switches.** `git switch` aborts if local modifications conflict with the target branch. Offer to stash changes before switching when this happens, don't force a checkout.
|
||||
- **Tracking relationships matter for coordination.** Agents pushing on behalf of users should always set tracking (`-u origin <branch>`) so later pushes/pulls know the target. Without it, commands fail or target the wrong remote branch.
|
||||
- **Gitflow vs. GitHub Flow are not compatible.** Gitflow requires `develop` and `release/*` branches with `--no-ff` merges; GitHub Flow uses only `main` and feature branches with fast-forward. Read the repo's config or ask the orchestrator which pattern to use — don't guess.
|
||||
- **Naming collisions with tags.** A branch and tag can have the same name. Prefer `git switch` over `git checkout` for branch operations — verify which ref you're targeting with `git branch --list <name>` / `git tag --list <name>` if the name could be ambiguous, and disambiguate explicitly with `refs/heads/<name>` (branch) or `refs/tags/<name>` (tag) where a command accepts either.
|
||||
- **Never force-push `main` or `master`.** This is a hard refusal, not a confirmation gate — it applies even if the caller passes `confirm: true`. Deleting or renaming `main`/`master` in a way that would require a force-push to reconcile the remote (e.g. force-deleting and recreating it, or renaming it out from under in-flight work) must be rejected outright; explain why and suggest a non-destructive alternative (e.g. a new branch) instead of proceeding.
|
||||
- **Uncommitted changes abort a switch.** `git switch` refuses rather than clobbering conflicting local edits. Offer to stash and retry — forcing the checkout past it is how work disappears.
|
||||
- **A branch and a tag can carry the same name.** Detect it before acting — `git branch --list <name>` and `git tag --list <name>`; output from both means the name is ambiguous. Prefer `git switch` over `git checkout`, and where a command accepts either ref, disambiguate with `refs/heads/<name>` or `refs/tags/<name>`.
|
||||
- **`main` and `master` are a refusal, not a gate.** Force-pushing, force-deleting, or renaming them is rejected even when the caller passes `confirm: true` — no flag makes the remote's history recoverable. Offer a new branch instead.
|
||||
|
||||
## Branch Patterns
|
||||
## Step 1 — Determine the branching pattern
|
||||
|
||||
Default to **GitHub Flow** (simpler, modern, CI/CD-friendly). Fall back to **Gitflow** only if the repo's config specifies it or the branch structure shows it in use (presence of `develop` or release branches).
|
||||
Read `branching_pattern` from the git plugin config (`.claude/plugins/git/config.json`; the plugin root's `config.example.json` shows the shape). Default: `github-flow`. With no config, infer Gitflow from the presence of a `develop` or `release/*` branch, and GitHub Flow otherwise.
|
||||
|
||||
**GitHub Flow:**
|
||||
- Base: `main`
|
||||
- Feature branches: `feature/<feature-name>` or `fix/<bug-name>`
|
||||
- Merge: fast-forward when possible (preserves linear history)
|
||||
- Delete after merge
|
||||
The two patterns are not mixable, and the wrong merge rule silently damages history. If the action touches a base branch, a name prefix, or a merge rule, read `references/branch-patterns.md`.
|
||||
|
||||
**Gitflow:**
|
||||
- Base: `main` (production) + `develop` (integration)
|
||||
- Feature branches: `feature/<feature-name>` (from `develop`)
|
||||
- Release branches: `release/X.Y.Z` (from `develop`, merged to `main` + `develop`)
|
||||
- Hotfix branches: `hotfix/X.Y.Z` (from `main`, merged to `main` + `develop`)
|
||||
- Merge: always use `--no-ff` to preserve branch structure
|
||||
## Step 2 — Dispatch on the action
|
||||
|
||||
## Workflow
|
||||
| Action | Reference |
|
||||
|---|---|
|
||||
| create, switch, delete, rename, track, list, get-intent, stash | `references/branch-operations.md` |
|
||||
| merge a branch, resolve merge conflicts | `references/merging.md` |
|
||||
| compare two branches, find their divergence | `references/comparing-branches.md` |
|
||||
|
||||
- [ ] **Determine pattern:** Check git plugin config (`.claude/plugins/git/config.json`, if present — see `config.example.json` in the plugin root for the expected shape) for `branching_pattern` (default: `github-flow`). If not set, inspect repo for `develop` branch or `release/*` branches; if present, assume Gitflow.
|
||||
- [ ] **Create branch:** Use `git switch -c <branch> <base>`. Base defaults to config's `base_branch` (usually `main` or `develop`). Include intent metadata in branch name or return as structured result (e.g., `{ "branch": "feature/x", "intent": "implement feature X" }`).
|
||||
- [ ] **Track remote:** If pushing, always use `git push -u origin <branch>` to establish tracking.
|
||||
- [ ] **Safety checks before destructive ops:** Before delete/force-push/rebase with history loss, check: (1) Is this branch tracking a remote? Warn if yes. (2) Are there unpushed commits? Warn if yes. (3) Does the orchestrator call include `confirm: true`? Fail if not. For humans, prompt interactively.
|
||||
- [ ] **Return structured results:** Always return branch operations as JSON or structured text: `{ "action": "create", "branch": "feature/x", "base": "main", "tracking": "origin/feature/x", "intent": "implement feature X" }`. Agents need to parse this for subsequent operations.
|
||||
- [ ] **Retrieve intent (`get-intent`):** Git has no native field for free-text branch metadata — this skill doesn't persist it. On `create`, the `intent` value is only ever returned in the structured result; the caller (orchestrator or agent) is responsible for storing it if it needs to be looked up later. On `get-intent`, either parse it back out of the branch name convention (`feature/<intent-slug>`) or return `{ "intent": null }` if the caller never persisted the original create-time value — don't fabricate an intent.
|
||||
Load only the file the action needs. A destructive action still passes Step 3 first.
|
||||
|
||||
### Command mapping for each action
|
||||
## Step 3 — Gate destructive operations
|
||||
|
||||
- **delete:** `git branch -d <branch>` refuses if the branch has unmerged commits — prefer this by default. `git branch -D <branch>` forces deletion and discards unmerged work; only use it after the safety checks above pass and `confirm: true` is set. For a remote branch: `git push origin --delete <branch>`.
|
||||
- **rename:** `git branch -m <old> <new>`.
|
||||
- **list:** `git branch` (local only), `git branch -a` (all local + remote-tracking), `git branch -r` (remote-tracking only), `git branch --merged`/`--no-merged` (filter by merge status into current branch).
|
||||
- **get-intent:** No git command — see Workflow step "Retrieve intent" for how this is resolved.
|
||||
- **track (existing branch):** `git branch --set-upstream-to=origin/<branch>` sets tracking without a push; `git branch -vv` shows tracking state for all local branches.
|
||||
- **switch (existing branch):** `git switch <branch>` — switches to an existing local branch (aborts on conflicting local changes, see Gotchas). `git switch -` switches back to the previously checked-out branch.
|
||||
Before any delete or force-delete that loses history:
|
||||
|
||||
## Merging
|
||||
- [ ] Does the branch track a remote? Warn if so.
|
||||
- [ ] Are there unpushed commits on it? Warn if so.
|
||||
- [ ] Did the caller pass `confirm: true`? Fail if not — for a human caller, prompt interactively instead of failing.
|
||||
|
||||
Scope: fast-forward/merge-commit mechanics and conflict resolution only. Rebase, cherry-pick, and revert belong to `git-history`.
|
||||
These gates are passable. The `main`/`master` refusal in Gotchas is not.
|
||||
|
||||
- **Fast-forward:** `git merge <branch>` — advances the pointer with no merge commit if the target hasn't diverged.
|
||||
- **True merge:** `git merge --no-ff <branch>` — forces a merge commit even when fast-forward is possible; required by Gitflow on all supporting-branch merges.
|
||||
- **Squash merge:** `git merge --squash <branch>` stages the combined diff without committing; follow with a manual `git commit`.
|
||||
- **Octopus merge:** `git merge branch-a branch-b branch-c` merges more than two branches at once; fails outright on any conflict, so use sequential two-way merges if conflicts are expected.
|
||||
## Step 4 — Set tracking
|
||||
|
||||
**Conflict resolution:** when Git can't auto-merge, it inserts conflict markers and stops. Run `git status` to find conflicted files, edit them to resolve the markers, then `git add <file>` and `git merge --continue`. `git merge --abort` reverts to the pre-merge state. `git mergetool` opens the configured merge tool; `git diff --diff-filter=U` shows only conflicted files.
|
||||
A new branch's first push must be `git push -u origin <branch>`. The push itself is `git-remotes`' — every remote-side gate lives there, which is why Step 2's remote-delete row hands off the same way — but the upstream requirement originates here, so carry it in the handoff. Without an upstream, later pushes and pulls either fail or silently target the wrong remote branch, and the caller has no way to tell which happened.
|
||||
|
||||
## Comparing Branches
|
||||
## Step 5 — Return a structured result
|
||||
|
||||
- `git log main..feature` — commits in `feature` not in `main`.
|
||||
- `git log feature..main` — commits in `main` not in `feature` (reverse direction).
|
||||
- `git log --left-right main...feature` — both diverging sets (symmetric diff).
|
||||
- `git diff main...feature` — diff from the common ancestor to `feature`'s tip.
|
||||
- `git merge-base main feature` — print the common ancestor commit.
|
||||
Return every operation in this shape rather than prose, including failures — a calling agent chains its next operation on the result and cannot parse a sentence.
|
||||
|
||||
## Integration with Orchestrator
|
||||
|
||||
When invoked by `git-orchestrate`, accept requests in the form:
|
||||
```json
|
||||
{
|
||||
"action": "create|switch|delete|rename|track|list|get-intent",
|
||||
"branch": "<branch-name>",
|
||||
"base": "<base-branch (optional, defaults to config)>",
|
||||
"intent": "<human-readable intent (optional)>",
|
||||
"confirm": "<true for destructive ops, omit for read ops>"
|
||||
}
|
||||
```
|
||||
|
||||
Return results as:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"action": "create|switch|...",
|
||||
"action": "create|switch|delete|rename|track|list|get-intent",
|
||||
"branch": "<name>",
|
||||
"message": "descriptive message",
|
||||
"intent": "<intent if tracked>",
|
||||
"tracking": "origin/<branch (if set)>",
|
||||
"tracking": "origin/<branch, if set>",
|
||||
"error": "<error message if success=false>",
|
||||
"suggestion": "<recovery suggestion if applicable>"
|
||||
}
|
||||
```
|
||||
|
||||
If error is due to uncommitted changes, include `{ "suggestion": "stash changes and retry" }` so the orchestrator can offer automatic recovery.
|
||||
When the failure is uncommitted local changes, set `"suggestion": "stash changes and retry"` so the caller can offer recovery rather than surfacing a dead end.
|
||||
|
||||
When a calling agent supplies a structured request rather than prose, read `references/orchestrator-contract.md` for the request schema.
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
source_keys:
|
||||
- context7-git-htmldocs
|
||||
---
|
||||
|
||||
# Per-action command mapping
|
||||
|
||||
One command per action. Where two forms exist, the first is the default and the second the escape
|
||||
hatch.
|
||||
|
||||
- **create** — `git switch -c <branch> <base>`. Base comes from the config's `base_branch`
|
||||
(`main` under GitHub Flow, usually `develop` under Gitflow).
|
||||
- **switch** — `git switch <branch>` moves to an existing local branch; it aborts rather than
|
||||
clobbering conflicting local changes. `git switch -` returns to the previous branch.
|
||||
- **delete (local)** — `git branch -d <branch>` refuses when the branch holds unmerged commits,
|
||||
which is why it is the default. `git branch -D <branch>` forces the deletion and discards that
|
||||
work — only after the destructive-operation gates pass and `confirm: true` is set.
|
||||
- **delete (remote)** — not this skill's. Deleting a remote branch is a push, and every remote-side
|
||||
gate lives in `git-remotes`; hand it there rather than running the push from here. Its
|
||||
`references/push.md` carries the command and the refspec form.
|
||||
- **rename** — `git branch -m <old> <new>`.
|
||||
- **list** — `git branch` (local), `-a` (local plus remote-tracking), `-r` (remote-tracking only),
|
||||
`--merged` / `--no-merged` (filter by merge status into the current branch).
|
||||
- **track** — `git branch --set-upstream-to=origin/<branch>` sets an upstream without pushing.
|
||||
`git branch -vv` shows the tracking state of every local branch.
|
||||
|
||||
## get-intent
|
||||
|
||||
Git has no native field for free-text branch metadata, and this skill does not persist any. On
|
||||
`create`, the `intent` value is only returned in the structured result — the caller decides
|
||||
whether to store it.
|
||||
|
||||
On `get-intent`, either parse the intent back out of the branch-name convention
|
||||
(`feature/<intent-slug>`) or return `{ "intent": null }` when the caller never persisted the
|
||||
create-time value. Never fabricate an intent: a downstream commit message built on a guessed
|
||||
intent is worse than one built on none.
|
||||
|
||||
## Stashing work in progress
|
||||
|
||||
A switch aborts rather than clobbering conflicting local changes (see Gotchas). Stash is the way
|
||||
past it: it shelves the working tree and index so the branch pointer can move.
|
||||
|
||||
- **save** — `git stash push -m "<message>"`. Add `-u` to include untracked files; verified on Git
|
||||
2.39.5, a plain `push` leaves them in place, and a plain `push` with *only* untracked changes
|
||||
reports `No local changes to save` and stashes nothing. Bare `git stash` is `push` with no message.
|
||||
- **restore** — `git stash pop` applies the newest entry and deletes it. `git stash apply stash@{n}`
|
||||
applies without deleting, for replaying one shelf onto more than one branch.
|
||||
- **list** — `git stash list`; `git stash show -p stash@{n}` prints that entry's diff.
|
||||
- **drop** — `git stash drop stash@{n}` deletes one entry. `git stash clear` deletes all of them
|
||||
and nothing recovers them — confirm before running it.
|
||||
- **branch from a stash** — `git stash branch <branch> stash@{n}` creates a branch at the commit the
|
||||
stash was taken from and pops it there. Use it when the stash no longer applies to the current tip.
|
||||
|
||||
**A conflicting `pop` keeps the entry.** Verified on 2.39.5: it exits 1, writes conflict markers,
|
||||
prints "The stash entry is kept in case you need it again", and `git stash list` still shows it.
|
||||
Resolve, `git add`, then `git stash drop` the entry by hand — otherwise it silently accumulates.
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
source_keys:
|
||||
- nvie-gitflow-post
|
||||
- atlassian-gitflow-tutorial
|
||||
- gitflow-cheatsheet
|
||||
---
|
||||
|
||||
# Branch patterns
|
||||
|
||||
Which pattern is in play decides the base branch, the branch name prefix, and whether merges are
|
||||
allowed to fast-forward. Default to GitHub Flow — simpler, and what CI/CD-oriented repos expect.
|
||||
Fall back to Gitflow only when the config says so or the repo already carries `develop` or
|
||||
`release/*` branches.
|
||||
|
||||
## GitHub Flow
|
||||
|
||||
- Base: `main`
|
||||
- Feature branches: `feature/<feature-name>` or `fix/<bug-name>`
|
||||
- Merge: fast-forward where possible, to keep history linear
|
||||
- Delete the branch after merge
|
||||
|
||||
## Gitflow
|
||||
|
||||
- Base: `main` (production) plus `develop` (integration)
|
||||
- Feature branches: `feature/<feature-name>`, cut from `develop`
|
||||
- Release branches: `release/X.Y.Z`, cut from `develop`, merged to both `main` and `develop`
|
||||
- Hotfix branches: `hotfix/X.Y.Z`, cut from `main`, merged to both `main` and `develop`
|
||||
- Merge: always `--no-ff`, so the branch structure survives in the history
|
||||
|
||||
The two are not mixable. A `--no-ff` merge into a GitHub Flow repo leaves merge commits nobody
|
||||
expects; a fast-forward merge of a Gitflow release branch erases the release boundary.
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
source_keys:
|
||||
- context7-git-htmldocs
|
||||
---
|
||||
|
||||
# Comparing two branches
|
||||
|
||||
The two-dot and three-dot forms mean different things and are easy to swap by accident — check the
|
||||
direction before reporting a result.
|
||||
|
||||
- `git log main..feature` — commits on `feature` that are not on `main`.
|
||||
- `git log feature..main` — the reverse direction: commits on `main` not on `feature`.
|
||||
- `git log --left-right main...feature` — both diverging sets at once (symmetric difference).
|
||||
- `git diff main...feature` — the diff from the common ancestor to `feature`'s tip, which is what
|
||||
a reviewer sees, rather than the diff between the two tips.
|
||||
- `git merge-base main feature` — print the common ancestor commit.
|
||||
30
plugins/git/.apm/skills/git-branches/references/merging.md
Normal file
30
plugins/git/.apm/skills/git-branches/references/merging.md
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source_keys:
|
||||
- context7-git-htmldocs
|
||||
- atlassian-gitflow-tutorial
|
||||
---
|
||||
|
||||
# Merging one branch into another
|
||||
|
||||
Scope is fast-forward and merge-commit mechanics plus conflict resolution. Rebase and cherry-pick
|
||||
belong to `git-commits`; revert to `git-history`.
|
||||
|
||||
- **Fast-forward** — `git merge <branch>` advances the pointer with no merge commit when the
|
||||
target has not diverged.
|
||||
- **True merge** — `git merge --no-ff <branch>` forces a merge commit even when a fast-forward is
|
||||
possible. Gitflow requires it on every supporting-branch merge.
|
||||
- **Squash merge** — `git merge --squash <branch>` stages the combined diff without committing.
|
||||
Follow it with a `git commit`.
|
||||
- **Octopus merge** — `git merge branch-a branch-b branch-c` merges more than two branches at
|
||||
once, but fails outright on any conflict. Use sequential two-way merges when conflicts are
|
||||
likely.
|
||||
|
||||
## Conflict resolution
|
||||
|
||||
When Git cannot auto-merge it writes conflict markers and stops mid-merge. Run `git status` to
|
||||
list the conflicted files, edit each to resolve its markers, then `git add <file>` and
|
||||
`git merge --continue`.
|
||||
|
||||
- `git merge --abort` restores the pre-merge state.
|
||||
- `git mergetool` opens the configured merge tool.
|
||||
- `git diff --diff-filter=U` shows only the still-conflicted files.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
source_keys: []
|
||||
---
|
||||
|
||||
# Orchestrator request contract
|
||||
|
||||
`git-orchestrate` and other calling agents send this shape. The result shape they parse back is in
|
||||
`SKILL.md` Step 5, because every run emits one.
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "create|switch|delete|rename|track|list|get-intent",
|
||||
"branch": "<branch-name>",
|
||||
"base": "<base branch, optional, defaults to config>",
|
||||
"intent": "<human-readable intent, optional>",
|
||||
"confirm": "<true for destructive ops, omit for read ops>"
|
||||
}
|
||||
```
|
||||
@@ -12,7 +12,8 @@
|
||||
- **Research doc:** plugins/git/docs/research/docs/git/gitflow.md (whole-document reference)
|
||||
|
||||
**Contributing files:**
|
||||
- SKILL.md (Branch Patterns — Gitflow vs. GitHub Flow structure and defaults)
|
||||
- SKILL.md (Gitflow vs. GitHub Flow inference and the not-mixable rule)
|
||||
- references/branch-patterns.md (Gitflow vs. GitHub Flow structure, defaults, and why the two are not mixable)
|
||||
|
||||
## atlassian-gitflow-tutorial
|
||||
|
||||
@@ -23,7 +24,9 @@
|
||||
- **Research doc:** plugins/git/docs/research/docs/git/gitflow.md (whole-document reference)
|
||||
|
||||
**Contributing files:**
|
||||
- SKILL.md (Branch Patterns — Gitflow branch types, base/merge targets, `--no-ff` requirement)
|
||||
- SKILL.md (Gitflow vs. GitHub Flow inference and the not-mixable rule)
|
||||
- references/branch-patterns.md (Gitflow branch types, base/merge targets, `--no-ff` requirement)
|
||||
- references/merging.md (`--no-ff` requirement on Gitflow supporting-branch merges)
|
||||
|
||||
## gitflow-cheatsheet
|
||||
|
||||
@@ -34,7 +37,7 @@
|
||||
- **Research doc:** plugins/git/docs/research/docs/git/gitflow.md (whole-document reference)
|
||||
|
||||
**Contributing files:**
|
||||
- SKILL.md (Branch Patterns — feature/release/hotfix naming conventions)
|
||||
- references/branch-patterns.md (feature/release/hotfix naming conventions)
|
||||
|
||||
## context7-git-htmldocs
|
||||
|
||||
@@ -45,4 +48,7 @@
|
||||
- **Research doc:** plugins/git/docs/research/docs/git/branching-merging.md (whole-document reference)
|
||||
|
||||
**Contributing files:**
|
||||
- SKILL.md (Command mapping, Merging, Comparing Branches — `git switch`/`git branch`/`git merge`/`git log`/`git diff`/`git merge-base` command vocabulary and flags)
|
||||
- SKILL.md (Gotchas — `git switch` abort-on-conflict behaviour, branch/tag name ambiguity)
|
||||
- references/branch-operations.md (`git switch`/`git branch` command vocabulary and flags)
|
||||
- references/merging.md (`git merge` strategies and conflict-resolution commands)
|
||||
- references/comparing-branches.md (`git log`/`git diff`/`git merge-base` range syntax)
|
||||
|
||||
@@ -16,9 +16,16 @@ Describe your commit task: create a new commit, amend, squash, or cherry-pick. T
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | Skill instructions for agents |
|
||||
| `references/conventional-commits-spec.md` | Full Conventional Commits specification |
|
||||
| `references/commit-template.md` | Why / Implementation Notes / Impact body structure and full trailer list |
|
||||
| File | Loaded when |
|
||||
|------|-------------|
|
||||
| `SKILL.md` | Always — gotchas, the flow dispatch table, the gates common to every flow, and the output shape |
|
||||
| `references/create-commit.md` | Composing a new commit from staged changes |
|
||||
| `references/rewrite-history.md` | Amending, squashing, or folding a `fixup!`/`squash!` commit into an earlier one |
|
||||
| `references/cherry-pick.md` | Replaying an existing commit onto the current branch |
|
||||
| `references/conventional-commits-spec.md` | A type, footer, or breaking-change edge case is not obvious — full spec, 11-type set, commitlint constraint table |
|
||||
| `references/commit-template.md` | Writing a body for a non-trivial commit — Why / Implementation Notes / Impact structure and the full trailer list |
|
||||
| `references/sources.md` | Research sources and provenance |
|
||||
|
||||
## Composition
|
||||
|
||||
Part of the git plugin's domain suite. This skill owns commit authoring and history-rewriting operations only; `git-history` inspects history, `git-branches` owns branch lifecycle, and `git-workflow` is the conversational entry point that routes between them.
|
||||
|
||||
@@ -2,16 +2,13 @@
|
||||
name: git-commits
|
||||
|
||||
description: >
|
||||
Use when creating, amending, squashing, or cherry-picking commits.
|
||||
Generates well-formatted commit messages following Conventional Commits spec (type, scope, description, body, footers).
|
||||
Validates against commitlint config-conventional constraints (header max 100 chars, lowercase subject, no trailing periods, type must be one of 11 standard types).
|
||||
Communicates SemVer impact (MAJOR for breaking changes, MINOR for features, PATCH for fixes).
|
||||
Handles confirmation gates for history-altering operations (amend, rebase, squash).
|
||||
Provides interactive guidance for humans, structured JSON output for agents.
|
||||
Do not use for: inspecting git history, branch management, or repository state inspection — those are separate skills.
|
||||
Use when creating, amending, squashing, or cherry-picking commits, including
|
||||
writing and validating the Conventional Commits message.
|
||||
Not history inspection -> `git-history`.
|
||||
Not branch lifecycle -> `git-branches`.
|
||||
|
||||
metadata:
|
||||
version: "0.1.2"
|
||||
version: "0.1.3"
|
||||
category: git
|
||||
source_keys:
|
||||
- conventional-commits-spec
|
||||
@@ -24,92 +21,56 @@ allowed-tools: Bash
|
||||
|
||||
## Gotchas
|
||||
|
||||
- **Type must be one of 11 standard types** — `feat`, `fix`, `perf`, `revert`, `docs`, `style`, `refactor`, `test`, `build`, `ci`, `chore`. Non-standard types will fail commitlint validation. Note: the Conventional Commits spec itself only mandates `feat`/`fix` — the 11-type set is a commitlint/Angular convention this skill validates against, not a spec requirement.
|
||||
- **Scope is optional but should be used** — helps identify which part of the system changed. Examples: `api`, `db`, `cli`, `config`.
|
||||
- **Header max 100 characters** — type + scope + colon + description must fit. If longer, move detail to body.
|
||||
- **BREAKING CHANGE notation** — use `!` before the colon (`feat!: drop Node 6`) for visibility in `git log --oneline`. Footer notation (`BREAKING CHANGE: ...`) is machine-readable but hidden in log.
|
||||
- **SemVer mapping is not optional** — agents must communicate: `feat` → MINOR bump, `fix`/`perf`/`revert` → PATCH, any with breaking change → MAJOR.
|
||||
- **Confirmation gates are mandatory for destructive operations** — amend, rebase, squash require explicit user/agent approval before execution.
|
||||
- **Never skip hooks with `--no-verify`** — hooks are the automated QA gate; bypassing them breaks the pipeline. Do not add this flag to any commit command unless the user explicitly demands it, and warn them if they do.
|
||||
- **Never force-push `main`/`master`** — even after an amend or interactive rebase, refuse to force-push a protected branch (`main`, `master`) and explain why; force-push is only safe on branches no one else has based work on.
|
||||
- **Command examples use the `rtk git` wrapper** — this org's convention routes all git invocations through `rtk git <subcommand>` instead of bare `git <subcommand>`. Follow this prefix in any command you actually run.
|
||||
- **Never commit secrets, credentials, or environment-specific config** — if staged changes contain what looks like an API key, token, password, or connection string, stop and flag it before committing rather than committing it.
|
||||
- **Commits must be atomic and leave the repo working** — each commit should be one logical, independently reviewable and reversible change, and should leave the repository in a buildable/testable state. If staged changes bundle unrelated work, suggest splitting before committing.
|
||||
- **Commit messages explain why, not what** — the diff already shows what changed; the message's job is to capture context the diff can't (motivation, root cause, tradeoffs). See `references/commit-template.md` for the structure this maps to.
|
||||
- **Run git as `rtk git <subcommand>`, never bare `git`** — org convention, in `&&` chains too.
|
||||
- **Refuse to force-push `main`/`master`** — a rewrite leaves the branch diverged and the reflex is to force it back; safe only where nobody else has based work on it.
|
||||
- **`reset --hard` is a confirmation gate, not a default.** It overwrites the working tree, and uncommitted edits it discards were never in git, so no reflog recovers them. Name what will be lost and offer a stash first.
|
||||
- **Never add `--no-verify`** — using it when a hook fails bypasses the QA gate the pipeline depends on. Only on the user's explicit demand, with a warning.
|
||||
|
||||
## Workflow
|
||||
## Dispatch
|
||||
|
||||
### For creating a new commit:
|
||||
Read exactly one flow file. Each is self-contained.
|
||||
|
||||
1. **Gather context** — what changed and why? (from staged changes, PR description, issue context). Verify the staged diff is one logical, atomic change and that the repo would still build/test at this commit — if not, suggest splitting before proceeding.
|
||||
2. **Check for secrets** — scan the staged diff for anything that looks like a credential, API key, token, or environment-specific config. Stop and flag it rather than committing.
|
||||
3. **Determine type** — is this a feature (`feat`), bug fix (`fix`), or other? Default: check the change itself.
|
||||
4. **Determine scope** — which system/module? Use scope from plugin config if set, otherwise infer from files changed.
|
||||
5. **Write description** — imperative mood, no period. Neither source spec sets a length target below the 100-char header max, but convention favors keeping it to ~50 characters where possible for `git log --oneline` readability. Examples: "add user authentication", "fix race condition in cache".
|
||||
6. **Add body if needed** — explain why (not what). Blank line before body, wrap at 100 chars. For non-trivial changes, follow the Why / Implementation Notes / Impact structure in `references/commit-template.md`.
|
||||
7. **Add footers if needed** — `Fixes: #123`, `Refs: #123`, `ADR: 0012`, `RFC: 0003`, `Design: <link>`, `Reviewed-by: Name`, `Co-authored-by: Name <email>`, `Signed-off-by: Name <email>`, `BREAKING CHANGE: description`. See `references/commit-template.md` for the full trailer list.
|
||||
8. **Validate** — check header length, type correctness, no trailing periods, lowercase.
|
||||
9. **Confirm and execute** — for agents, require explicit approval; for humans, show preview and ask. Never add `--no-verify` to skip hooks.
|
||||
| Condition | Flow | Read |
|
||||
|---|---|---|
|
||||
| Composing a new commit from staged changes | create | `references/create-commit.md` |
|
||||
| Amending, squashing, folding a fixup, rebasing onto a new base, or resetting HEAD | rewrite | `references/rewrite-history.md` |
|
||||
| Replaying an existing commit onto the current branch | cherry-pick | `references/cherry-pick.md` |
|
||||
|
||||
### For amending a commit:
|
||||
## Gates on every flow
|
||||
|
||||
1. **Stage new changes** (or changes to undo)
|
||||
2. **Run amend operation** — executes `rtk git commit --amend [--no-edit]` based on user intent
|
||||
3. **Offer message edit** — if user wants to change commit message, show current message and prompt for new one
|
||||
4. **Confirm before force-push** — amending is only safe on non-shared branches; if the current branch is `main`/`master`, refuse to force-push and explain why rather than warning and proceeding
|
||||
1. **Confirmation.** No history rewrite executes without explicit approval from the user or the calling agent. Cherry-pick needs the destination branch confirmed first.
|
||||
2. **Atomicity.** The result must be one logical, independently reviewable and reversible change that leaves the repository buildable and testable. This binds an amend or a squashed result as much as a fresh commit — say so before writing it, not after.
|
||||
3. **Secrets.** Before any commit or amend, scan the staged diff for anything resembling an API key,
|
||||
token, password, connection string, or environment-specific config. Stop and flag it rather than
|
||||
committing it.
|
||||
4. **Validation.** Check the message against commitlint `config-conventional` before committing. If a type, footer, or breaking-change edge case is not obvious, read `references/conventional-commits-spec.md` — it carries the constraint table, the 11-type set, and the footer token rules.
|
||||
5. **SemVer impact.** Report the bump the commit implies: `feat` → MINOR, `fix`/`perf`/`revert` → PATCH, any breaking change → MAJOR, everything else → none. Callers decide releases from this, so never omit it.
|
||||
6. **Conflicts.** If a rebase or cherry-pick halts, offer resolution or an abort. Do not resolve automatically without confirmation.
|
||||
|
||||
### For squashing commits (interactive rebase):
|
||||
## Output
|
||||
|
||||
1. **Identify commits to squash** — typically the last N commits on current branch
|
||||
2. **Confirm operation** — squashing rewrites history; get explicit approval
|
||||
3. **Execute rebase** — `rtk git rebase -i HEAD~N`, mark older commits as `squash` or `fixup`
|
||||
4. **Handle merge conflicts** — if rebase halts, offer conflict resolution options or abort; do not resolve automatically without confirmation
|
||||
5. **Offer message composition** — if squashing interactive, allow message editing
|
||||
|
||||
### For squashing commits (autosquash — preferred when tagging at commit time):
|
||||
|
||||
Prefer this over manual interactive rebase when a commit is written to be folded into an earlier one, since it removes the manual "mark as squash/fixup" step and the risk of reordering the wrong line:
|
||||
|
||||
1. **Create the fixup/squash commit** — `rtk git commit --fixup=<commit>` (keeps target's message) or `rtk git commit --squash=<commit>` (lets you edit the combined message later). Both prefix the message with `fixup!`/`squash!` and target `<commit>`.
|
||||
2. **Confirm operation** — rewriting history still requires explicit approval before the rebase runs.
|
||||
3. **Execute** — `rtk git rebase --autosquash HEAD~N` (or `-i --autosquash` to review the plan first); git reorders and marks the `fixup!`/`squash!` commits against their targets automatically.
|
||||
4. **Handle merge conflicts** — same as manual rebase: offer resolution or abort, never resolve automatically without confirmation.
|
||||
|
||||
### For cherry-picking:
|
||||
|
||||
1. **Identify source commit(s)** — hash or branch reference
|
||||
2. **Confirm destination branch** — cherry-pick will replay commits on current branch
|
||||
3. **Execute cherry-pick** — `rtk git cherry-pick <commit-hash>`
|
||||
4. **Handle conflicts** — offer conflict resolution or abort
|
||||
5. **Report outcome** — successful replays, conflicts, or rejected commits
|
||||
|
||||
## Output format (for agent consumption)
|
||||
|
||||
Return structured JSON:
|
||||
For an agent caller, return:
|
||||
|
||||
```json
|
||||
{
|
||||
"operation": "create|amend|squash|cherry-pick",
|
||||
"status": "success|conflict|rejected",
|
||||
"message": "Commit message or error description",
|
||||
"message": "commit message or error description",
|
||||
"commit_hash": "abc1234",
|
||||
"semver_impact": "MAJOR|MINOR|PATCH|none",
|
||||
"breaking_change": true|false,
|
||||
"confirmation_required": true|false,
|
||||
"breaking_change": false,
|
||||
"confirmation_required": false,
|
||||
"details": {
|
||||
"type": "feat",
|
||||
"scope": "api",
|
||||
"description": "add user authentication",
|
||||
"body": "optional body text",
|
||||
"footers": ["Fixes: #123", "Refs: #456", "ADR: 0012", "Reviewed-by: Alice", "Co-authored-by: Bob <bob@example.com>", "Signed-off-by: Alice <alice@example.com>"]
|
||||
"body": "optional body text, or null",
|
||||
"footers": ["Fixes: #123", "Refs: #456", "Co-authored-by: Bob <bob@example.com>"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For interactive human use, format as readable prose with clear prompts and previews.
|
||||
`details.footers` is an array of the resolved trailer lines, empty when there are none — never a
|
||||
single joined string, and never omitted. Downstream agents index it.
|
||||
|
||||
## Reference
|
||||
|
||||
If a footer or type/scope edge case isn't covered above, read `references/conventional-commits-spec.md` for the full specification.
|
||||
|
||||
For the Why / Implementation Notes / Impact body structure and the full trailer list, read `references/commit-template.md`.
|
||||
For a human caller, show the same fields as a prose preview with a confirmation prompt.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
source_keys:
|
||||
- context7-git-htmldocs
|
||||
---
|
||||
|
||||
# Cherry-picking a commit
|
||||
|
||||
1. **Identify the source commit** — a hash or a branch reference.
|
||||
2. **Confirm the destination** — cherry-pick replays onto the branch currently checked out, so verify that is the intended branch before running anything.
|
||||
3. **Execute** — `rtk git cherry-pick <commit-hash>`. A range is `<a>..<b>` (exclusive of `<a>`) or `<a>^..<b>` (inclusive); `-n` stages without committing, for when the replay needs editing first.
|
||||
4. **Handle conflicts** — if the replay halts, offer resolution or `rtk git cherry-pick --abort`. Never resolve automatically without confirmation.
|
||||
5. **Report the outcome** — which commits replayed, which conflicted, and which were rejected.
|
||||
@@ -7,7 +7,7 @@ source_keys:
|
||||
|
||||
Use this structure for the body/footer of any non-trivial commit (skip sections that don't apply — do not leave placeholders in the actual commit).
|
||||
|
||||
```
|
||||
```text
|
||||
<type>(<scope>): <concise summary>
|
||||
```
|
||||
The header is required. Describe the intended outcome, not the implementation.
|
||||
@@ -53,7 +53,7 @@ Omit if there are no noteworthy impacts.
|
||||
|
||||
Structured metadata for traceability and tooling. Use only the trailers that apply:
|
||||
|
||||
```
|
||||
```text
|
||||
Fixes:
|
||||
Refs:
|
||||
ADR:
|
||||
|
||||
@@ -10,7 +10,7 @@ Conventional Commits is a lightweight convention on top of commit messages that
|
||||
|
||||
## Message Format
|
||||
|
||||
```
|
||||
```text
|
||||
<type>[optional scope]: <description>
|
||||
|
||||
[optional body]
|
||||
@@ -58,20 +58,20 @@ A `BREAKING CHANGE` footer or `!` on **any** type always triggers a MAJOR bump.
|
||||
Two equivalent notations:
|
||||
|
||||
**`!` in header** (preferred — visible in `git log --oneline`):
|
||||
```
|
||||
```text
|
||||
feat!: drop support for Node 6
|
||||
feat(api)!: remove deprecated endpoint
|
||||
```
|
||||
|
||||
**`BREAKING CHANGE` footer** (machine-readable body):
|
||||
```
|
||||
```text
|
||||
feat: allow config to extend other configs
|
||||
|
||||
BREAKING CHANGE: `extends` key now used for extending config files
|
||||
```
|
||||
|
||||
**Both together** (most explicit):
|
||||
```
|
||||
```text
|
||||
feat!: drop support for Node 6
|
||||
|
||||
BREAKING CHANGE: use JavaScript features not available in Node 6.
|
||||
@@ -85,7 +85,7 @@ Rules:
|
||||
|
||||
## Footer Token Rules
|
||||
|
||||
```
|
||||
```text
|
||||
<token>: <value>
|
||||
<token> #<value> # for issue references
|
||||
```
|
||||
@@ -96,7 +96,7 @@ Rules:
|
||||
- Blank line required before the footer block.
|
||||
|
||||
Valid footer examples:
|
||||
```
|
||||
```text
|
||||
Reviewed-by: Z
|
||||
Refs: #123
|
||||
Co-authored-by: Alice <alice@example.com>
|
||||
@@ -106,29 +106,29 @@ BREAKING CHANGE: the `--format` flag now requires a value
|
||||
## Examples
|
||||
|
||||
Minimal — no body, no footer:
|
||||
```
|
||||
```text
|
||||
docs: correct spelling of CHANGELOG
|
||||
```
|
||||
|
||||
With scope:
|
||||
```
|
||||
```text
|
||||
feat(lang): add Polish language
|
||||
```
|
||||
|
||||
Breaking change via `!`:
|
||||
```
|
||||
```text
|
||||
feat!: send an email to the customer when a product is shipped
|
||||
```
|
||||
|
||||
Breaking change via footer:
|
||||
```
|
||||
```text
|
||||
feat: allow provided config object to extend other configs
|
||||
|
||||
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
|
||||
```
|
||||
|
||||
Multi-paragraph body with multiple footers:
|
||||
```
|
||||
```text
|
||||
fix: prevent racing of requests
|
||||
|
||||
Introduce a request id and a reference to latest request. Dismiss
|
||||
@@ -142,7 +142,7 @@ Refs: #123
|
||||
```
|
||||
|
||||
Revert:
|
||||
```
|
||||
```text
|
||||
revert: let us never again speak of the noodle incident
|
||||
|
||||
Refs: 676104e, a215868
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
source_keys:
|
||||
- conventional-commits-spec
|
||||
- commitlint-config-conventional
|
||||
- org-commit-conventions
|
||||
---
|
||||
|
||||
# Creating a new commit
|
||||
|
||||
1. **Gather context** — what changed and why, from the staged diff, the PR description, or the issue. Confirm the staged diff is one logical, independently reviewable and reversible change that leaves the repository buildable and testable. If it bundles unrelated work, suggest splitting it before going further.
|
||||
2. **Determine the type** — read it off the change itself: a new user-visible feature is `feat`, a bug fix is `fix`. For the full 11-type set and each type's SemVer impact, read `references/conventional-commits-spec.md`.
|
||||
3. **Determine the scope** — use the scope from plugin config where one is set, otherwise infer it from the files changed (`api`, `db`, `cli`, `config`). Scope is optional, but it identifies which part of the system moved and is worth setting.
|
||||
4. **Write the description** — imperative mood, no trailing period: "add user authentication", "fix race condition in cache". Neither source spec sets a target below the 100-character header maximum, but convention favours roughly 50 characters so `git log --oneline` stays readable.
|
||||
5. **Add a body when the change is non-trivial** — blank line first, wrapped at 100 characters. Explain *why*, not what: the diff already shows what changed, and the message's job is the context the diff cannot carry — motivation, root cause, tradeoffs. Follow the Why / Implementation Notes / Impact structure in `references/commit-template.md`.
|
||||
6. **Add footers where they apply** — `Fixes: #123`, `Refs: #123`, `ADR: 0012`, `Co-authored-by: Name <email>`, `BREAKING CHANGE: description`. For the full trailer list, read `references/commit-template.md`.
|
||||
7. **Signal a breaking change with `!` before the colon** — `feat!: drop Node 6` is visible in `git log --oneline`, where the `BREAKING CHANGE:` footer alone is machine-readable but hidden. Use both when the break needs describing.
|
||||
8. **Validate, confirm, execute** — check header length, type, lowercase subject and trailing period against commitlint, show the message, and commit only once the caller has approved. Never add `--no-verify`.
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
source_keys:
|
||||
- org-commit-conventions
|
||||
- context7-git-htmldocs
|
||||
---
|
||||
|
||||
# Rewriting existing commits
|
||||
|
||||
Every flow on this page rewrites history. None of them runs before the caller has explicitly approved it, and none is followed by a force-push to `main`/`master` — refuse that and explain why instead.
|
||||
|
||||
## Amend the last commit
|
||||
|
||||
1. Stage the new changes, or the changes that undo something.
|
||||
2. Run `rtk git commit --amend`, adding `--no-edit` when the message stays as it is.
|
||||
3. If the message should change, show the current one and prompt for the replacement.
|
||||
4. The branch has now diverged from its remote. Amending is safe only on a branch nobody else has based work on; on `main`/`master`, refuse the force-push and explain, rather than warning and proceeding.
|
||||
|
||||
## Fold a commit into an earlier one (autosquash — preferred)
|
||||
|
||||
Prefer this whenever a commit is written to be folded, because git does the marking:
|
||||
|
||||
1. `rtk git commit --fixup=<commit>` keeps the target's message; `rtk git commit --squash=<commit>` lets you edit the combined message later. Both prefix the message with `fixup!`/`squash!` and name the target commit.
|
||||
2. Get explicit approval — the rebase still rewrites history.
|
||||
3. Run `rtk git rebase -i --autosquash HEAD~N`. Git pre-fills the todo list with the tagged commits already reordered against their targets; save it unchanged to apply.
|
||||
|
||||
**`-i` is not optional here.** On Git 2.39.5, `rtk git rebase --autosquash HEAD~N` without `-i` prints `Successfully rebased and updated refs/heads/<branch>.` and exits 0 while leaving the `fixup!` commit in place at its original SHA — `--autosquash` is honoured only by the interactive machinery, and the false success is the trap: the fold is reported as done, and the surviving `fixup!` subject then fails the Conventional Commits `commit-msg` hook. Later Git versions taught the non-interactive rebase to honour the flag, but `-i --autosquash` is correct on every version, so always write that.
|
||||
|
||||
## Squash by hand (interactive rebase)
|
||||
|
||||
Use this when the commits were not tagged at commit time. **Interactive rebase has no undo once `rebase -i` starts — `git reflog` is the recovery path.**
|
||||
|
||||
1. Identify the commits to squash — typically the last N on the current branch.
|
||||
2. Get explicit approval.
|
||||
3. Run `rtk git rebase -i HEAD~N`, marking the older commits `squash` to keep their messages for editing, or `fixup` to discard them.
|
||||
4. Compose the combined message when the rebase stops to ask. For a non-trivial combined message, follow the structure in `references/commit-template.md`.
|
||||
|
||||
## When a rebase halts on a conflict
|
||||
|
||||
Offer conflict resolution or `rtk git rebase --abort`. Do not resolve conflicts automatically without confirmation.
|
||||
|
||||
## Rebase the branch onto a new base
|
||||
|
||||
Replays this branch's commits on top of another branch's tip — bringing a feature branch up to
|
||||
date without a merge commit.
|
||||
|
||||
1. Confirm nothing being replayed has been pushed anywhere someone else has based work on. A rebase
|
||||
gives every replayed commit a new SHA, which breaks any clone that already has the old ones.
|
||||
2. Get explicit approval — this rewrites history like every other flow on this page.
|
||||
3. `rtk git fetch origin` first, so `<newbase>` is the real tip rather than a stale local copy.
|
||||
4. `rtk git rebase <newbase>` — for example `rtk git rebase main`. Use
|
||||
`rtk git rebase --onto <newbase> <upstream> <branch>` to replay only the commits after
|
||||
`<upstream>`, which is how a branch started from the wrong base gets moved.
|
||||
5. The branch has now diverged from its remote. It needs
|
||||
`--force-with-lease --force-if-includes` to push, never a bare `--force`, and never on
|
||||
`main`/`master` — refuse that and explain.
|
||||
|
||||
## Move the branch pointer back (`git reset`)
|
||||
|
||||
`reset` moves the current branch to another commit. The mode decides what survives:
|
||||
|
||||
| Mode | Branch pointer | Index | Working tree |
|
||||
|---|---|---|---|
|
||||
| `--soft` | moves | untouched — the changes stay staged | untouched |
|
||||
| `--mixed` (default) | moves | reset — the changes become unstaged | untouched |
|
||||
| `--hard` | moves | reset | **overwritten; uncommitted work is destroyed** |
|
||||
|
||||
- "Undo my last commit but keep the changes" is `rtk git reset --soft HEAD~1`. That is the default
|
||||
answer to the request; reach for anything else only when the caller asked for it.
|
||||
- `rtk git reset --mixed HEAD~1` when the staging should be redone from scratch too.
|
||||
- `rtk git reset --hard <ref>` is gated like a force-push: state exactly which uncommitted changes
|
||||
will be discarded, get approval for that specific reset, and offer `rtk git stash push -u` first.
|
||||
The commits it drops stay reachable through `git reflog`; the uncommitted edits never entered git
|
||||
at all and nothing recovers them.
|
||||
|
||||
Reset does not rewrite the commits it leaves behind, so no force-push is needed unless the branch
|
||||
was already pushed at the newer commit.
|
||||
@@ -7,34 +7,34 @@ source_keys:
|
||||
- context7-git-htmldocs
|
||||
---
|
||||
|
||||
# Research Sources for git:commits Skill
|
||||
# Research Sources for git-commits Skill
|
||||
|
||||
Sources extracted from the git plugin research phase. Only sources that directly informed this skill are listed; sibling skills (git:branches, git:history, git:remotes, etc.) have their own sources.md.
|
||||
Sources extracted from the git plugin research phase. Only sources that directly informed this skill are listed; sibling skills (git-branches, git-history, git-remotes, etc.) have their own sources.md.
|
||||
|
||||
## conventional-commits-spec
|
||||
|
||||
- **Description:** Conventional Commits Specification (v1.0.0) — message format, types, breaking changes, footer rules
|
||||
- **Research doc:** plugins/git/docs/research/docs/git/commits.md § "Conventional Commits Specification (v1.0.0)"
|
||||
- **Contributing files:** SKILL.md, references/conventional-commits-spec.md
|
||||
- **Contributing files:** SKILL.md, references/conventional-commits-spec.md, references/create-commit.md
|
||||
- **Status:** extracted
|
||||
|
||||
## commitlint-config-conventional
|
||||
|
||||
- **Description:** commitlint config-conventional preset — validation constraints (max 100 chars header, no trailing periods, lowercase type, 11-type set enforcement)
|
||||
- **Research doc:** plugins/git/docs/research/docs/git/commits.md § "commitlint Constraints (`config-conventional`)"
|
||||
- **Contributing files:** SKILL.md, references/conventional-commits-spec.md
|
||||
- **Contributing files:** SKILL.md, references/conventional-commits-spec.md, references/create-commit.md
|
||||
- **Status:** extracted
|
||||
|
||||
## org-commit-conventions
|
||||
|
||||
- **Description:** Organization commit message body template and git conventions (atomic commits, no `--no-verify`, no force-push main/master, `rtk git` wrapper) — content fully embedded in this skill; the org's `core/instructions/git.md` and `core/instructions/commits.md` are provenance only and are not a live dependency
|
||||
- **Research doc:** core/instructions/commits.md, core/instructions/git.md (org convention, not part of the plugin's research corpus)
|
||||
- **Contributing files:** SKILL.md, references/commit-template.md
|
||||
- **Contributing files:** SKILL.md, references/commit-template.md, references/create-commit.md, references/rewrite-history.md
|
||||
- **Status:** extracted
|
||||
|
||||
## context7-git-htmldocs
|
||||
|
||||
- **Description:** Official Git HTML documentation — `git commit --squash`/`--fixup` and `git rebase --autosquash` flag semantics
|
||||
- **Research doc:** plugins/git/docs/research/docs/git/cli-reference.md
|
||||
- **Contributing files:** SKILL.md
|
||||
- **Description:** Official Git HTML documentation — `git commit --squash`/`--fixup`, `git rebase --autosquash`, and `git cherry-pick` range and abort semantics
|
||||
- **Research doc:** plugins/git/docs/research/docs/git/cli-reference.md § "Committing", § "Rebasing", § "Cherry-picking"
|
||||
- **Contributing files:** SKILL.md, references/rewrite-history.md, references/cherry-pick.md
|
||||
- **Status:** extracted
|
||||
|
||||
@@ -6,6 +6,10 @@ Inspect git history — log queries, bisect, and locating problematic commits.
|
||||
|
||||
This skill handles history inspection within the git workflow suite. It queries logs with pickaxe/line-range/custom formats, runs bisect to find bug-introducing commits, and locates commits for downstream cherry-picking or reverting. It returns structured results for agent composition. Rebase, squash, fixup, and other history-rewriting operations are owned by git-commits, not this skill.
|
||||
|
||||
## Composition
|
||||
|
||||
`git-branches` delegates revert here (see `git-branches`'s `references/merging.md`), which is why this skill carries that operation rather than treating it as out of scope; it is general git knowledge, not drawn from the `history-inspection.md` research corpus. Cherry-pick is **not** this skill's: `git-commits` owns it, and this skill's job ends at locating the SHA to hand over. Server-side commit history on a Gitea-hosted repository belongs to `gitea-branches`; this skill reads the local working copy.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
@@ -19,6 +23,7 @@ Describe your history task: search logs, bisect for a regression, or locate a sp
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `SKILL.md` | Skill instructions for agents |
|
||||
| `references/git-log-format.md` | Full log format placeholders, diff-filter letters, `-L` syntax, ancestry filters, diff output-control flags |
|
||||
| `references/bisect.md` | Loaded when the entry procedure is bisect: manual and automated flows, exit codes, skip, replay, narrowing, custom terms |
|
||||
| `references/git-log-format.md` | Loaded when a log or diff flag needs looking up: format placeholders, presets, diff-filter letters, `-L` syntax, ancestry filters, pickaxe binary-file behaviour, diff output-control flags |
|
||||
| `references/sources.md` | Research sources and provenance |
|
||||
| `references/README.md` | Index of the references directory |
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user