agentleFS
phase-rsphase-rs/phase/.claude/skills/validate-cr-annotations/SKILL.md

validate-cr-annotations

Skill331 starsChanged 4 months agoApache-2.0View on GitHub

Use when writing, modifying, or reviewing CR (Comprehensive Rules) annotations in engine code — any time a `// CR` or `/// CR` comment is added, changed, or audited. Ensures every CR number is verified against `docs/MagicCompRules.txt` before it enters the codebase.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the grep returns a matching line → the rule exists.

    line 22
  2. Distinctive:

    If the grep returns nothing → STOP.

    line 23
  3. Distinctive:

    When adding several CR annotations in one change, verify all at once:

    line 27
  4. Distinctive:

    After writing CR annotations, ask yourself:

    line 125

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

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

CR Annotation Validation

This skill enforces the mandatory verification protocol for MTG Comprehensive Rules annotations. Every CR number is verified by grep before it is written. No exceptions.


Verification Protocol

For every CR number you are about to write, run this BEFORE writing:

grep -n "^NNN.X" docs/MagicCompRules.txt

Where NNN.X is the rule number (e.g., 702.33d, 613.1f, 120.2a).

  • If the grep returns a matching line → the rule exists. Read the text to confirm it matches your intent.
  • If the grep returns nothing → STOP. Do not write the annotation. The rule number is wrong.

Batch verification for multiple annotations

When adding several CR annotations in one change, verify all at once:

for ref in "702.33d" "613.1f" "120.2a"; do
  echo "=== CR $ref ==="
  grep -n "^${ref}" docs/MagicCompRules.txt | head -2
done

Format Rules

FormatWhen to useExample
Inline commentImplementation code// CR 704.5a: A player with 0 or less life loses the game.
Doc commentPublic items (functions, types, variants)/// CR 704: Checks state-based actions.
Combined +Multiple interacting rules// CR 702.2c + CR 702.19b: Deathtouch with trample assigns lethal (1) to each blocker.
Combined /Alternative/overlapping rules// CR 704.3 / CR 800.4: SBAs may have ended the game during phase auto-advance.

Mandatory rules:

  • Prefix is always CR — never Rule, MTG Rule, or bare numbers
  • Number format regex: CR \d{3}(\.\d+[a-z]?)?
  • Description is mandatory — a bare CR 704.5a with no explanation is not acceptable
  • Placement: directly above or inline with the code that implements the rule

Known Hallucination Patterns

These are the error classes found in the full audit of this codebase. Watch for them:

1. Off-by-one section numbers (most common)

The 702.x keyword ability numbers are arbitrary sequential assignments. There is no mnemonic anchor. Common confusions:

KeywordWRONGCORRECT
KickerCR 702.32 (= Fading)CR 702.33
FlashCR 702.8c/d (don't exist)CR 702.8a/b (only two sub-rules)
ExploitCR 702.110c (doesn't exist)CR 702.110a/b (only two sub-rules)
ShroudCR 114.x (= Emblems!)CR 702.18a

Rule: Never assume you know a 702.x number. Always grep.

2. Hallucinated lettered sub-rules

A parent rule exists but the lettered sub-rule does not:

WRONGWHYCORRECT
CR 613.3d613.3 has no sub-rulesCR 613.1d (Layer 4 types)
CR 613.3f613.3 has no sub-rulesCR 613.1f (Layer 6 abilities)
CR 716.5/716.6716 ends at 716.4CR 716.2a (class level)
CR 719.4719 ends at 719.3cCR 719.3c (Case solved)
CR 118.12d118.12 has a/b onlyCR 118.5 (zero costs)
CR 120.1bdoesn't existCR 120.2b (noncombat damage)

Rule: After grepping, also check that the sub-rule letter exists — grep -n "^613.1[a-g]" docs/MagicCompRules.txt to see all sub-rules.

3. Wrong section entirely

WRONGWhat it actually isIntentCORRECT
CR 114.xEmblemsTargetingCR 115.x
CR 711.xLeveler cardsDFC transformCR 712.x
CR 702.32FadingKickerCR 702.33

Rule: After finding the rule text, read the first sentence to confirm the section topic matches your intent.


Frequently Referenced Sections

Quick-reference for sections that are commonly annotated in this codebase:

SectionTopicKey sub-rules
120Damage120.1 (what can be damaged), 120.2a (combat), 120.2b (noncombat), 120.3a-h (results), 120.4 (sequence)
601Casting spells601.2a-h (steps), 601.2f (hybrid/Phyrexian)
603Triggered abilities603.2 (when triggered), 603.3 (APNAP stack order), 603.4 (intervening-if)
608Resolving spells/abilities608.2b (partial fizzle), 608.2e (modes)
613Continuous effects / Layers613.1a-g (layers 1-7), 613.2a-c (layer 1 sublayers), 613.4a-d (layer 7 sublayers)
614Replacement effects614.1a (definition — "instead"), 614.4 (must pre-exist), 614.15 (self-replacement effects)
616Multiple replacements616.1a (self-replacement priority), 616.1b-d (ordering), 616.1e (player choice)
700General700.4 (damage memory)
701Keyword actionsSequential numbers — always verify
702Keyword abilitiesSequential numbers — always verify
704State-based actions704.5a-y (individual SBAs)
711Leveler cardsNot DFCs!
712Double-faced cards712.2 (nonmodal/transform), 712.3 (modal)
716Class cards716.2a (level ability), 716.2b-d (level designation)
719Case cards719.3a (to solve), 719.3b (solved designation), 719.3c (solved ability)

Self-Check Before Finalizing

After writing CR annotations, ask yourself:

  1. Did I grep every CR number? — No number enters code unverified.
  2. Does the rule text match my description? — Read the actual CR text, not just confirm the number exists.
  3. Is the sub-rule letter real? — Parent existing doesn't mean child exists.
  4. Is this the right section? — CR 114 ≠ CR 115; CR 711 ≠ CR 712.
  5. Did I include a description? — Bare CR NNN.Xa without explanation is not acceptable.
  6. Is there an existing annotation nearby I should update? — Old formats (Rule 514.1, MTG Rule 727) get migrated to CR format.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.