agentleFS
ultimatileultimatile/development-skills/skills/bug-to-contract/SKILL.md

bug-to-contract

Skill0 starsChanged 32 days agoMITView on GitHub

Promote a review finding or bug fix into a contract test that prevents the underlying invariant violation from recurring. Companion to finding-to-audit, which elevates to diff-time rules instead.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    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:

    When both are available, prefer review findings — a reviewer saying "this doesn't handle column-major layout" is a stronger signal than a …

    line 19
  2. Distinctive:

    Look for tests that verify the identified contract beyond the specific case:

    line 52
  3. Distinctive:

    If a test exists that covers the general contract, the contract is already guarded.

    line 58
  4. Distinctive:

    Write a test (or propose one) that verifies the general contract, not just the specific case that broke.

    line 74
  5. Distinctive:

    Vary the representation: If it's a layout bug, test with all valid layouts

    line 76
  6. Distinctive:

    Use multiple inputs: Not just the one that triggered the issue

    line 77
  7. Distinctive:

    Name the contract: If you can't name the implicit specification in one sentence, you haven't understood the issue yet.

    line 97

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

Bug-to-Contract

Review findings and bug fixes address symptoms. This skill asks: what implicit specification was violated, and is that specification now tested?

Inputs

This skill works from two kinds of input. The fix-commit lane uses a root on diff-root's consumer contract, halt included; the review-findings lane uses none.

InputWhat to collect
Review findingsActionable findings from any review pass (codex, Copilot, human reviewer) that resulted in code changes. The reviewer's framing of the issue.
Fix commitsBranch commits whose subject signals a fix: git log <root-rev>..HEAD --oneline --grep="fix" -i, then git show <sha>.

When both are available, prefer review findings — a reviewer saying "this doesn't handle column-major layout" is a stronger signal than a commit message.

Core procedure

1. Collect signals

From review findings:

  • For each actionable finding that resulted in a code change, note what the issue was and what changed.

From fix commits:

  • Examine the diff of each fix commit:
    git log <root-rev>..HEAD --oneline --grep="fix" -i
    git show <commit-sha>

2. Ask the contract question

For each signal, determine:

  1. What broke? — The specific symptom (wrong output, crash, silent corruption, reviewer complaint, etc.)
  2. What implicit specification was violated? — The unstated property that users expect to hold. This is the contract. Examples:
    • Memory layout should not affect computation results
    • Operation order in einsum should not affect results (up to floating-point tolerance)
    • Transpose is an involution: transpose(transpose(A)) == A
    • Scalar type promotion should be consistent across operations
    • Empty inputs should produce empty outputs with correct shape
  3. Is this contract already tested? — Search for existing tests that verify this property in general, not just the specific case that broke.

3. Search for existing contract tests

Look for tests that verify the identified contract beyond the specific case:

grep -r "test.*layout\|test.*order\|row_major.*column_major" --include="*.rs" tests/

If a test exists that covers the general contract, the contract is already guarded. Report this and stop.

4. Classify the contract

Identifying the category helps write a general test rather than a point fix test.

CategoryDescriptionExample
Representation invarianceResult is independent of internal representation choicesMemory layout, stride order, storage format
Algebraic identityMathematical property that must holdInvolution, associativity, commutativity
Structural preservationShape, type, or metadata properties preserved through operationsOutput shape matches specification, dtype preserved
Boundary behaviorCorrect handling of edge casesEmpty input, zero-size dimension, single element
Semantic equivalenceDifferent spellings of the same operation produce the same resulteinsum("ij,jk->ik", A, B) == matmul(A, B)

5. Propose the contract test

Write a test (or propose one) that verifies the general contract, not just the specific case that broke. The test should:

  • Vary the representation: If it's a layout bug, test with all valid layouts
  • Use multiple inputs: Not just the one that triggered the issue
  • State the contract explicitly: The test name and/or comment should name the property being verified

6. Check for related contracts

Once a contract is identified, look for related contracts in the same category. If memory layout invariance was violated for GEMM, it could also be violated for SVD, QR, eigendecomposition, solve, etc.

Propose tests for related operations if they are missing.

7. Report

Present to the user:

  1. The implicit contract that was violated (one sentence)
  2. Whether it was already tested (yes/no + evidence)
  3. Proposed contract test (code or description)
  4. Related contracts that may also be untested

Important principles

  • Name the contract: If you can't name the implicit specification in one sentence, you haven't understood the issue yet.
  • Patterns are escalation-worthy: A cluster of findings in the same category (e.g., three layout-related issues in one review cycle) indicates a systematically untested contract. Escalate this to the user.
  • Don't boil the ocean: One contract test per finding is enough.

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.