From cortex
This skill should be used when a long-lived canonical document (design doc, spec, architecture doc) states the same rule in multiple places and has produced propagation defects — a law updated in one place while another surface kept stale wording. Scaffolds a law registry (anchor regex, home, echo list) plus a mechanical verifier script. Trigger phrases include "add a law registry", "guard the doc", "echo map", "the doc drifted", or any second occurrence of a propagation defect in the same document.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cortex:law-registryThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**TL;DR**: When a canonical doc states a rule at one authoritative home plus N echo
TL;DR: When a canonical doc states a rule at one authoritative home plus N echo surfaces, every fold eventually updates the home while one echo keeps older wording. Convert echo-recall into lookup: give every load-bearing law a registry row (anchor regex · home section · echo list) and a ~90-line checker that asserts the anchor appears at every listed surface. Run it after every edit wave.
Adopt the registry when a document has produced two or more propagation defects (same rule, divergent wording across surfaces). Before that, the registry is ceremony; after that, every fold without it repeats the defect class. Origin evidence: five consecutive fold batches in a 2,000-line design doc each produced exactly this defect until the registry converted recall into lookup — and the mechanical guard then caught real misses for 11+ consecutive batches.
Do NOT point this at small or short-lived files. A README does not need a law registry. The trigger is distributed echoes in a long-lived artifact under active amendment.
Add an appendix section to the document:
## N. Law registry — echo map
| Law | Anchor (regex, `~` = alternation) | Home | Echo surfaces |
|---|---|---|---|
| SHORTNAME — one-line statement of the law | `anchor[- ]pattern~alternate wording` | 4 | 2, 7.3, 11 |
~ stands for
alternation (| collides with table delimiters).Generic template (parametrize DOC and the heading regex to the doc's numbering convention; ~90 lines total in the reference implementation):
"""Every registry law's anchor must appear in its home + every listed echo section."""
import re, sys
from pathlib import Path
DOC = Path("docs/plans/YOUR-CANONICAL-DOC.md")
HEADING = re.compile(r"^(#{2,3})\s+(\d+(?:\.\d+)?)[.\s]") # '## 7.' / '### 7.3'
REGISTRY_HEADING = re.compile(r"^##\s+N\.") # your appendix number
def split_sections(lines):
sections, current = {}, "0"
for line in lines:
m = HEADING.match(line)
if m: current = m.group(2)
sections.setdefault(current, []).append(line)
return {k: "\n".join(v) for k, v in sections.items()}
def parse_registry(lines):
rows, in_reg = [], False
for line in lines:
if REGISTRY_HEADING.match(line): in_reg = True; continue
if in_reg and line.startswith("## "): break
if not in_reg or not line.startswith("|"): continue
cells = [c.strip() for c in line.strip().strip("|").split("|")]
if len(cells) != 4 or cells[0].startswith("---") or cells[0] == "Law": continue
law, anchor_raw, home, echoes_raw = cells
rows.append((law, anchor_raw.strip("`").replace("~", "|"), home,
[e.strip() for e in echoes_raw.split(",") if e.strip()]))
return rows
def main():
lines = DOC.read_text(encoding="utf-8").splitlines()
sections, failures = split_sections(lines), []
for law, anchor, home, echoes in parse_registry(lines):
pat = re.compile(anchor)
for target in [home, *echoes]:
sec = sections.get(target)
if sec is None: failures.append(f"{law}: section {target} missing")
elif not pat.search(" ".join(sec.split())):
failures.append(f"{law}: anchor not found in section {target}")
print("FAILED:\n" + "\n".join(failures) if failures else "PASSED")
return 1 if failures else 0
if __name__ == "__main__": sys.exit(main())
Note the " ".join(sec.split()) — anchors must match across line-wrapped prose;
matching raw lines produces false negatives on wrapped text.
old wording~new wording lets a surface pass on the OLD wording alone,
silently certifying a law that changed. When a fold ADDS a requirement to an
existing law, give the new conjunct its own row with its own anchor.The same run-after-every-edit-wave posture supports other ~cheap mechanical guards; add them as the doc's failure modes earn them:
A doc under continuous amendment carries a current-state header (status line, items trail, where-to-look pointers) refreshed as part of every fold — the human approval gate reads the doc, and orientation is part of the artifact, not a courtesy. A fold that leaves the header stale is unfinished; treat the header as an implicit echo surface of every fold.
npx claudepluginhub crombieman/undercurrent-cortex --plugin cortexGuides collaborative design exploration before implementation: explores context, asks clarifying questions, proposes approaches, and writes a design doc for user approval.
Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
Resolves in-progress git merge or rebase conflicts by analyzing history, understanding intent, and preserving both changes where possible. Runs automated checks after resolution.