Skip to content
Back to skills

Api Contract Init

ASecurity

Generate API_CONTRACT.md by scanning existing routes and controllers

  • 4 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
developmentpythonrustgophpexpressfastapidjangoflaskrailsapi

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 12, 2026

npx -y skills add aibot88/sec_skill_store --skill api-contract-init --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Contract Init?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api Contract Init
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aibot88-api-contract-init/badge)](https://www.skillsdirectory.com/skills/aibot88-api-contract-init)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: api-contract-init
description: Generate API_CONTRACT.md by scanning existing routes and controllers
argument-hint: [shared|root — where to create the file]
---

Generate an `API_CONTRACT.md` by scanning the **real** codebase. Never fabricate endpoints or types.

## 1. Detect the backend stack

| File | Stack |
|---|---|
| `package.json` with `@nestjs/core` | NestJS |
| `package.json` with `express`/`fastify` | Express/Fastify |
| `composer.json` | CakePHP / Laravel |
| `pyproject.toml` or `requirements.txt` with `django`/`fastapi`/`flask` | Python |
| `go.mod` | Go |
| `Cargo.toml` with `actix`/`axum`/`rocket` | Rust |
| `Gemfile` with `rails` | Rails |

## 2. Scan routes and controllers

| Stack | Where to look |
|---|---|
| NestJS | `*.controller.ts` — decorators `@Get`, `@Post`, `@Put`, `@Delete`, `@Patch` |
| Express/Fastify | `routes/**`, `router/**` — `router.get()`, `app.post()`, etc. |
| CakePHP/Laravel | `*Controller.php` — public methods, `routes/*.php` |
| Django | `urls.py` — `urlpatterns`, `ViewSet` classes |
| FastAPI | `*.py` — `@app.get`, `@router.post`, etc. |
| Go | `*_handler.go`, `*_router.go` — `HandleFunc`, `mux.Handle` |
| Rails | `config/routes.rb` — resources, get/post/put/delete |
| Rust | `routes/*.rs` — handler functions, route macros |

## 3. For each endpoint, extract

- HTTP method and path
- Request body / query params (from DTOs, structs, dataclasses, type annotations)
- Response type (if detectable)
- Auth requirement (if detectable)
- If a type cannot be determined, write `// TODO: define type` — **NEVER fabricate**

## 4. Generate the contract

Use this format:

```markdown
# API Contract — [Project Name]

Source of truth for backend/frontend communication.

## Global Conventions
- Base URL: [detected or TODO]
- Auth: [detected or TODO]
- Response format: [detected or standard JSON]
- Error format: [detected or TODO]

## [Domain — grouped by controller/router]

### [METHOD] [path]

**Request:**
\`\`\`[lang]
[body type / query params]
\`\`\`

**Response:**
\`\`\`[lang]
[response type]
\`\`\`

**Auth:** [required/optional/none]
**Notes:** [if applicable]

---

## Changelog

| Date | Change | Side |
|------|--------|------|
| [today] | Initial generation from code | backend |
```

## 5. Placement

- If argument is `shared` or no argument: propose `shared/API_CONTRACT.md`
- If argument is `root`: propose `API_CONTRACT.md` at project root

**Present the generated contract and wait for user validation before writing.**

Files in this skill

  • SKILL.md2.5 KB
  • source.json593 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.