Skip to content

Commit e806522

Browse files
authored
fix(ce-compound-refresh): check inbound links before deletion (#713)
1 parent 1f0a77b commit e806522

1 file changed

Lines changed: 31 additions & 7 deletions

File tree

  • plugins/compound-engineering/skills/ce-compound-refresh

plugins/compound-engineering/skills/ce-compound-refresh/SKILL.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ For each candidate artifact, classify it into one of five outcomes:
8080
- the user has provided enough concrete replacement context to document the successor honestly, or
8181
- the codebase investigation found the current approach and can document it as the successor, or
8282
- newer docs, pattern docs, PRs, or issues provide strong successor evidence.
83-
8. **Delete when the code is gone.** If the referenced code, controller, or workflow no longer exists in the codebase and no successor can be found, delete the file — don't default to Keep just because the general advice is still "sound." A learning about a deleted feature misleads readers into thinking that feature still exists. When in doubt between Keep and Delete, ask the user (in interactive mode) or mark as stale (in autofix mode). But missing referenced files with no matching code is **not** a doubt case — it is strong, unambiguous Delete evidence. Auto-delete it.
83+
8. **Delete when the code is gone, and only after checking for inbound links.** If the referenced code, controller, or workflow no longer exists in the codebase and no successor can be found, delete the file — don't default to Keep just because the general advice is still "sound." When in doubt between Keep and Delete, ask the user (in interactive mode) or mark as stale (in autofix mode). Inbound links inform classification, not cleanup: cleanup is always mechanical, but **decorative** citations (principle stated inline) allow Delete, while **substantive** citations (citing doc relies on the cited doc) signal Replace. The auto-delete case is missing code, no matching successor, and citations absent or decorative.
8484
9. **Evaluate document-set design, not just accuracy.** In addition to checking whether each doc is accurate, evaluate whether it is still the right unit of knowledge. If two or more docs overlap heavily, determine whether they should remain separate, be cross-scoped more clearly, or be consolidated into one canonical document. Redundant docs are dangerous because they drift silently — two docs saying the same thing will eventually say different things.
8585
10. **Delete, don't archive.** There is no `_archived/` directory. When a doc is no longer useful, delete it. Git history preserves every deleted file — that is the archive. A dedicated archive directory creates problems: archived docs accumulate, pollute search results, and nobody reads them. If someone needs a deleted doc, `git log --diff-filter=D -- docs/solutions/` will find it.
8686

@@ -350,15 +350,33 @@ When a learning's referenced files are gone, that is strong evidence — but onl
350350

351351
Do not search mechanically for keywords from the old learning. Instead, understand what problem the learning addresses, then investigate whether that problem domain still exists in the codebase. The agent understands concepts — use that understanding to look for where the problem lives now, not where the old code used to be.
352352

353-
**Auto-delete only when both the implementation AND the problem domain are gone:**
353+
### Before deleting: check for inbound links
354354

355-
- the referenced code is gone AND the application no longer deals with that problem domain
356-
- the learning is fully superseded by a clearly better successor AND the old doc adds no distinct value
357-
- the document is plainly redundant and adds nothing the canonical doc doesn't already say
355+
A doc that other files cite is load-bearing in a way the doc itself does not announce. Before classifying as Delete, search the repo's markdown content (other docs, plans, instruction files, READMEs) for citations of the file — not source code, where citations are rare and only appear in comments. The filename slug is usually unique enough that one query covers all citation sites.
358356

359-
If the implementation is gone but the problem domain persists (the app still does auth, still processes payments, still handles migrations), classify as **Replace** — the problem still matters and the current approach should be documented.
357+
Search efficiently:
360358

361-
Do not keep a learning just because its general advice is "still sound" — if the specific code it references is gone, the learning misleads readers. But do not delete a learning whose problem domain is still active — that knowledge gap should be filled with a replacement.
359+
- Prefer the platform's native content-search tool (e.g., Grep in Claude Code) over shell. Drop to shell when materially better for the case.
360+
- Search the filename slug (without `.md`); narrow to the full path only if matches are noisy.
361+
- Read context lines around each match (e.g., Grep's `-B`/`-A`), not whole files.
362+
363+
**Inbound links inform the classification, not the cleanup.** Removing a citation is always mechanical (drop the parenthetical, the bare entry, or the deferring clause). The judgment is upstream: given these citations, is Delete still right, or is Replace closer to right?
364+
365+
Classify each citation by what it does in its citing context:
366+
367+
- **Decorative** — principle stated inline, citation is a "see also" pointer or bare attribution. Delete is fine; clean up citations in the same commit.
368+
- **Substantive** — citing doc relies on the cited doc to provide content not stated inline (e.g., "see X for details on Y" with no inline Y). Signal Replace — write a successor at the same path, or **Keep with narrowed scope** if the doc's actual content is broader than its title implies.
369+
- **Mixed or unclear** — stale-mark.
370+
371+
In autofix mode, Delete + decorative cleanup is fine. Any substantive citation, or any genuine ambiguity, downgrades to stale-marking — writing a Replace successor is judgment-heavy and should not happen unattended.
372+
373+
**Auto-delete only when all three hold:**
374+
375+
- The implementation is gone (or fully superseded by a clearly better successor, or the doc is plainly redundant).
376+
- The problem domain is gone — the app no longer deals with what the learning addresses.
377+
- Inbound links are absent or unambiguously decorative.
378+
379+
If any condition fails, classify as Replace, Update, Consolidate, or stale-mark per the rules above. Do not delete a learning whose problem domain is still active or whose principles are cited substantively — fill the gap with a replacement instead.
362380

363381
## Pattern Guidance
364382

@@ -531,6 +549,12 @@ Do not let replacement subagents invent frontmatter fields, enum values, or sect
531549

532550
Delete only when a learning is clearly obsolete, redundant (with no unique content to merge), or its problem domain is gone. Do not delete a document just because it is old — age alone is not a signal.
533551

552+
Before unlinking the file, run a final inbound-link check across the repo's markdown content to catch any references missed during Phase 1 investigation. Prefer the platform's native content-search tool (e.g., Grep in Claude Code) for efficiency; use ranged or context-line reads around matches rather than loading whole files.
553+
554+
Each match is a citation that will dangle after delete. Cleanup is mechanical — Phase 2 already classified the citations and confirmed Delete was right. Don't re-litigate.
555+
556+
If any citation surfaces here that wasn't seen in Phase 1 and is anything other than unambiguously decorative (substantive or mixed/unclear), stop and reclassify: autofix mode stale-marks; interactive mode asks the user whether Replace fits. Only proceed with cleanup when all late-discovered citations are unambiguously decorative.
557+
534558
## Output Format
535559

536560
**The full report MUST be printed as markdown output.** Do not summarize findings internally and then output a one-liner. The report is the deliverable — print every section in full, formatted as readable markdown with headers, tables, and bullet points.

0 commit comments

Comments
 (0)