@caddis/cli 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +150 -1
- package/bundles/antigravity-plugin/agents/code-reviewer.md +47 -0
- package/bundles/antigravity-plugin/agents/preflight.md +53 -0
- package/bundles/antigravity-plugin/guard_agy.py +338 -0
- package/bundles/antigravity-plugin/hooks.json +36 -0
- package/bundles/antigravity-plugin/mcp_config.json +8 -0
- package/bundles/antigravity-plugin/mcp_ping_server.py +55 -0
- package/bundles/antigravity-plugin/plugin.json +5 -0
- package/bundles/antigravity-plugin/session_end_agy.py +57 -0
- package/bundles/antigravity-plugin/skills/_registry.md +115 -0
- package/bundles/antigravity-plugin/skills/add-rules/SKILL.md +45 -0
- package/bundles/antigravity-plugin/skills/api-design/SKILL.md +249 -0
- package/bundles/antigravity-plugin/skills/backend-development/SKILL.md +305 -0
- package/bundles/antigravity-plugin/skills/best-practices/SKILL.md +500 -0
- package/bundles/antigravity-plugin/skills/best-practices/agents/best-practices-referencer.md +263 -0
- package/bundles/antigravity-plugin/skills/best-practices/agents/codebase-context-builder.md +326 -0
- package/bundles/antigravity-plugin/skills/best-practices/agents/task-intent-analyzer.md +245 -0
- package/bundles/antigravity-plugin/skills/best-practices/references/anti-patterns.md +571 -0
- package/bundles/antigravity-plugin/skills/best-practices/references/before-after-examples.md +1114 -0
- package/bundles/antigravity-plugin/skills/best-practices/references/best-practices-guide.md +513 -0
- package/bundles/antigravity-plugin/skills/best-practices/references/common-workflows.md +692 -0
- package/bundles/antigravity-plugin/skills/best-practices/references/prompt-patterns.md +547 -0
- package/bundles/antigravity-plugin/skills/brainstorming/SKILL.md +57 -0
- package/bundles/antigravity-plugin/skills/ci-cd-pipeline/SKILL.md +315 -0
- package/bundles/antigravity-plugin/skills/code-documentation/SKILL.md +271 -0
- package/bundles/antigravity-plugin/skills/code-review/SKILL.md +122 -0
- package/bundles/antigravity-plugin/skills/codebase-audit/SKILL.md +204 -0
- package/bundles/antigravity-plugin/skills/context-curator/SKILL.md +157 -0
- package/bundles/antigravity-plugin/skills/cross-review/SKILL.md +40 -0
- package/bundles/antigravity-plugin/skills/css-architecture/SKILL.md +305 -0
- package/bundles/antigravity-plugin/skills/css-architecture/references/RESPONSIVE-DESIGN.md +604 -0
- package/bundles/antigravity-plugin/skills/database-design/SKILL.md +177 -0
- package/bundles/antigravity-plugin/skills/db-diagram/SKILL.md +148 -0
- package/bundles/antigravity-plugin/skills/db-diagram/scripts/sql_to_graph.py +1212 -0
- package/bundles/antigravity-plugin/skills/digress/SKILL.md +61 -0
- package/bundles/antigravity-plugin/skills/draw-io/SKILL.md +162 -0
- package/bundles/antigravity-plugin/skills/draw-io/references/aws-icons.md +677 -0
- package/bundles/antigravity-plugin/skills/draw-io/references/layout-guidelines.md +142 -0
- package/bundles/antigravity-plugin/skills/draw-io/references/troubleshooting.md +118 -0
- package/bundles/antigravity-plugin/skills/draw-io/references/workflows.md +103 -0
- package/bundles/antigravity-plugin/skills/draw-io/scripts/convert-drawio-to-png.sh +25 -0
- package/bundles/antigravity-plugin/skills/draw-io/scripts/find_aws_icon.py +79 -0
- package/bundles/antigravity-plugin/skills/error-handling/SKILL.md +260 -0
- package/bundles/antigravity-plugin/skills/excalidraw-db/SKILL.md +38 -0
- package/bundles/antigravity-plugin/skills/fastapi-dev/SKILL.md +300 -0
- package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +198 -0
- package/bundles/antigravity-plugin/skills/frontend-design/SKILL.md +193 -0
- package/bundles/antigravity-plugin/skills/frontend-design/references/my-tech-stack.md +127 -0
- package/bundles/antigravity-plugin/skills/gh-cli/SKILL.md +195 -0
- package/bundles/antigravity-plugin/skills/git-commit/SKILL.md +285 -0
- package/bundles/antigravity-plugin/skills/golden-plan/SKILL.md +577 -0
- package/bundles/antigravity-plugin/skills/handoff/SKILL.md +100 -0
- package/bundles/antigravity-plugin/skills/implement/SKILL.md +114 -0
- package/bundles/antigravity-plugin/skills/javascript-typescript/SKILL.md +142 -0
- package/bundles/antigravity-plugin/skills/kb/SKILL.md +60 -0
- package/bundles/antigravity-plugin/skills/mermaid-db/SKILL.md +33 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/SKILL.md +236 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/ENHANCEMENTS.md +264 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/MERMAID-SUMMARY.md +137 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/advanced-features.md +556 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/architecture-diagrams.md +192 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/c4-diagrams.md +410 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/class-diagrams.md +361 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/erd-diagrams.md +510 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/flowcharts.md +450 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/sequence-diagrams.md +394 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/troubleshooting.md +335 -0
- package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/workflows.md +418 -0
- package/bundles/antigravity-plugin/skills/migrate-dir/SKILL.md +68 -0
- package/bundles/antigravity-plugin/skills/mockup/SKILL.md +242 -0
- package/bundles/antigravity-plugin/skills/particle-art/SKILL.md +243 -0
- package/bundles/antigravity-plugin/skills/particle-art/references/canvas-utils.ts +171 -0
- package/bundles/antigravity-plugin/skills/particle-art/references/dot-field.template.tsx +203 -0
- package/bundles/antigravity-plugin/skills/particle-art/references/flow-field.template.tsx +263 -0
- package/bundles/antigravity-plugin/skills/particle-art/references/node-shape.template.tsx +261 -0
- package/bundles/antigravity-plugin/skills/particle-art/references/shape-sampler.ts +281 -0
- package/bundles/antigravity-plugin/skills/particle-art/references/stipple-morph.template.tsx +167 -0
- package/bundles/antigravity-plugin/skills/particle-art/references/stipple.template.tsx +175 -0
- package/bundles/antigravity-plugin/skills/particle-art/references/trail-ghost.template.tsx +266 -0
- package/bundles/antigravity-plugin/skills/particle-art/references/usage-examples.md +320 -0
- package/bundles/antigravity-plugin/skills/playwright/API_REFERENCE.md +653 -0
- package/bundles/antigravity-plugin/skills/playwright/SKILL.md +454 -0
- package/bundles/antigravity-plugin/skills/playwright/lib/helpers.js +441 -0
- package/bundles/antigravity-plugin/skills/playwright/package.json +26 -0
- package/bundles/antigravity-plugin/skills/playwright/run.js +228 -0
- package/bundles/antigravity-plugin/skills/prd/SKILL.md +107 -0
- package/bundles/antigravity-plugin/skills/preflight/SKILL.md +435 -0
- package/bundles/antigravity-plugin/skills/python/SKILL.md +388 -0
- package/bundles/antigravity-plugin/skills/react-best-practices/SKILL.md +269 -0
- package/bundles/antigravity-plugin/skills/react-dev/README.md +404 -0
- package/bundles/antigravity-plugin/skills/react-dev/SKILL.md +459 -0
- package/bundles/antigravity-plugin/skills/react-dev/examples/generic-components.md +579 -0
- package/bundles/antigravity-plugin/skills/react-dev/examples/server-components.md +579 -0
- package/bundles/antigravity-plugin/skills/react-dev/references/event-handlers.md +574 -0
- package/bundles/antigravity-plugin/skills/react-dev/references/hooks.md +456 -0
- package/bundles/antigravity-plugin/skills/react-dev/references/react-19-patterns.md +638 -0
- package/bundles/antigravity-plugin/skills/react-dev/references/react-router.md +1002 -0
- package/bundles/antigravity-plugin/skills/react-dev/references/tanstack-router.md +587 -0
- package/bundles/antigravity-plugin/skills/refactoring/SKILL.md +486 -0
- package/bundles/antigravity-plugin/skills/resume/SKILL.md +36 -0
- package/bundles/antigravity-plugin/skills/security-review/SKILL.md +196 -0
- package/bundles/antigravity-plugin/skills/setup-project-ai/SKILL.md +61 -0
- package/bundles/antigravity-plugin/skills/ship/SKILL.md +107 -0
- package/bundles/antigravity-plugin/skills/ship-merge/SKILL.md +103 -0
- package/bundles/antigravity-plugin/skills/ship-pr/SKILL.md +102 -0
- package/bundles/antigravity-plugin/skills/skill-creator/LICENSE.txt +202 -0
- package/bundles/antigravity-plugin/skills/skill-creator/SKILL.md +491 -0
- package/bundles/antigravity-plugin/skills/skill-creator/agents/analyzer.md +274 -0
- package/bundles/antigravity-plugin/skills/skill-creator/agents/comparator.md +202 -0
- package/bundles/antigravity-plugin/skills/skill-creator/agents/grader.md +223 -0
- package/bundles/antigravity-plugin/skills/skill-creator/assets/eval_review.html +146 -0
- package/bundles/antigravity-plugin/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/bundles/antigravity-plugin/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/bundles/antigravity-plugin/skills/skill-creator/references/schemas.md +430 -0
- package/bundles/antigravity-plugin/skills/skill-creator/scripts/__init__.py +0 -0
- package/bundles/antigravity-plugin/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/bundles/antigravity-plugin/skills/skill-creator/scripts/generate_report.py +326 -0
- package/bundles/antigravity-plugin/skills/skill-creator/scripts/improve_description.py +247 -0
- package/bundles/antigravity-plugin/skills/skill-creator/scripts/package_skill.py +136 -0
- package/bundles/antigravity-plugin/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/bundles/antigravity-plugin/skills/skill-creator/scripts/run_eval.py +310 -0
- package/bundles/antigravity-plugin/skills/skill-creator/scripts/run_loop.py +328 -0
- package/bundles/antigravity-plugin/skills/skill-creator/scripts/utils.py +47 -0
- package/bundles/antigravity-plugin/skills/sql/SKILL.md +321 -0
- package/bundles/antigravity-plugin/skills/tdd/SKILL.md +37 -0
- package/bundles/antigravity-plugin/skills/tdd-workflow/SKILL.md +188 -0
- package/bundles/antigravity-plugin/skills/technical-writing/SKILL.md +286 -0
- package/bundles/antigravity-plugin/skills/test-strategy/SKILL.md +155 -0
- package/bundles/antigravity-plugin/skills/ui-brief/SKILL.md +84 -0
- package/bundles/antigravity-plugin/skills/ui-review/SKILL.md +176 -0
- package/bundles/antigravity-plugin/skills/ui-review/references/framework-fixes.md +471 -0
- package/bundles/antigravity-plugin/skills/ui-review/references/visual-checklist.md +236 -0
- package/bundles/antigravity-plugin/skills/usage-review/SKILL.md +77 -0
- package/bundles/antigravity-plugin/skills/use-model/SKILL.md +64 -0
- package/bundles/antigravity-plugin/skills/using-git-worktrees/SKILL.md +217 -0
- package/bundles/antigravity-plugin/skills/version/SKILL.md +18 -0
- package/bundles/antigravity-plugin/skills/warm-editorial-ui/DESIGN_TOKENS.md +487 -0
- package/bundles/antigravity-plugin/skills/warm-editorial-ui/IMPLEMENTATION_GUIDE.md +177 -0
- package/bundles/antigravity-plugin/skills/warm-editorial-ui/SKILL.md +732 -0
- package/bundles/antigravity-plugin/skills/webapp-testing/LICENSE.txt +202 -0
- package/bundles/antigravity-plugin/skills/webapp-testing/SKILL.md +97 -0
- package/bundles/antigravity-plugin/skills/webapp-testing/examples/console_logging.py +35 -0
- package/bundles/antigravity-plugin/skills/webapp-testing/examples/element_discovery.py +40 -0
- package/bundles/antigravity-plugin/skills/webapp-testing/examples/static_html_automation.py +33 -0
- package/bundles/antigravity-plugin/skills/webapp-testing/scripts/with_server.py +106 -0
- package/bundles/antigravity-plugin/skills/windows-deployment/SKILL.md +880 -0
- package/bundles/antigravity-plugin/skills/writing-plans/SKILL.md +384 -0
- package/bundles/antigravity-plugin/statusline-command-agy.sh +91 -0
- package/bundles/antigravity-plugin/warm_start_agy.py +149 -0
- package/bundles/manifest.json +6 -0
- package/dist/cli.js +5363 -0
- package/package.json +61 -4
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Minimal self-contained MCP stdio server (raw JSON-RPC 2.0, zero dependencies).
|
|
3
|
+
|
|
4
|
+
Ships in the caddis agy plugin to prove the MCP wiring end-to-end without pulling in the `mcp`
|
|
5
|
+
package or any retired server (junai-mcp is gone). Exposes ONE tool, `caddis_ping`, which returns
|
|
6
|
+
the marker `CADDIS-MCP-OK`. Transport: newline-delimited JSON-RPC on stdin/stdout (MCP stdio).
|
|
7
|
+
"""
|
|
8
|
+
import json
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _send(msg: dict) -> None:
|
|
13
|
+
sys.stdout.write(json.dumps(msg) + "\n")
|
|
14
|
+
sys.stdout.flush()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main() -> None:
|
|
18
|
+
for line in sys.stdin:
|
|
19
|
+
line = line.strip()
|
|
20
|
+
if not line:
|
|
21
|
+
continue
|
|
22
|
+
try:
|
|
23
|
+
req = json.loads(line)
|
|
24
|
+
except json.JSONDecodeError:
|
|
25
|
+
continue
|
|
26
|
+
mid = req.get("id")
|
|
27
|
+
method = req.get("method")
|
|
28
|
+
if method == "initialize":
|
|
29
|
+
_send({"jsonrpc": "2.0", "id": mid, "result": {
|
|
30
|
+
"protocolVersion": "2024-11-05",
|
|
31
|
+
"capabilities": {"tools": {}},
|
|
32
|
+
"serverInfo": {"name": "caddis", "version": "0.1.0"},
|
|
33
|
+
}})
|
|
34
|
+
elif method == "tools/list":
|
|
35
|
+
_send({"jsonrpc": "2.0", "id": mid, "result": {"tools": [{
|
|
36
|
+
"name": "caddis_ping",
|
|
37
|
+
"description": "Health-check tool — returns a caddis marker so MCP wiring can be verified.",
|
|
38
|
+
"inputSchema": {"type": "object", "properties": {}},
|
|
39
|
+
}]}})
|
|
40
|
+
elif method == "tools/call":
|
|
41
|
+
name = (req.get("params") or {}).get("name")
|
|
42
|
+
if name == "caddis_ping":
|
|
43
|
+
_send({"jsonrpc": "2.0", "id": mid, "result": {
|
|
44
|
+
"content": [{"type": "text", "text": "CADDIS-MCP-OK"}]
|
|
45
|
+
}})
|
|
46
|
+
else:
|
|
47
|
+
_send({"jsonrpc": "2.0", "id": mid, "error": {"code": -32601, "message": f"unknown tool: {name}"}})
|
|
48
|
+
elif method and method.startswith("notifications/"):
|
|
49
|
+
pass # notifications get no response
|
|
50
|
+
elif mid is not None:
|
|
51
|
+
_send({"jsonrpc": "2.0", "id": mid, "error": {"code": -32601, "message": f"method not found: {method}"}})
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
main()
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""caddis `session_end` hook for agy (Antigravity) — Stop event.
|
|
3
|
+
|
|
4
|
+
Ports claude-harness/hooks/session_end.py to agy's contract. On Stop, appends ONE session-end record to
|
|
5
|
+
the workspace's usage log (`<workspace>/.caddis/usage-log.jsonl`, or `.claudster/` if the repo still lives
|
|
6
|
+
there). Self-contained (the agy bundle does not ship claudster_config.py), stdlib-only, and fully defensive:
|
|
7
|
+
a Stop hook must never fail the turn, and must not print a non-JSON line to stdout (agy parses Stop-hook
|
|
8
|
+
stdout as a `{"decision":…}` object — a stray string trips its "unsupported hook decision" path). So this
|
|
9
|
+
does a pure side effect and prints NOTHING.
|
|
10
|
+
|
|
11
|
+
agy Stop stdin (camelCase protojson):
|
|
12
|
+
{"executionNum":N, "terminationReason":"model_stop|max_steps_exceeded|error", "error":"",
|
|
13
|
+
"fullyIdle":true, "conversationId":"…", "workspacePaths":["…"], "transcriptPath":"…", "modelName":"…"}
|
|
14
|
+
"""
|
|
15
|
+
import json
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
from datetime import datetime, timezone
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _artifact_root(root: str) -> str:
|
|
22
|
+
"""Write where the repo lives: prefer .caddis, keep .claudster if that's what the repo has."""
|
|
23
|
+
for name in (".caddis", ".claudster"):
|
|
24
|
+
path = os.path.join(str(root), name)
|
|
25
|
+
if os.path.isdir(path):
|
|
26
|
+
return path
|
|
27
|
+
return os.path.join(str(root), ".caddis")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def main() -> None:
|
|
31
|
+
try:
|
|
32
|
+
data = json.load(sys.stdin)
|
|
33
|
+
except Exception:
|
|
34
|
+
data = {}
|
|
35
|
+
try:
|
|
36
|
+
workspaces = data.get("workspacePaths") or []
|
|
37
|
+
workspace = workspaces[0] if workspaces else os.getcwd()
|
|
38
|
+
art = _artifact_root(workspace)
|
|
39
|
+
os.makedirs(art, exist_ok=True)
|
|
40
|
+
record = {
|
|
41
|
+
"ts": datetime.now(timezone.utc).isoformat(),
|
|
42
|
+
"event": "session_end",
|
|
43
|
+
"agent": "agy",
|
|
44
|
+
"conversationId": data.get("conversationId"),
|
|
45
|
+
"executionNum": data.get("executionNum"),
|
|
46
|
+
"terminationReason": data.get("terminationReason"),
|
|
47
|
+
"model": data.get("modelName"),
|
|
48
|
+
}
|
|
49
|
+
with open(os.path.join(art, "usage-log.jsonl"), "a", encoding="utf-8") as fh:
|
|
50
|
+
fh.write(json.dumps(record) + "\n")
|
|
51
|
+
except Exception:
|
|
52
|
+
pass # never fail the turn
|
|
53
|
+
# No stdout: agy interprets a Stop hook's stdout as a decision object.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
main()
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Skills Registry
|
|
2
|
+
|
|
3
|
+
> Bundle skill inventory generated from `SKILL.md` frontmatter for the shipped subset.
|
|
4
|
+
> Load a skill by reading its `SKILL.md`.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Skills by Category
|
|
9
|
+
|
|
10
|
+
### Coding
|
|
11
|
+
|
|
12
|
+
| Skill | Path | When to Use |
|
|
13
|
+
|-------|------|-------------|
|
|
14
|
+
| Api Design | `api-design/` | REST and GraphQL API design patterns. Use when designing new API endpoints, defining resource schemas, planning versioning strategies, or reviewing API contracts. Covers naming conventions, pagination, filtering, error responses, and OpenAPI documentation. |
|
|
15
|
+
| Backend Development | `backend-development/` | Backend API design, database architecture, microservices patterns, and test-driven development. Use for designing APIs, database schemas, or backend system architecture. |
|
|
16
|
+
| Code Review | `code-review/` | Automated code review for pull requests using specialized review patterns. Analyzes code for quality, security, performance, and best practices. Use when reviewing code changes, PRs, or doing code audits. |
|
|
17
|
+
| Codebase Audit | `codebase-audit/` | Systematic codebase audit methodology for unfamiliar codebases before architecture or implementation work. Use for new codebase, unfamiliar codebase, pre-implementation audit, codebase review, technical due diligence, or onboarding to an existing project. Produces AUDIT-FINDINGS.md and QUESTIONS.md. Routes to Architect, Planner, or Code Reviewer agents. |
|
|
18
|
+
| Cross Review | `cross-review/` | Cross-vendor code review of the current diff — a second-vendor model (DeepSeek/GLM/any OpenAI-compatible endpoint) reviews your changes to catch bugs a same-vendor reviewer misses |
|
|
19
|
+
| Error Handling | `error-handling/` | Error handling patterns for Python and TypeScript applications. Use when designing error hierarchies, implementing retry logic, building error boundaries, or establishing logging strategies. Covers custom exceptions, result types, circuit breakers, and user-facing error messages. |
|
|
20
|
+
| Fastapi Dev | `fastapi-dev/` | Build FastAPI backends with standard patterns, error handling, and testing |
|
|
21
|
+
| Javascript Typescript | `javascript-typescript/` | JavaScript and TypeScript development with ES6+, Node.js, React, and modern web frameworks. Use for frontend, backend, or full-stack JavaScript/TypeScript projects. |
|
|
22
|
+
| Python Development | `python/` | Modern Python development with Python 3.12+, Django, FastAPI, async patterns, and production best practices. Use for Python projects, APIs, data processing, or automation scripts. |
|
|
23
|
+
| Refactoring | `refactoring/` | Safely refactor code while maintaining behavior. Use when improving code structure, reducing duplication, extracting functions, or modernizing legacy code. |
|
|
24
|
+
| Security Review | `security-review/` | Security review workflow — OWASP, code scanning, cloud infrastructure |
|
|
25
|
+
| Sql | `sql/` | Write high-quality, optimized SQL with best practices for performance, NULL handling, security, and readability. Database-agnostic patterns with dialect-specific notes. |
|
|
26
|
+
|
|
27
|
+
### Data
|
|
28
|
+
|
|
29
|
+
| Skill | Path | When to Use |
|
|
30
|
+
|-------|------|-------------|
|
|
31
|
+
| Database Design | `database-design/` | Database schema design, optimization, and migration patterns for PostgreSQL, MySQL, and NoSQL databases. Use for designing schemas, writing migrations, or optimizing queries. |
|
|
32
|
+
| Db Diagram | `db-diagram/` | Turn a SQL artifact — a stored procedure, view, query, .sql file, or table name — into a diagram that explains it to a human. Use when the user says "diagram this query/proc/view/schema", "explain this SQL visually", "draw the ER diagram", "show me the data flow of this stored proc", "/mermaid-db", or "/excalidraw-db". Produces Mermaid (default, git-diffable) or Excalidraw (for design reviews). Read-only — never touches the database. |
|
|
33
|
+
|
|
34
|
+
### Devops
|
|
35
|
+
|
|
36
|
+
| Skill | Path | When to Use |
|
|
37
|
+
|-------|------|-------------|
|
|
38
|
+
| Ci Cd Pipeline | `ci-cd-pipeline/` | CI/CD pipeline design and implementation for GitHub Actions, Azure DevOps, and general pipeline architecture. Use when creating build pipelines, deployment workflows, quality gates, environment promotion strategies, or automating release processes. |
|
|
39
|
+
| Gh Cli | `gh-cli/` | GitHub CLI operations — issues, PRs, releases, and repo management |
|
|
40
|
+
| Git Commit | `git-commit/` | Create well-structured conventional commit messages following Conventional Commits standard. Use when committing changes, preparing PRs, or generating changelogs. |
|
|
41
|
+
| Using Git Worktrees | `using-git-worktrees/` | Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification |
|
|
42
|
+
| Windows Deployment | `windows-deployment/` | Deploy FastAPI + React/Vite apps to Windows Server with NSSM services, reverse proxy (IIS or nginx), and git-pull workflow. Use when deploying any web app to a Windows prod server, setting up NSSM services, configuring IIS or nginx reverse proxy, making code environment-aware for dev/prod, or troubleshooting prod deployment issues. |
|
|
43
|
+
|
|
44
|
+
### Docs
|
|
45
|
+
|
|
46
|
+
| Skill | Path | When to Use |
|
|
47
|
+
|-------|------|-------------|
|
|
48
|
+
| Code Documentation | `code-documentation/` | Writing effective code documentation - API docs, README files, inline comments, and technical guides. Use for documenting codebases, APIs, or writing developer guides. |
|
|
49
|
+
| Technical Writing | `technical-writing/` | Technical documentation best practices for READMEs, API docs, architecture docs, runbooks, and developer guides. Use when writing or reviewing documentation, creating onboarding guides, or establishing documentation standards. |
|
|
50
|
+
| Writing Plans | `writing-plans/` | Use when you have a spec or requirements for a multi-step task, before touching code |
|
|
51
|
+
|
|
52
|
+
### Frontend
|
|
53
|
+
|
|
54
|
+
| Skill | Path | When to Use |
|
|
55
|
+
|-------|------|-------------|
|
|
56
|
+
| Css Architecture | `css-architecture/` | CSS architecture, design token strategy, Tailwind conventions, CSS Modules, container queries, dark mode, responsive patterns, and animation architecture. Use for design token naming, CSS custom properties, Tailwind config, container queries, dark mode implementation, fluid typography, or CSS animation decisions. Complements frontend-design (what to achieve) with how to implement it. |
|
|
57
|
+
| Frontend Design | `frontend-design/` | Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications. Generates creative, polished code that avoids generic AI aesthetics while strictly adhering to the user's technical standards. |
|
|
58
|
+
| Mockup | `mockup/` | Create framework-aware UI mockups with feasibility checks. Prevents wasted effort by validating that proposed designs work within the target framework's constraints. |
|
|
59
|
+
| React Best Practices | `react-best-practices/` | Modern React development guidelines covering hooks, component patterns, state management, performance optimization, and TypeScript integration. |
|
|
60
|
+
| React Dev | `react-dev/` | This skill should be used when building React components with TypeScript, typing hooks, handling events, or when React TypeScript, React 19, Server Components are mentioned. Covers type-safe patterns for React 18-19 including generic components, proper event typing, and routing integration (TanStack Router, React Router). |
|
|
61
|
+
| Ui Review | `ui-review/` | Review UI implementations against design requirements, accessibility standards (WCAG 2.2 AA), and brand guidelines. Use when reviewing designs or validating UI before release. |
|
|
62
|
+
| Warm Editorial Ui | `warm-editorial-ui/` | Apply the "Warm Editorial Refinement" design system — a sophisticated, executive-grade aesthetic with warm cream surfaces (light mode) and warm charcoal surfaces (dark mode), Bahnschrift + Plus Jakarta Sans typography, generous rounded corners, multi-layer shadows, and a warm neutral palette. Supports both light and dark themes via CSS custom properties and the `.dark` class. Use this skill whenever the user wants to build an app, dashboard, component, or web UI using the abc-project visual style. Trigger on phrases like "use our design system", "apply our template", "make it look like abc-project", "use the warm editorial style", "use our brand template", "add dark mode", or any request to build a new tool/app/dashboard for XYZ Brand or similar contexts. This is the canonical design template for all new frontend builds. |
|
|
63
|
+
|
|
64
|
+
### General
|
|
65
|
+
|
|
66
|
+
| Skill | Path | When to Use |
|
|
67
|
+
|-------|------|-------------|
|
|
68
|
+
| Add Rules | `add-rules/` | Create canonical rules for ANY folder — write <folder>/AGENTS.md (from the folder template) + a <folder>/CLAUDE.md @import shim. For folders the stack-map generator doesn't cover. |
|
|
69
|
+
| Digress | `digress/` | Park the current workstream on the stack and switch to a new task — without losing the original |
|
|
70
|
+
| Excalidraw Db | `excalidraw-db/` | Turn a SQL artifact into an Excalidraw diagram for a design review / ARB pack / slide — higher-level, drag-the-boxes format |
|
|
71
|
+
| Feature Plan | `feature-plan/` | Create a phased, TDD-structured implementation plan that acts as the durable spine for multi-session work |
|
|
72
|
+
| Handoff | `handoff/` | End-of-session handoff — capture exact state so the next session resumes with zero re-discovery |
|
|
73
|
+
| Implement | `implement/` | Headless plan executor — implement an approved plan phase-by-phase on the current feature branch, TDD-first, committing per phase |
|
|
74
|
+
| Kb | `kb/` | Rebuild the KB index (.caddis/kb/DOC-MAP.md) — create it if missing, index un-indexed notes, report dangling links |
|
|
75
|
+
| Mermaid Db | `mermaid-db/` | Turn a SQL artifact (proc, view, query, .sql file, or table name) into a Mermaid diagram that explains it — git-diffable, saved as .md |
|
|
76
|
+
| Migrate Dir | `migrate-dir/` | Rename this repo's legacy `.claudster/` artifact dir to `.caddis/` — dry-run first, `git mv` to keep history, merges a straggler dir, rewrites live refs. Opt-in, never automatic. |
|
|
77
|
+
| Prd | `prd/` | Capture requirements through structured discovery and write a PRD |
|
|
78
|
+
| Resume | `resume/` | Pop the most recently parked workstream off the stack and resume it at its exact resume point |
|
|
79
|
+
| Ship | `ship/` | Commit, push, and monitor the deploy pipeline (auto-detects Gitea, GitHub Actions, or local-only) |
|
|
80
|
+
| Ship Merge | `ship-merge/` | Merge an already-green, already-reviewed PR behind an explicit deploy-confirm, monitor the deploy, validate prod, then clean up the branch — only on green. |
|
|
81
|
+
| Ship Pr | `ship-pr/` | Open a reviewed PR for the current feature branch — rebase-safe push, PR create/update, monitor CI, STOP at green. Never merges, never deploys (that's /ship-merge). |
|
|
82
|
+
| Tdd | `tdd/` | Run a strict red-green-refactor TDD cycle for a unit of behavior |
|
|
83
|
+
| Ui Brief | `ui-brief/` | Design-first UI brief — lock the aesthetic before writing any code |
|
|
84
|
+
| Usage Review | `usage-review/` | Review local caddis usage over a window, surface prioritised recommendations, and apply config changes in one step |
|
|
85
|
+
| Use Model | `use-model/` | Explain (or apply) the model lanes — claude / claude-glm / cross-review — key resolution, and how to add a provider |
|
|
86
|
+
| Version | `version/` | Report the installed caddis version |
|
|
87
|
+
|
|
88
|
+
### Media
|
|
89
|
+
|
|
90
|
+
| Skill | Path | When to Use |
|
|
91
|
+
|-------|------|-------------|
|
|
92
|
+
| Draw Io | `draw-io/` | draw.io diagram creation, editing, and review. Use for .drawio XML editing, PNG conversion, layout adjustment, and AWS icon usage. |
|
|
93
|
+
| Mermaid Diagrams | `mermaid-diagrams/` | Create software diagrams using Mermaid text-based syntax. Use for class diagrams (domain modeling, OOP design), sequence diagrams (API flows, interactions), flowcharts (processes, algorithms, user journeys), ERD (database schemas), C4 architecture diagrams, state diagrams, git graphs, gantt charts, and data visualization. |
|
|
94
|
+
| Particle Art | `particle-art/` | Generate animated particle art React/Next.js components — zero dependencies, spring physics, CSS-variable theming, DPR-correct canvas, mouse interaction. Use when the user wants animated hero art, a living logo, a branded initial or monogram, a constellation background, or any "particles that form a shape". Triggers on "particle animation", "node network", "animated letter/logo/initials", "living letter", "morphing particles", "constellation", "neural net art", "dot field", "stipple portrait", "halftone animation", "ASCII art animation", "background art for my site", or "art that reacts to mouse". Covers — text/initials → spring-node letter; preset patterns (constellation, helix, spiral, DNA, hex-grid, wave, infinity); custom SVG paths; custom polygon points; Unicode halftone stipple; Gaussian dot field with sparks; SVG circuit traces; hybrid combos. Outputs a complete, self-contained, copy-paste-ready React component. Prefer this over p5.js (zero-dep, React-native, TypeScript), tsParticles (richer spring physics, CSS-var theming), Three.js (lightweight, no WebGL). |
|
|
95
|
+
|
|
96
|
+
### Testing
|
|
97
|
+
|
|
98
|
+
| Skill | Path | When to Use |
|
|
99
|
+
|-------|------|-------------|
|
|
100
|
+
| Playwright | `playwright/` | Complete browser automation with Playwright. Auto-detects dev servers, writes clean test scripts to /tmp. Test pages, fill forms, take screenshots, check responsive design, validate UX, test login flows, check links, automate any browser task. Use when user wants to test websites, automate browser interactions, validate web functionality, or perform any browser-based testing. |
|
|
101
|
+
| Tdd Workflow | `tdd-workflow/` | Test-Driven Development workflow — red-green-refactor cycle |
|
|
102
|
+
| Test Strategy | `test-strategy/` | Test planning and strategy for projects of any size. Use when defining what to test, choosing test types, setting coverage goals, building test pyramids, or planning quality gates. Produces TEST-STRATEGY.md with prioritized test plan. Routes to Tester agent for execution. |
|
|
103
|
+
| Webapp Testing | `webapp-testing/` | Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs. |
|
|
104
|
+
|
|
105
|
+
### Workflow
|
|
106
|
+
|
|
107
|
+
| Skill | Path | When to Use |
|
|
108
|
+
|-------|------|-------------|
|
|
109
|
+
| Best Practices | `best-practices/` | >- |
|
|
110
|
+
| Brainstorming | `brainstorming/` | You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation. |
|
|
111
|
+
| Context Curator | `context-curator/` | Compress and prioritize codebase context before handing work to reasoning agents, minimizing token waste while preserving the required decision inputs. |
|
|
112
|
+
| Golden Plan | `golden-plan/` | USE THIS SKILL whenever a user asks for a comprehensive implementation plan, a full-stack build plan, a UI+backend plan, or says 'create a plan for building X' where X spans multiple phases or systems. Also activate when the user says 'plan this project', 'I need a detailed plan', 'build plan', 'implementation plan', or attaches a mockup/wireframe and asks how to build it. Produces a zero-ambiguity, evidence-gated plan with self-contained per-phase prompts, exhaustive data binding tables, per-phase validation checklists, and a global quality gate. Evidence-gated: before writing phases, verify required artefacts (mockup, data sample, API contract, scaffold inventory); if any BLOCKER is missing, ask for it and wait before proceeding. Dual-mode: generic by default, junai-pipeline only when explicitly requested. Agent-agnostic - any agent with read/search/edit tools can use this skill. |
|
|
113
|
+
| Preflight | `preflight/` | Plan-vs-codebase validation — verifies API contracts, type names, field accuracy, dependencies, and paths before implementation begins |
|
|
114
|
+
| Setup Project Ai | `setup-project-ai/` | Install or refresh the agent-agnostic dev harness in this project (AGENTS.md-canonical rules hierarchy + CLAUDE.md @import shims, subagents, commands, settings) |
|
|
115
|
+
| Skill Creator | `skill-creator/` | Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. |
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: add-rules
|
|
3
|
+
description: Create canonical rules for ANY folder — write <folder>/AGENTS.md (from the folder template) + a <folder>/CLAUDE.md @import shim. For folders the stack-map generator doesn't cover.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /add-rules — add canonical rules to a folder
|
|
7
|
+
|
|
8
|
+
Create a rules file for a folder the deterministic generator doesn't cover (stack-map only writes
|
|
9
|
+
`src/`, `frontend/`, `tests/`). `AGENTS.md` is the **canonical** rules file; `CLAUDE.md` is a thin
|
|
10
|
+
`@AGENTS.md` import shim beside it. This command writes both.
|
|
11
|
+
|
|
12
|
+
Context / args: **$ARGUMENTS** — the first token is the target `<folder>` (repo-relative); the rest is
|
|
13
|
+
an optional one-line purpose.
|
|
14
|
+
|
|
15
|
+
## Steps
|
|
16
|
+
|
|
17
|
+
1. **Parse args.** `<folder>` = first token; `[purpose]` = the remainder (may be empty). If `<folder>`
|
|
18
|
+
is missing, ask which folder and stop. Resolve `<folder>` relative to the repo root; if it doesn't
|
|
19
|
+
exist, say so and stop (create the folder first, or fix the path).
|
|
20
|
+
|
|
21
|
+
2. **Refuse to clobber.** If `<folder>/AGENTS.md` already exists, STOP — do **not** overwrite it. Point
|
|
22
|
+
the user at the `knowledge-transfer` / `claude-md-curator` agents for *updating* existing rules (they
|
|
23
|
+
target ANY existing `AGENTS.md`). This command only *creates* new folder rules.
|
|
24
|
+
|
|
25
|
+
3. **Seed from the folder.** Read a representative sample of `<folder>`'s contents (a few files, the
|
|
26
|
+
most-imported modules, any local README) to learn the real conventions, layering, naming, test
|
|
27
|
+
pattern, and non-obvious gotchas. Combine that with `[purpose]`. Do not invent rules the code
|
|
28
|
+
doesn't support; prefer a short honest file over a padded one.
|
|
29
|
+
|
|
30
|
+
4. **Write `<folder>/AGENTS.md`** from the folder template `claude-md/folder-agents.md.tmpl` (resolve
|
|
31
|
+
`<harness-root>` the same way `/setup-project-ai` does: `${CLAUDE_PLUGIN_ROOT}/claude-md/…` for a
|
|
32
|
+
plugin install, else the `claude-harness/claude-md/…` checkout path). Fill `{{FOLDER}}` and
|
|
33
|
+
`{{FOLDER_PURPOSE}}`, then replace the `<…>` section stubs (Conventions, Gotchas / non-obvious,
|
|
34
|
+
Adding functionality) with what you learned in Step 3. Keep it lean (the ~80-line budget applies).
|
|
35
|
+
|
|
36
|
+
5. **Write `<folder>/CLAUDE.md`** as the exact 2-line shim (nothing more — never put rules here):
|
|
37
|
+
```
|
|
38
|
+
# Folder conventions — canonical in AGENTS.md (imported below; Claude Code inlines it)
|
|
39
|
+
@AGENTS.md
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
6. **Report + remind.** Show the two files written. Remind that ongoing updates flow through the
|
|
43
|
+
`knowledge-transfer` (end-of-session capture) and `claude-md-curator` (periodic prune) agents — they
|
|
44
|
+
match ANY existing `AGENTS.md`, so no per-folder upkeep command is needed. Codex and Antigravity
|
|
45
|
+
(`agy`) read the `AGENTS.md` directly; Claude Code inlines it via the `CLAUDE.md` shim.
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-design
|
|
3
|
+
description: REST and GraphQL API design patterns. Use when designing new API endpoints, defining resource schemas, planning versioning strategies, or reviewing API contracts. Covers naming conventions, pagination, filtering, error responses, and OpenAPI documentation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# API Design Skill
|
|
7
|
+
|
|
8
|
+
Design APIs that are consistent, discoverable, and hard to misuse. Conventions over configuration.
|
|
9
|
+
|
|
10
|
+
## 1. When to Apply This Skill
|
|
11
|
+
|
|
12
|
+
**Trigger conditions:**
|
|
13
|
+
- Designing new API endpoints or a full API surface
|
|
14
|
+
- "What should this endpoint look like?"
|
|
15
|
+
- Planning API versioning or migration
|
|
16
|
+
- Reviewing API contracts for consistency
|
|
17
|
+
- Building an API spec or OpenAPI document
|
|
18
|
+
|
|
19
|
+
## 2. REST Resource Naming
|
|
20
|
+
|
|
21
|
+
### URL Convention
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
# Resources are nouns, plural, lowercase, kebab-case
|
|
25
|
+
GET /api/v1/customers # List
|
|
26
|
+
GET /api/v1/customers/{id} # Get one
|
|
27
|
+
POST /api/v1/customers # Create
|
|
28
|
+
PUT /api/v1/customers/{id} # Full update
|
|
29
|
+
PATCH /api/v1/customers/{id} # Partial update
|
|
30
|
+
DELETE /api/v1/customers/{id} # Delete
|
|
31
|
+
|
|
32
|
+
# Nested resources for strong ownership
|
|
33
|
+
GET /api/v1/customers/{id}/orders # Customer's orders
|
|
34
|
+
POST /api/v1/customers/{id}/orders # Create order for customer
|
|
35
|
+
|
|
36
|
+
# Actions (when CRUD doesn't fit) — verb suffix
|
|
37
|
+
POST /api/v1/orders/{id}/cancel # Action on resource
|
|
38
|
+
POST /api/v1/reports/generate # Trigger async operation
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Naming Rules
|
|
42
|
+
|
|
43
|
+
| Rule | Good | Bad |
|
|
44
|
+
|------|------|-----|
|
|
45
|
+
| Plural nouns | `/customers` | `/customer`, `/getCustomers` |
|
|
46
|
+
| Kebab-case | `/order-items` | `/orderItems`, `/order_items` |
|
|
47
|
+
| No verbs in path | `/customers` (POST = create) | `/createCustomer` |
|
|
48
|
+
| Consistent nesting depth | Max 2 levels: `/customers/{id}/orders` | `/customers/{id}/orders/{id}/items/{id}/details` |
|
|
49
|
+
| No trailing slash | `/customers` | `/customers/` |
|
|
50
|
+
|
|
51
|
+
## 3. Request & Response Envelope
|
|
52
|
+
|
|
53
|
+
### Success Response
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"data": { ... },
|
|
58
|
+
"meta": {
|
|
59
|
+
"request_id": "req_abc123",
|
|
60
|
+
"timestamp": "2025-01-15T10:30:00Z"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### List Response (with pagination)
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"data": [ ... ],
|
|
70
|
+
"pagination": {
|
|
71
|
+
"page": 1,
|
|
72
|
+
"per_page": 25,
|
|
73
|
+
"total": 142,
|
|
74
|
+
"total_pages": 6
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Error Response
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"error": {
|
|
84
|
+
"code": "VALIDATION_ERROR",
|
|
85
|
+
"message": "Request validation failed",
|
|
86
|
+
"details": [
|
|
87
|
+
{ "field": "email", "message": "Invalid email format" },
|
|
88
|
+
{ "field": "age", "message": "Must be at least 18" }
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 4. HTTP Status Codes
|
|
95
|
+
|
|
96
|
+
Use the right code. Clients depend on these for control flow.
|
|
97
|
+
|
|
98
|
+
| Code | When to Use |
|
|
99
|
+
|------|-------------|
|
|
100
|
+
| `200 OK` | Successful GET, PUT, PATCH |
|
|
101
|
+
| `201 Created` | Successful POST that creates a resource |
|
|
102
|
+
| `204 No Content` | Successful DELETE |
|
|
103
|
+
| `400 Bad Request` | Malformed request body or parameters |
|
|
104
|
+
| `401 Unauthorized` | Missing or invalid authentication |
|
|
105
|
+
| `403 Forbidden` | Authenticated but not authorized |
|
|
106
|
+
| `404 Not Found` | Resource doesn't exist |
|
|
107
|
+
| `409 Conflict` | Duplicate resource, version conflict |
|
|
108
|
+
| `422 Unprocessable Entity` | Valid syntax but semantic validation failed |
|
|
109
|
+
| `429 Too Many Requests` | Rate limit exceeded (include `Retry-After` header) |
|
|
110
|
+
| `500 Internal Server Error` | Unhandled server error |
|
|
111
|
+
|
|
112
|
+
## 5. Pagination
|
|
113
|
+
|
|
114
|
+
### Offset-based (simple, good for most cases)
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
GET /api/v1/customers?page=2&per_page=25
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Cursor-based (better for real-time data, large datasets)
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
GET /api/v1/events?cursor=eyJpZCI6MTAwfQ&limit=25
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
| Strategy | Pros | Cons |
|
|
127
|
+
|----------|------|------|
|
|
128
|
+
| Offset | Simple, supports jumping to page N | Skips/duplicates on mutations, slow at high offsets |
|
|
129
|
+
| Cursor | Consistent with mutations, performant | No "jump to page 5", harder to implement |
|
|
130
|
+
|
|
131
|
+
**Rule:** Use offset for admin/dashboard UIs. Use cursor for feeds, events, and public APIs.
|
|
132
|
+
|
|
133
|
+
## 6. Filtering, Sorting, and Search
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
# Filtering — field-level with operators
|
|
137
|
+
GET /api/v1/orders?status=open&created_after=2025-01-01
|
|
138
|
+
|
|
139
|
+
# Sorting — field with direction prefix
|
|
140
|
+
GET /api/v1/orders?sort=-created_at # descending
|
|
141
|
+
GET /api/v1/orders?sort=status,created_at # multi-field
|
|
142
|
+
|
|
143
|
+
# Search — dedicated parameter
|
|
144
|
+
GET /api/v1/customers?q=acme+corp
|
|
145
|
+
|
|
146
|
+
# Field selection — sparse fieldsets
|
|
147
|
+
GET /api/v1/customers?fields=id,name,email
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## 7. Versioning
|
|
151
|
+
|
|
152
|
+
### URL Path versioning (recommended)
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
/api/v1/customers
|
|
156
|
+
/api/v2/customers
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Version lifecycle
|
|
160
|
+
|
|
161
|
+
| Phase | Duration | Behaviour |
|
|
162
|
+
|-------|----------|-----------|
|
|
163
|
+
| **Current** | Indefinite | Actively maintained |
|
|
164
|
+
| **Deprecated** | 6-12 months | Returns `Deprecation` header, still works |
|
|
165
|
+
| **Sunset** | After deprecation | Returns `410 Gone` |
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
# FastAPI deprecation header
|
|
169
|
+
@app.get("/api/v1/old-endpoint", deprecated=True)
|
|
170
|
+
async def old_endpoint(response: Response):
|
|
171
|
+
response.headers["Deprecation"] = "true"
|
|
172
|
+
response.headers["Sunset"] = "2026-06-01"
|
|
173
|
+
response.headers["Link"] = '</api/v2/new-endpoint>; rel="successor-version"'
|
|
174
|
+
return {"data": ...}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## 8. Authentication & Security
|
|
178
|
+
|
|
179
|
+
- Use `Authorization: Bearer <token>` for API auth
|
|
180
|
+
- Never put tokens in URL query parameters (they appear in logs)
|
|
181
|
+
- Return `401` for missing/invalid auth, `403` for insufficient permissions
|
|
182
|
+
- Include `X-Request-Id` header for tracing
|
|
183
|
+
- Rate limit all public endpoints
|
|
184
|
+
|
|
185
|
+
## 9. FastAPI Implementation Pattern
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from fastapi import APIRouter, Depends, Query, HTTPException, status
|
|
189
|
+
from pydantic import BaseModel, Field
|
|
190
|
+
|
|
191
|
+
router = APIRouter(prefix="/api/v1/customers", tags=["customers"])
|
|
192
|
+
|
|
193
|
+
class CustomerCreate(BaseModel):
|
|
194
|
+
name: str = Field(..., min_length=1, max_length=200)
|
|
195
|
+
email: str = Field(..., pattern=r"^[\w.-]+@[\w.-]+\.\w+$")
|
|
196
|
+
|
|
197
|
+
class CustomerResponse(BaseModel):
|
|
198
|
+
id: str
|
|
199
|
+
name: str
|
|
200
|
+
email: str
|
|
201
|
+
|
|
202
|
+
class PaginatedResponse(BaseModel):
|
|
203
|
+
data: list[CustomerResponse]
|
|
204
|
+
pagination: dict
|
|
205
|
+
|
|
206
|
+
@router.get("", response_model=PaginatedResponse)
|
|
207
|
+
async def list_customers(
|
|
208
|
+
page: int = Query(1, ge=1),
|
|
209
|
+
per_page: int = Query(25, ge=1, le=100),
|
|
210
|
+
):
|
|
211
|
+
...
|
|
212
|
+
|
|
213
|
+
@router.post("", response_model=CustomerResponse, status_code=status.HTTP_201_CREATED)
|
|
214
|
+
async def create_customer(body: CustomerCreate):
|
|
215
|
+
...
|
|
216
|
+
|
|
217
|
+
@router.get("/{customer_id}", response_model=CustomerResponse)
|
|
218
|
+
async def get_customer(customer_id: str):
|
|
219
|
+
customer = await repo.find(customer_id)
|
|
220
|
+
if not customer:
|
|
221
|
+
raise HTTPException(status_code=404, detail="Customer not found")
|
|
222
|
+
return customer
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## 10. API Design Checklist
|
|
226
|
+
|
|
227
|
+
Before shipping an API endpoint:
|
|
228
|
+
|
|
229
|
+
- [ ] Resource names are plural nouns in kebab-case
|
|
230
|
+
- [ ] Correct HTTP methods (GET reads, POST creates, etc.)
|
|
231
|
+
- [ ] Correct status codes (201 for create, 204 for delete)
|
|
232
|
+
- [ ] Request body validated with Pydantic/Zod
|
|
233
|
+
- [ ] Error responses use consistent envelope with error code
|
|
234
|
+
- [ ] Pagination implemented for list endpoints
|
|
235
|
+
- [ ] Authentication required (unless intentionally public)
|
|
236
|
+
- [ ] Rate limiting configured
|
|
237
|
+
- [ ] OpenAPI spec generated and reviewed
|
|
238
|
+
- [ ] No sensitive data in URLs or logs
|
|
239
|
+
|
|
240
|
+
## 11. Anti-Patterns
|
|
241
|
+
|
|
242
|
+
| Anti-Pattern | Problem | Fix |
|
|
243
|
+
|---|---|---|
|
|
244
|
+
| Verbs in URLs | `/getUser`, `/deleteOrder` | Use HTTP methods + nouns |
|
|
245
|
+
| Inconsistent pluralisation | `/user` vs `/orders` | Always plural |
|
|
246
|
+
| Returning 200 for errors | Client can't distinguish success/failure | Use proper status codes |
|
|
247
|
+
| Nested resources > 2 levels | Hard to discover, fragile URLs | Flatten with query params |
|
|
248
|
+
| No pagination on lists | Unbounded response size, OOM | Always paginate |
|
|
249
|
+
| Exposing internal IDs/schemas | Coupling clients to implementation | Use public-facing schemas |
|