agentleFS
DariuszDuszaDariuszDusza/agentic-workflow-foundry/.agents/skills/api-code-generation/SKILL.md

api-code-generation

Skill1 starsChanged 26 days agoApache-2.0View on GitHub

Use when generating API code from a contract or by pattern, meaning handlers or clients generated from a schema, scaffolding a new resource from a sibling, regenerating an SDK, or changing the schema or generator config itself. Keeps the contract the single source, generated output reproducible, and breaking changes explicit.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    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:

    Do not invent the contract: Every endpoint, field and status code comes from the schema or the operator's request.

    line 32
  2. Distinctive:

    Follow the sibling: When scaffolding by pattern, copy the shape of the newest good sibling, not the oldest: old ones carry the conventions …

    line 42

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

API code generation

Required context

  1. .agents/areas.json: the area the generated code lands in, its guardrail and its verify command.
  2. .agents/guardrails/code-style.md: what generated and hand-written code must both satisfy.
  3. .agents/skills/secure-api-endpoint/SKILL.md: the security rules still apply to generated endpoints; a generator does not know your authorization model.
  4. .agents/policy/data-classification.yml: which fields are confidential and may not be exposed.
  5. The contract (contracts/openapi.json in this repository) and the generator's config, and one sibling resource already generated the same way.

The rules that bite

  • The contract is the single source. Change the schema, then regenerate. A hand edit to generated output is lost on the next run and, until then, disagrees with the contract that clients were built from.
  • Generated files say so. Each carries a header naming its generator and input, so a reviewer and a merge resolver know to regenerate rather than hand-merge.
  • Reproducible output. Pin the generator's version, commit its input and its output in the same change, and keep a check that regenerates and diffs, so drift fails a gate instead of a client.
  • The route table matches the contract. tools/check-contract.py compares what make -C app/api routes-json prints with contracts/openapi.json: every method, path, operation id and public or protected standing. Change the contract first, in the same change as the route.
  • Do not invent the contract. Every endpoint, field and status code comes from the schema or the operator's request. A plausible extra field is a public commitment nobody made.
  • Generated is not authorized. Scaffolding produces a handler; it does not produce the authorization check, the query scoping or the page-size clamp. Add them and test them as for a hand-written endpoint.
  • Public identifiers only. A generated serializer exposes what the schema says. Check the schema does not expose an internal id, a token or a confidential field.
  • Breaking changes are explicit. Removing or renaming a field, narrowing a type, adding a required input or changing a status code breaks existing clients. It needs a new version or a recorded decision, never a quiet regeneration.
  • Follow the sibling. When scaffolding by pattern, copy the shape of the newest good sibling, not the oldest: old ones carry the conventions the codebase has since dropped.
  • Adding or upgrading a generator is a dependency change, which is an escalation.

Verify

<the regenerate command, then git diff --exit-code on the output>   # generated matches the contract
<the area's test runner, filtered to the new resource>
make verify

Then the area's verify command exactly as .agents/areas.json declares it; tests follow .agents/skills/api-test-generation/SKILL.md. Reviewers: api-standards-reviewer and code-reviewer; security-data-reviewer when a field's data class changes.

Escalate when

  • The change breaks a public contract clients depend on.
  • A generator or its runtime is added, replaced or upgraded (a dependency change).
  • The schema would expose a confidential or secret data class.
  • The contract and the operator's request disagree: ask which one is right, do not pick.

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.