JSON API
A small, read-only API so AI tools and scripts can fetch rule sets the same way the builder UI does. No authentication. CORS is enabled (*), responses are cached on the CDN for five minutes, and everything is JSON (application/json).
Endpoints
| Method | Path | Returns |
|---|---|---|
| GET | /api/rules | List target tools and all rule sets (metadata only, no rule bodies). |
| GET | /api/rules/{id} | One rule set with its rules array and ready-to-use markdown `content`. |
List rule sets
GET /api/rules returns tool conventions and metadata for every curated rule set.
{
"name": "AI Rules Builder",
"endpoints": { "list": "GET /api/rules", "ruleSet": "GET /api/rules/{id}", "docs": "GET /api (HTML)" },
"tools": [
{ "id": "commandcode", "label": "Command Code", "files": ["AGENTS.md"] },
{ "id": "cursor", "label": "Cursor CLI", "files": [".cursor/rules/ai-rules.mdc", ".cursorrules"] }
…
],
"ruleSets": [
{ "id": "codestyle-typescript", "name": "TypeScript Style", "category": "Code Style",
"description": "Strict typing, unions over flags, and lean exports.", "signals": ["typescript"], "ruleCount": 9 }
…
]
}Fetch one rule set
GET /api/rules/codestyle-typescript returns the full rule set. The content field is markdown built to be appended to your rules file. Unknown ids return 404 with the list of available ids.
{
"id": "codestyle-typescript",
"name": "TypeScript Style",
"category": "Code Style",
"description": "Strict typing, unions over flags, and lean exports.",
"signals": ["typescript", "tslib", "swc"],
"ruleCount": 9,
"rules": [
"Keep `strict` TypeScript enabled; the build must pass with zero type errors.",
"Avoid `any` — use `unknown` at system boundaries and narrow it deliberately."
…
],
"content": "## TypeScript Style
- Keep `strict` TypeScript enabled; the build must pass with zero type errors.
- …"
}404 shape
{ "error": "Rule set "nonexistent" not found", "available": ["general-principles", …] }Usage from CLI tools
Point BASE at your deployed URL, then append rule sets to an AGENTS.md:
BASE="https://your-app.vercel.app" # Inspect the catalog curl -s "$BASE/api/rules" | jq -r '.ruleSets[].id' # Append a rule set to your rules file curl -s "$BASE/api/rules/security-web" | jq -r '.content' >> AGENTS.md