code-contracts

Records and verifies durable behavioral obligations as structured contracts beside source code.

9|Updated Jul 17, 2026
One-click install
npx skills add https://github.com/Yassimba/loom --skill code-contracts-yassimba
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-contracts
Source: https://github.com/Yassimba/loom/tree/main/skills/code-contracts
Command: npx skills add https://github.com/Yassimba/loom --skill code-contracts-yassimba

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Important behavioral assumptions, invariants, and guarantees often live only in developers' heads or scattered comments, so later changes silently break them. This Skill records those obligations as structured, discoverable contracts attached to declarations or directories, and verifies that code changes stay compliant. ## Core Features & Use Cases - Contract authoring: Write @cc contracts in doc comments or directory-level CONTRACTS files, with optional owner, notify, label, and test metadata. - Obligation sweep: Systematically surface assumptions, invariants, error behavior, and side effects that future changes must preserve before implementing or reviewing code. - Verification and review: Run read-only contract reviews over diffs or audits, tracing callers and checking compliance with loom contracts commands. - Use Case: Before refactoring a payment module, run loom contracts affected --base main to list every obligation the change touches, then verify each one is satisfied or intentionally updated. ## Quick Start Use the code-contracts skill to record the invariants of this function as a contract and verify the current changes comply with it.

Frequently Asked Questions about code-contracts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a code contract to a function?

Add an `@cc` directive with a unique contract ID in the documentation comment or docstring immediately above the declaration, followed by prose stating one concrete obligation. For directory-wide rules, place the contract in a `CONTRACTS` file that applies to that directory and its descendants.

How do I verify code changes against existing contracts?

Run `loom contracts affected --base <merge_base>` to list candidate obligations for a diff, then trace the implementation against each contract. Use `loom contracts check` for syntax validation and `loom contracts diff` to detect reworded or removed contracts.

Which languages does loom contracts support?

The loom contracts tooling supports TypeScript (.ts, .tsx, .mts, .cts), Python (.py, .pyi), Rust, and CONTRACTS files. For unsupported languages, use directory contracts or inspect declaration comments manually and disclose the tooling limit.

Are code contracts enforced at runtime?

No. Contracts are structured natural-language specifications, not runtime checks or formal proofs. Keep tests, types, and validation that enforce the same behavior mechanically, and link them via the optional `test` metadata key.

When should a proposed contract be rejected?

Keep a contract only when a reviewer can identify both a concrete change that would violate it and an alternative implementation that would satisfy it. Omit purpose-only documentation, rationale, and accidental implementation details that impose no real constraint.