agentleFS
Bhanuj-AIBhanuj-AI/ai-governance-oss/skills/api-change/SKILL.md

api-change

Skill2 starsChanged 4 months agoApache-2.0View on GitHub

Implement or modify a AI Governance Control Plane REST API endpoint, request or response model, router, mapper, dependency, or HTTP error mapping. Use for backwards-compatible API additions, contract changes, pagination, authorization, idempotent write endpoints, and API-focused tests.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 7 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read root AGENTS.md and src/ai_governance/api/AGENTS.md.

    line 12
  2. Distinctive:

    Put validation and mapping in the adapter.

    line 18
  3. Distinctive:

    Add endpoint tests for the successful path, invalid input, authorization or tenant boundary, and stable error mapping.

    line 26
  4. Distinctive:

    Follow the existing decision-router shape.

    line 31
  5. Distinctive:

    Update OpenAPI summary and description with the actual contract.

    line 54
  6. Distinctive:

    Add a mapper rather than returning a domain or persistence object directly.

    line 57
  7. Distinctive:

    Run the targeted test for the changed router and any dependent service test.

    line 72
  8. Distinctive:

    Run the full relevant suite before handoff when the API change crosses a transport, service, persistence, or tenancy boundary.

    line 73

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “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 Change

Implement a REST change as a transport adapter over an application service.

Workflow

  1. Read root AGENTS.md and src/ai_governance/api/AGENTS.md. Read the service, tenancy, repository, or domain instructions for every layer changed.
  2. Inspect the existing router, request/response models, mapper, dependency provider, and closest API test before choosing the public contract.
  3. Preserve existing routes and fields. Add a versioned route or an optional field when a breaking change is not deliberately approved.
  4. Put validation and mapping in the adapter. Put business decisions in an application service; do not import database implementations into a router.
  5. Obtain context through approved dependencies. Pass the resolved context to every protected service call; never use an unverified tenant value from the body or query string.
  6. Bound and validate list pagination. Require authorization and an idempotency mechanism where a client or transport can plausibly retry a write.
  7. Add endpoint tests for the successful path, invalid input, authorization or tenant boundary, and stable error mapping.

Route pattern

Follow the existing decision-router shape. Adapt names and response types to the target capability; do not copy tenant identifiers from the request.

@router.get("/{decision_id}", response_model=DecisionResponse)
def get_decision(
    decision_id: str,
    service: Annotated[
        object, Depends(get_governance_decision_application_service)
    ],
    context=Depends(get_compatible_tenant_context),
) -> DecisionResponse:
    decision = service.get(decision_id, context)
    return DecisionApiMapper.to_decision_response(decision)

For a list endpoint, use a bounded FastAPI query parameter such as Query(default=50, ge=1, le=500) and pass the resolved context to the service.

Contract checklist

  • Declare request, success, and stable error response models.
  • Update OpenAPI summary and description with the actual contract.
  • Map internal exceptions at the HTTP boundary without exposing implementation details.
  • Add a mapper rather than returning a domain or persistence object directly.
  • Confirm state-changing routes are authorized, deterministic under a retry, and auditable through the service layer.

Verify

Choose the closest existing API test module and run it. These commands are known to exercise the current decision and policy API contracts:

uv run ruff check src/ai_governance/api
uv run pytest tests/api/test_decision_api.py
uv run pytest tests/api/test_policy_administration_api.py

Run the targeted test for the changed router and any dependent service test. Run the full relevant suite before handoff when the API change crosses a transport, service, persistence, or tenancy boundary.

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.