agentleFS
IcodeNetIcodeNet/agent-skills/skills/contract-guard/SKILL.md

contract-guard

Skill0 starsChanged 4 months agoMITView on GitHub

Guard external contracts before changing them. Use BEFORE modifying anything consumed outside the current codebase or by clients you do not control: public/exported APIs, REST/GraphQL endpoints and their request/response shapes, published package entry points, database schemas read by other services, event/message payloads, webhooks, or generated client types. Also use when reviewing a diff that touches such surfaces. Prevents silently shipping breaking changes to external consumers.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the change only touches code whose callers all live in this repo and are updated in the same change, this skill does not apply — …

    line 28
  2. Distinctive:

    Before editing, establish who consumes the thing you're about to change:

    line 34
  3. Distinctive:

    Search the repo for callers.

    line 36
  4. Distinctive:

    Look for contract artifacts: OpenAPI/GraphQL schemas, protobuf files, generated client packages, versioned API docs, consumer contract …

    line 37
  5. Distinctive:

    Ask: "can every consumer be updated in this same change?" If no (external clients, mobile apps with old versions, other teams, published …

    line 38
  6. Very specific:

    Use references/breaking-change-taxonomy.md for the full table.

    line 44
  7. Distinctive:

    Never apply a breaking change in place.

    line 52
  8. Very specific:

    Expand–migrate–contract: add the new field/endpoint/column alongside the old, migrate consumers, remove the old one later (separately).

    line 54
  9. Distinctive:

    Negotiate: if consumers are known and coordinated, an agreed synchronized change — recorded, not assumed.

    line 57
  10. Distinctive:

    If none is possible in scope, do not make the change — report the conflict and the recommended strategy instead.

    line 59
  11. Distinctive:

    Run existing contract tests (Pact, schema validation) — add one when the surface has none and you're touching it.

    line 65
  12. Very specific:

    Every change touching a guarded surface ends with an explicit statement in the PR/commit/summary:

    line 72
  13. Very specific:

    Do not resolve ambiguity in favor of convenience.

    line 81

≈ “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

Contract Guard

External consumers cannot be refactored by you. Any interface they depend on is a contract: change it deliberately and compatibly, or version it — never silently.

When this applies

Trigger this skill before editing (or when reviewing edits to):

  • Exported symbols of a published package or shared library
  • HTTP/GraphQL/gRPC endpoints: paths, methods, params, request/response shapes, status codes, error formats
  • Database schemas other services or reports read
  • Event, queue, or webhook payloads
  • OpenAPI/GraphQL/protobuf schema files and generated clients
  • File formats or CLI output that downstream tooling parses

If the change only touches code whose callers all live in this repo and are updated in the same change, this skill does not apply — refactor freely.

Workflow

1. Inventory the contract surface

Before editing, establish who consumes the thing you're about to change:

  • Search the repo for callers; check whether the symbol/endpoint is exported, published, or documented publicly.
  • Look for contract artifacts: OpenAPI/GraphQL schemas, protobuf files, generated client packages, versioned API docs, consumer contract tests (e.g. Pact).
  • Ask: "can every consumer be updated in this same change?" If no (external clients, mobile apps with old versions, other teams, published packages) → the surface is guarded.

State the finding explicitly: Contract surface: <what> — consumers: <who/unknown>.

2. Classify the intended change

Use references/breaking-change-taxonomy.md for the full table. Summary:

  • Compatible (safe): adding optional fields, adding new endpoints/methods, widening accepted input, adding enum handling, new optional params with defaults.
  • Breaking: removing/renaming anything; changing a field's type or nullability; adding a required input; narrowing accepted values; changing error shapes, status codes, sort order, pagination, or semantics callers rely on; changing serialization defaults.
  • Ambiguous: behavior changes that were arguably bugs — treat as potentially breaking, flag for human decision.

3. Breaking → stop and choose a compatibility strategy

Never apply a breaking change in place. Options, in order of preference:

  1. Expand–migrate–contract: add the new field/endpoint/column alongside the old, migrate consumers, remove the old one later (separately).
  2. Version the surface: /v2 endpoint, new event version, semver major bump for packages.
  3. Deprecate with a window: mark deprecated, keep serving, document the removal date.
  4. Negotiate: if consumers are known and coordinated, an agreed synchronized change — recorded, not assumed.

If none is possible in scope, do not make the change — report the conflict and the recommended strategy instead.

4. Verify with contract evidence

Claims of compatibility need proof, not inspection:

  • Run existing contract tests (Pact, schema validation) — add one when the surface has none and you're touching it.
  • Diff schema artifacts old-vs-new (e.g. oasdiff for OpenAPI, buf breaking for protobuf, migration dry-run for SQL) when tooling exists.
  • Compile/type-check in-repo consumers and any reachable generated clients.
  • For serialized payloads: round-trip a captured real payload from before the change through the new code.

5. Sign off with a compatibility statement

Every change touching a guarded surface ends with an explicit statement in the PR/commit/summary:

Contract impact: [none | compatible additions | breaking — strategy: <versioning/expand-contract/deprecation>]. Evidence: <tests/diff command run>.

Constraints

  • Absence of a schema file does not mean absence of a contract — consumers bind to observed behavior.
  • "The tests pass" is insufficient when no test encodes the external contract; say so and add one.
  • Renames are removals. A rename of anything externally visible is a breaking change, full stop.
  • Do not resolve ambiguity in favor of convenience; flag Potentially breaking — review required with the evidence.

Verification

  • Contract surface and consumers stated before the edit
  • Change classified against the taxonomy
  • Breaking changes have an explicit compatibility strategy (or were not made)
  • Contract evidence produced (test, schema diff, consumer compile, or payload round-trip)
  • Compatibility statement included in the final summary

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.