contextos-agents 2.1.0 → 2.2.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/.agents/adapters/aider/export.js +2 -2
- package/.agents/adapters/claude/export.js +53 -2
- package/.agents/adapters/drift-detector.js +6 -3
- package/.agents/adapters/pure-compiler.js +18 -6
- package/.agents/ctx.js +13 -8
- package/.agents/plugins.js +347 -26
- package/.agents/profiles.js +32 -11
- package/README.md +38 -3
- package/bin/commands/hook.js +50 -12
- package/bin/commands/scan.js +10 -3
- package/bin/index.js +165 -53
- package/bin/lib/git-snapshot.js +70 -43
- package/bin/lib/scan.js +108 -27
- package/bin/lib/ui.js +140 -0
- package/catalog/skills/adapters/EXAMPLES.md +19 -0
- package/catalog/skills/adapters/SKILL.md +101 -0
- package/catalog/skills/adapters/TROUBLESHOOTING.md +7 -0
- package/catalog/skills/adapters/VALIDATION.json +12 -0
- package/catalog/skills/adapters/skill.yaml +13 -0
- package/catalog/skills/api-design/EXAMPLES.md +91 -0
- package/catalog/skills/api-design/SKILL.md +63 -0
- package/catalog/skills/api-design/TROUBLESHOOTING.md +54 -0
- package/catalog/skills/api-design/VALIDATION.json +11 -0
- package/catalog/skills/api-design/skill.yaml +14 -0
- package/catalog/skills/architecture-diagrams/SKILL.md +108 -0
- package/catalog/skills/architecture-diagrams/VALIDATION.json +12 -0
- package/catalog/skills/architecture-diagrams/skill.yaml +9 -0
- package/catalog/skills/brutalist-design/EXAMPLES.md +59 -0
- package/catalog/skills/brutalist-design/SKILL.md +150 -0
- package/catalog/skills/brutalist-design/VALIDATION.json +12 -0
- package/catalog/skills/brutalist-design/skill.yaml +10 -0
- package/catalog/skills/ci-cd/EXAMPLES.md +79 -0
- package/catalog/skills/ci-cd/SKILL.md +69 -0
- package/catalog/skills/ci-cd/TROUBLESHOOTING.md +52 -0
- package/catalog/skills/ci-cd/VALIDATION.json +11 -0
- package/catalog/skills/ci-cd/skill.yaml +13 -0
- package/catalog/skills/database/EXAMPLES.md +74 -0
- package/catalog/skills/database/SKILL.md +101 -0
- package/catalog/skills/database/TROUBLESHOOTING.md +18 -0
- package/catalog/skills/database/VALIDATION.json +11 -0
- package/catalog/skills/database/skill.yaml +14 -0
- package/catalog/skills/ddd/EXAMPLES.md +42 -0
- package/catalog/skills/ddd/SKILL.md +247 -0
- package/catalog/skills/ddd/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/ddd/VALIDATION.json +12 -0
- package/catalog/skills/ddd/skill.yaml +14 -0
- package/catalog/skills/decisions/EXAMPLES.md +35 -0
- package/catalog/skills/decisions/SKILL.md +90 -0
- package/catalog/skills/decisions/TROUBLESHOOTING.md +13 -0
- package/catalog/skills/decisions/VALIDATION.json +12 -0
- package/catalog/skills/decisions/skill.yaml +13 -0
- package/catalog/skills/docker/EXAMPLES.md +56 -0
- package/catalog/skills/docker/SKILL.md +169 -0
- package/catalog/skills/docker/TROUBLESHOOTING.md +18 -0
- package/catalog/skills/docker/VALIDATION.json +11 -0
- package/catalog/skills/docker/skill.yaml +13 -0
- package/catalog/skills/fastapi/EXAMPLES.md +36 -0
- package/catalog/skills/fastapi/SKILL.md +171 -0
- package/catalog/skills/fastapi/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/fastapi/VALIDATION.json +12 -0
- package/catalog/skills/fastapi/skill.yaml +14 -0
- package/catalog/skills/generators/EXAMPLES.md +19 -0
- package/catalog/skills/generators/SKILL.md +110 -0
- package/catalog/skills/generators/TROUBLESHOOTING.md +7 -0
- package/catalog/skills/generators/VALIDATION.json +12 -0
- package/catalog/skills/generators/skill.yaml +22 -0
- package/catalog/skills/generators/templates/API.md +77 -0
- package/catalog/skills/generators/templates/ARCHITECTURE.md +70 -0
- package/catalog/skills/generators/templates/DATABASE.md +42 -0
- package/catalog/skills/generators/templates/DECISION.md +46 -0
- package/catalog/skills/generators/templates/PRD.md +67 -0
- package/catalog/skills/generators/templates/PROJECT_GRAPH.md +56 -0
- package/catalog/skills/generators/templates/ROADMAP.md +51 -0
- package/catalog/skills/generators/templates/TASKS.md +43 -0
- package/catalog/skills/generators/templates/UI.md +73 -0
- package/catalog/skills/graphify/EXAMPLES.md +73 -0
- package/catalog/skills/graphify/SKILL.md +130 -0
- package/catalog/skills/graphify/VALIDATION.json +12 -0
- package/catalog/skills/graphify/skill.yaml +13 -0
- package/catalog/skills/impeccable-design/EXAMPLES.md +26 -0
- package/catalog/skills/impeccable-design/SKILL.md +201 -0
- package/catalog/skills/impeccable-design/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/impeccable-design/VALIDATION.json +12 -0
- package/catalog/skills/impeccable-design/skill.yaml +15 -0
- package/catalog/skills/interview-me/SKILL.md +97 -0
- package/catalog/skills/interview-me/VALIDATION.json +12 -0
- package/catalog/skills/interview-me/skill.yaml +9 -0
- package/catalog/skills/microservices/EXAMPLES.md +38 -0
- package/catalog/skills/microservices/SKILL.md +164 -0
- package/catalog/skills/microservices/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/microservices/VALIDATION.json +12 -0
- package/catalog/skills/microservices/skill.yaml +14 -0
- package/catalog/skills/minimalist-design/EXAMPLES.md +58 -0
- package/catalog/skills/minimalist-design/SKILL.md +113 -0
- package/catalog/skills/minimalist-design/VALIDATION.json +12 -0
- package/catalog/skills/minimalist-design/skill.yaml +10 -0
- package/catalog/skills/nestjs/EXAMPLES.md +40 -0
- package/catalog/skills/nestjs/SKILL.md +139 -0
- package/catalog/skills/nestjs/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/nestjs/VALIDATION.json +12 -0
- package/catalog/skills/nestjs/skill.yaml +14 -0
- package/catalog/skills/nextjs/EXAMPLES.md +40 -0
- package/catalog/skills/nextjs/SKILL.md +163 -0
- package/catalog/skills/nextjs/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/nextjs/VALIDATION.json +12 -0
- package/catalog/skills/nextjs/skill.yaml +14 -0
- package/catalog/skills/node/EXAMPLES.md +80 -0
- package/catalog/skills/node/SKILL.md +128 -0
- package/catalog/skills/node/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/node/VALIDATION.json +12 -0
- package/catalog/skills/node/skill.yaml +14 -0
- package/catalog/skills/performance/EXAMPLES.md +30 -0
- package/catalog/skills/performance/SKILL.md +75 -0
- package/catalog/skills/performance/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/performance/VALIDATION.json +12 -0
- package/catalog/skills/performance/skill.yaml +14 -0
- package/catalog/skills/react/EXAMPLES.md +79 -0
- package/catalog/skills/react/SKILL.md +132 -0
- package/catalog/skills/react/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/react/VALIDATION.json +12 -0
- package/catalog/skills/react/skill.yaml +14 -0
- package/catalog/skills/react-best-practices/SKILL.md +158 -0
- package/catalog/skills/react-best-practices/VALIDATION.json +12 -0
- package/catalog/skills/react-best-practices/skill.yaml +13 -0
- package/catalog/skills/redesign-audit/SKILL.md +117 -0
- package/catalog/skills/redesign-audit/VALIDATION.json +12 -0
- package/catalog/skills/redesign-audit/skill.yaml +9 -0
- package/catalog/skills/security-audit/EXAMPLES.md +79 -0
- package/catalog/skills/security-audit/SKILL.md +91 -0
- package/catalog/skills/security-audit/TROUBLESHOOTING.md +46 -0
- package/catalog/skills/security-audit/VALIDATION.json +11 -0
- package/catalog/skills/security-audit/skill.yaml +14 -0
- package/catalog/skills/soft-design/EXAMPLES.md +51 -0
- package/catalog/skills/soft-design/SKILL.md +108 -0
- package/catalog/skills/soft-design/VALIDATION.json +12 -0
- package/catalog/skills/soft-design/skill.yaml +10 -0
- package/catalog/skills/state-management/EXAMPLES.md +56 -0
- package/catalog/skills/state-management/SKILL.md +168 -0
- package/catalog/skills/state-management/TROUBLESHOOTING.md +18 -0
- package/catalog/skills/state-management/VALIDATION.json +11 -0
- package/catalog/skills/state-management/skill.yaml +14 -0
- package/catalog/skills/subagent-orchestrator/SKILL.md +117 -0
- package/catalog/skills/subagent-orchestrator/VALIDATION.json +12 -0
- package/catalog/skills/subagent-orchestrator/skill.yaml +9 -0
- package/catalog/skills/system-design/EXAMPLES.md +75 -0
- package/catalog/skills/system-design/SKILL.md +419 -0
- package/catalog/skills/system-design/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/system-design/VALIDATION.json +12 -0
- package/catalog/skills/system-design/skill.yaml +14 -0
- package/catalog/skills/terraform/EXAMPLES.md +74 -0
- package/catalog/skills/terraform/SKILL.md +55 -0
- package/catalog/skills/terraform/TROUBLESHOOTING.md +53 -0
- package/catalog/skills/terraform/VALIDATION.json +11 -0
- package/catalog/skills/terraform/skill.yaml +14 -0
- package/catalog/skills/testing/EXAMPLES.md +122 -0
- package/catalog/skills/testing/SKILL.md +70 -0
- package/catalog/skills/testing/TROUBLESHOOTING.md +18 -0
- package/catalog/skills/testing/VALIDATION.json +11 -0
- package/catalog/skills/testing/skill.yaml +14 -0
- package/catalog/skills/typescript/EXAMPLES.md +64 -0
- package/catalog/skills/typescript/SKILL.md +112 -0
- package/catalog/skills/typescript/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/typescript/VALIDATION.json +12 -0
- package/catalog/skills/typescript/skill.yaml +14 -0
- package/catalog/skills/ui-design/EXAMPLES.md +21 -0
- package/catalog/skills/ui-design/SKILL.md +124 -0
- package/catalog/skills/ui-design/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/ui-design/VALIDATION.json +12 -0
- package/catalog/skills/ui-design/skill.yaml +16 -0
- package/catalog/skills/ui-ux-pro/EXAMPLES.md +62 -0
- package/catalog/skills/ui-ux-pro/SKILL.md +418 -0
- package/catalog/skills/ui-ux-pro/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/ui-ux-pro/VALIDATION.json +12 -0
- package/catalog/skills/ui-ux-pro/skill.yaml +14 -0
- package/catalog/skills/ux-design/EXAMPLES.md +36 -0
- package/catalog/skills/ux-design/SKILL.md +116 -0
- package/catalog/skills/ux-design/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/ux-design/VALIDATION.json +12 -0
- package/catalog/skills/ux-design/skill.yaml +16 -0
- package/catalog/skills/vercel-optimize/SKILL.md +83 -0
- package/catalog/skills/vercel-optimize/VALIDATION.json +12 -0
- package/catalog/skills/vercel-optimize/scripts/collect-signals.mjs +131 -0
- package/catalog/skills/vercel-optimize/scripts/gate-investigations.mjs +142 -0
- package/catalog/skills/vercel-optimize/scripts/merge-signals.mjs +143 -0
- package/catalog/skills/vercel-optimize/scripts/scan-codebase.mjs +174 -0
- package/catalog/skills/vercel-optimize/skill.yaml +15 -0
- package/catalog/skills/web-accessibility/EXAMPLES.md +39 -0
- package/catalog/skills/web-accessibility/SKILL.md +151 -0
- package/catalog/skills/web-accessibility/TROUBLESHOOTING.md +19 -0
- package/catalog/skills/web-accessibility/VALIDATION.json +12 -0
- package/catalog/skills/web-accessibility/skill.yaml +14 -0
- package/package.json +3 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Docker Troubleshooting Guide
|
|
2
|
+
|
|
3
|
+
## Common Issues & Fixes
|
|
4
|
+
|
|
5
|
+
### 1. Slow Docker builds rebuilding node_modules every time
|
|
6
|
+
|
|
7
|
+
- **Cause**: Copying the entire directory (`COPY . .`) before running `npm ci`.
|
|
8
|
+
- **Fix**: Copy `package.json` and `package-lock.json` separately first, run `npm ci`, and only then copy application source code.
|
|
9
|
+
|
|
10
|
+
### 2. Permission Denied Errors with Non-Root Users
|
|
11
|
+
|
|
12
|
+
- **Cause**: Files copied from builder without changing ownership.
|
|
13
|
+
- **Fix**: Always use `--chown=appuser:appgroup` when copying files in Dockerfile.
|
|
14
|
+
|
|
15
|
+
### 3. Missing native build dependencies on Alpine Linux
|
|
16
|
+
|
|
17
|
+
- **Cause**: Packages requiring C bindings (e.g. `sharp`, `bcrypt`) fail on musl libc.
|
|
18
|
+
- **Fix**: Add `RUN apk add --no-cache libc6-compat python3 make g++` in the builder stage.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill": "docker",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"checks": [
|
|
5
|
+
"Multi-stage Dockerfile architecture",
|
|
6
|
+
"Non-root USER directive present",
|
|
7
|
+
"Layer caching optimization (lockfiles copied first)",
|
|
8
|
+
"Specific image version tags (no :latest)",
|
|
9
|
+
".dockerignore excludes node_modules and secrets"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
schemaVersion: 2
|
|
2
|
+
name: docker
|
|
3
|
+
description: Docker containerization, multi-stage builds, non-root security, layer caching optimization, and docker-compose standards.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
category: devops
|
|
6
|
+
type: instruction-only
|
|
7
|
+
requires:
|
|
8
|
+
- security
|
|
9
|
+
resources:
|
|
10
|
+
- EXAMPLES.md
|
|
11
|
+
- SKILL.md
|
|
12
|
+
- TROUBLESHOOTING.md
|
|
13
|
+
- VALIDATION.json
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# fastapi Examples - Anti-patterns vs ContextOS Standard
|
|
2
|
+
|
|
3
|
+
## Example 1: Asynchronous Route Handlers
|
|
4
|
+
|
|
5
|
+
### Anti-pattern: Blocking I/O inside `async def`
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# BAD: time.sleep or synchronous requests blocks the entire asyncio event loop!
|
|
9
|
+
import time
|
|
10
|
+
import requests
|
|
11
|
+
|
|
12
|
+
@app.get("/slow")
|
|
13
|
+
async def slow_route():
|
|
14
|
+
time.sleep(5) # BLOCKS ALL CONCURRENT USERS!
|
|
15
|
+
return {"status": "done"}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Best practice: ContextOS Standard (Non-blocking Async or Def Offload)
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
# GOOD: Use async non-blocking client (httpx) or standard def for sync CPU work
|
|
22
|
+
import asyncio
|
|
23
|
+
import httpx
|
|
24
|
+
|
|
25
|
+
@app.get("/fast")
|
|
26
|
+
async def fast_route():
|
|
27
|
+
async with httpx.AsyncClient() as client:
|
|
28
|
+
response = await client.get("https://api.example.com/data")
|
|
29
|
+
return response.json()
|
|
30
|
+
|
|
31
|
+
# Or standard def (FastAPI automatically runs it in a background threadpool):
|
|
32
|
+
@app.get("/sync-worker")
|
|
33
|
+
def sync_worker():
|
|
34
|
+
time.sleep(5) # Runs in worker thread without blocking event loop
|
|
35
|
+
return {"status": "done"}
|
|
36
|
+
```
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: FastAPI
|
|
3
|
+
description: >
|
|
4
|
+
ContextOS skill for FastAPI
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# FastAPI
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
High-performance Python backend engineering using FastAPI, Pydantic v2, and async SQLAlchemy/Tortoise ORM. Enforces type-driven request validation, OpenAPI contracts, and async non-blocking endpoints.
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
Activate when building Python REST APIs, microservices, asynchronous background jobs, or integrating Python ML services into web backends.
|
|
16
|
+
|
|
17
|
+
## Rules & Patterns
|
|
18
|
+
<!-- Source: fastapi.md -->
|
|
19
|
+
|
|
20
|
+
## FastAPI - Best Practices
|
|
21
|
+
|
|
22
|
+
## Project Structure
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
app/
|
|
26
|
+
├── main.py # App entry, CORS, middleware
|
|
27
|
+
├── config.py # Settings with Pydantic BaseSettings
|
|
28
|
+
├── database.py # Database session, engine
|
|
29
|
+
├── models/ # SQLAlchemy models
|
|
30
|
+
│ ├── __init__.py
|
|
31
|
+
│ └── user.py
|
|
32
|
+
├── schemas/ # Pydantic schemas (request/response)
|
|
33
|
+
│ ├── __init__.py
|
|
34
|
+
│ └── user.py
|
|
35
|
+
├── api/ # Route handlers
|
|
36
|
+
│ ├── __init__.py
|
|
37
|
+
│ ├── deps.py # Dependency injection
|
|
38
|
+
│ └── v1/
|
|
39
|
+
│ ├── __init__.py
|
|
40
|
+
│ └── users.py
|
|
41
|
+
├── services/ # Business logic
|
|
42
|
+
│ └── user_service.py
|
|
43
|
+
├── repositories/ # Database access
|
|
44
|
+
│ └── user_repo.py
|
|
45
|
+
└── tests/
|
|
46
|
+
└── test_users.py
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Pydantic Models
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from pydantic import BaseModel, EmailStr, Field, ConfigDict
|
|
53
|
+
|
|
54
|
+
class UserCreate(BaseModel):
|
|
55
|
+
email: EmailStr
|
|
56
|
+
name: str = Field(..., min_length=1, max_length=100)
|
|
57
|
+
|
|
58
|
+
class UserResponse(BaseModel):
|
|
59
|
+
id: int
|
|
60
|
+
email: str
|
|
61
|
+
name: str
|
|
62
|
+
|
|
63
|
+
model_config = ConfigDict(from_attributes=True)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Dependency Injection
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from typing import AsyncGenerator
|
|
70
|
+
from fastapi import Depends, HTTPException, status
|
|
71
|
+
from fastapi.security import OAuth2PasswordBearer
|
|
72
|
+
from sqlalchemy.ext.asyncio import AsyncSession
|
|
73
|
+
import jwt
|
|
74
|
+
|
|
75
|
+
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="api/v1/auth/token")
|
|
76
|
+
|
|
77
|
+
async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
78
|
+
async with async_session() as session:
|
|
79
|
+
yield session
|
|
80
|
+
|
|
81
|
+
async def get_current_user(
|
|
82
|
+
token: str = Depends(oauth2_scheme),
|
|
83
|
+
db: AsyncSession = Depends(get_db)
|
|
84
|
+
) -> User:
|
|
85
|
+
try:
|
|
86
|
+
payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
|
|
87
|
+
user_id: str = payload.get("sub")
|
|
88
|
+
if user_id is None:
|
|
89
|
+
raise HTTPException(
|
|
90
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
91
|
+
detail="Could not validate credentials",
|
|
92
|
+
headers={"WWW-Authenticate": "Bearer"},
|
|
93
|
+
)
|
|
94
|
+
except jwt.PyJWTError:
|
|
95
|
+
raise HTTPException(
|
|
96
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
97
|
+
detail="Invalid token signature or expired token",
|
|
98
|
+
headers={"WWW-Authenticate": "Bearer"},
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
user = await user_repo.get_by_id(db, user_id=user_id)
|
|
102
|
+
if user is None:
|
|
103
|
+
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="User not found")
|
|
104
|
+
return user
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Async
|
|
108
|
+
|
|
109
|
+
- **Use async** for all I/O operations (database, HTTP calls, file I/O)
|
|
110
|
+
- **Never block the event loop** - no sync I/O in async endpoints
|
|
111
|
+
- **Use `asyncio.gather`** for parallel async operations
|
|
112
|
+
- **Background tasks** - use `BackgroundTasks` for non-critical work
|
|
113
|
+
|
|
114
|
+
## Error Handling
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from fastapi import HTTPException
|
|
118
|
+
|
|
119
|
+
class AppException(HTTPException):
|
|
120
|
+
def __init__(self, status_code: int, detail: str, code: str):
|
|
121
|
+
super().__init__(status_code=status_code, detail=detail)
|
|
122
|
+
self.code = code
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Security
|
|
126
|
+
|
|
127
|
+
- **OAuth2 with JWT** - use `python-jose`
|
|
128
|
+
- **Password hashing** - bcrypt via `passlib`
|
|
129
|
+
- **CORS** - configure explicitly
|
|
130
|
+
- **Rate limiting** - use `slowapi`
|
|
131
|
+
- **Input validation** - Pydantic handles this automatically
|
|
132
|
+
|
|
133
|
+
## Testing
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
import pytest
|
|
137
|
+
from httpx import AsyncClient
|
|
138
|
+
|
|
139
|
+
@pytest.mark.asyncio
|
|
140
|
+
async def test_create_user(client: AsyncClient):
|
|
141
|
+
response = await client.post("/api/v1/users", json={
|
|
142
|
+
"email": "test@example.com",
|
|
143
|
+
"name": "Test User"
|
|
144
|
+
})
|
|
145
|
+
assert response.status_code == 201
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Anti-Patterns
|
|
149
|
+
|
|
150
|
+
- [FAIL] Business logic in route handlers - use services
|
|
151
|
+
- [FAIL] Raw SQL without ORM - use SQLAlchemy
|
|
152
|
+
- [FAIL] Sync database calls - use async drivers
|
|
153
|
+
- [FAIL] Hardcoded settings - use Pydantic BaseSettings
|
|
154
|
+
- [FAIL] No schema validation - always use Pydantic models
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
## Code Examples
|
|
158
|
+
|
|
159
|
+
See `EXAMPLES.md` for detailed code examples.
|
|
160
|
+
|
|
161
|
+
## Validation Checklist
|
|
162
|
+
|
|
163
|
+
What to verify during the review phase before completing the task.
|
|
164
|
+
|
|
165
|
+
## Common Mistakes
|
|
166
|
+
|
|
167
|
+
Anti-patterns and things to explicitly avoid. See `TROUBLESHOOTING.md`.
|
|
168
|
+
|
|
169
|
+
## Integration Notes
|
|
170
|
+
|
|
171
|
+
How this skill interacts with other skills.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# fastapi Troubleshooting & Common Mistakes
|
|
2
|
+
|
|
3
|
+
## 1. Pydantic v1 vs v2 Deprecations
|
|
4
|
+
|
|
5
|
+
- **Symptom**: Warnings or crashes regarding @validator or .dict() methods.
|
|
6
|
+
- **Root Cause**: FastAPI projects upgrading to Pydantic v2.
|
|
7
|
+
- **Fix**: Use @field_validator instead of @validator, and .model_dump() instead of .dict().
|
|
8
|
+
|
|
9
|
+
## 2. Database Session Leaks
|
|
10
|
+
|
|
11
|
+
- **Symptom**: Database pool runs out of connections after a few requests.
|
|
12
|
+
- **Root Cause**: Database sessions opened manually without proper try...finally or dependency injection.
|
|
13
|
+
- **Fix**: Always provide database sessions via Depends(get_db) with a yield block.
|
|
14
|
+
|
|
15
|
+
## 3. Unhandled Validation Errors Returning Inconsistent JSON
|
|
16
|
+
|
|
17
|
+
- **Symptom**: Frontend receives raw 422 arrays without matching standard API error response envelope.
|
|
18
|
+
- **Root Cause**: Missing custom RequestValidationError handler.
|
|
19
|
+
- **Fix**: Register an app-level exception handler for RequestValidationError that normalizes error shapes.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
schemaVersion: 2
|
|
2
|
+
id: fastapi
|
|
3
|
+
name: FastAPI
|
|
4
|
+
category: backend
|
|
5
|
+
type: instruction-only
|
|
6
|
+
requires: []
|
|
7
|
+
optional: [postgres, redis, docker]
|
|
8
|
+
conflicts: [nestjs, express]
|
|
9
|
+
weight: 8
|
|
10
|
+
resources:
|
|
11
|
+
- EXAMPLES.md
|
|
12
|
+
- SKILL.md
|
|
13
|
+
- TROUBLESHOOTING.md
|
|
14
|
+
- VALIDATION.json
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# generators Examples - Anti-patterns vs ContextOS Standard
|
|
2
|
+
|
|
3
|
+
## Example 1: Technical Documentation Generation
|
|
4
|
+
|
|
5
|
+
### Anti-pattern: Scaffolding from Scratch Without Templates
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
Agent drafts a 2-paragraph "architecture overview" missing databases, security, and hosting models.
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Best practice: ContextOS Standard (ctx init Template Generation)
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
Generates complete engineering suite:
|
|
15
|
+
- PRD.md (User personas, in-scope, out-of-scope, acceptance criteria)
|
|
16
|
+
- ARCHITECTURE.md (C4 model, data flow, scaling boundaries)
|
|
17
|
+
- DATABASE.md (ERD, indexing strategy, migration plans)
|
|
18
|
+
- API.md (OpenAPI 3.1 endpoints, error codes, authentication)
|
|
19
|
+
```
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: document-generator
|
|
3
|
+
description: >
|
|
4
|
+
Generates project documentation from a single idea. Creates PRD, Architecture,
|
|
5
|
+
Database, API, UI, Roadmap, Tasks, Decision Records, and Project Graph
|
|
6
|
+
using templates. Supports incremental updates.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# document-generator
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Automated technical documentation generator. Transforms initial project ideas and specs into comprehensive PRDs, architecture schemas, API contracts, database ERDs, and roadmap task breakdowns.
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
Activate during project kickoff (ctx init), new service scaffolding, or when generating baseline technical specs from high-level user requirements.
|
|
18
|
+
|
|
19
|
+
## Rules & Patterns
|
|
20
|
+
|
|
21
|
+
You generate project documentation from a user's idea. Use the templates in `templates/` as the structure for each document.
|
|
22
|
+
|
|
23
|
+
## Workflows & CLI Commands
|
|
24
|
+
|
|
25
|
+
### Project Initialization (`contextos init`)
|
|
26
|
+
|
|
27
|
+
Full project initialization. From one user prompt, generate foundational documentation:
|
|
28
|
+
|
|
29
|
+
1. Ask clarifying questions (see context-os SKILL.md)
|
|
30
|
+
2. Select profile and skill pack
|
|
31
|
+
3. Generate documents in this order:
|
|
32
|
+
- `docs/PRD.md` - Product Requirements (from template)
|
|
33
|
+
- `docs/ARCHITECTURE.md` - System Architecture
|
|
34
|
+
- `docs/DATABASE.md` - Database Schema
|
|
35
|
+
- `docs/API.md` - API Specification (optional, when backend API layer is present)
|
|
36
|
+
- `docs/UI.md` - UI/UX Specification (optional, when UI layer is present)
|
|
37
|
+
- `docs/ROADMAP.md` - Development Roadmap
|
|
38
|
+
- `docs/TASKS.md` - Task Breakdown
|
|
39
|
+
- `docs/PROJECT_GRAPH.md` - Project Graph
|
|
40
|
+
4. Create `docs/decisions/` directory for future ADRs
|
|
41
|
+
5. Generate agent configuration via Adapters skill (`contextos export all`)
|
|
42
|
+
|
|
43
|
+
### Incremental Updates
|
|
44
|
+
|
|
45
|
+
When project requirements or schemas change:
|
|
46
|
+
|
|
47
|
+
1. Identify which documents are affected
|
|
48
|
+
2. Update only affected documents
|
|
49
|
+
3. Show diff of changes to user
|
|
50
|
+
4. Update Project Graph if structure changed
|
|
51
|
+
|
|
52
|
+
### Task Breakdown & Planning (`contextos resolve` & `/plan`)
|
|
53
|
+
|
|
54
|
+
Generate vertical development tasks from existing PRD and architecture:
|
|
55
|
+
|
|
56
|
+
1. Read `docs/PRD.md` and `docs/ARCHITECTURE.md`
|
|
57
|
+
2. Run `contextos resolve "<task description>"` to resolve minimal required skills
|
|
58
|
+
3. Break modules into vertical features and tasks (< 2 hours each)
|
|
59
|
+
4. Estimate complexity (S/M/L/XL)
|
|
60
|
+
5. Output to `docs/TASKS.md` or task implementation plan
|
|
61
|
+
|
|
62
|
+
## Template Usage
|
|
63
|
+
|
|
64
|
+
Each template contains:
|
|
65
|
+
|
|
66
|
+
- **Section headers** - required sections for the document
|
|
67
|
+
- **Placeholder prompts** - `{{description}}` markers that guide content generation
|
|
68
|
+
- **Examples** - sample content to illustrate the expected format
|
|
69
|
+
- **Validation rules** - what must be present for the document to be valid
|
|
70
|
+
|
|
71
|
+
When generating a document:
|
|
72
|
+
|
|
73
|
+
1. Read the template
|
|
74
|
+
2. Fill in each section based on the user's idea and clarifying answers
|
|
75
|
+
3. Replace all `{{placeholders}}` with real content
|
|
76
|
+
4. Remove the template comments (lines starting with `<!-- -->`)
|
|
77
|
+
5. Validate: ensure all required sections are present
|
|
78
|
+
|
|
79
|
+
## Document Dependencies
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
PRD.md
|
|
83
|
+
├── ARCHITECTURE.md
|
|
84
|
+
│ ├── DATABASE.md
|
|
85
|
+
│ ├── API.md
|
|
86
|
+
│ └── DEPLOYMENT.md
|
|
87
|
+
├── UI.md
|
|
88
|
+
├── ROADMAP.md
|
|
89
|
+
│ └── TASKS.md
|
|
90
|
+
└── PROJECT_GRAPH.md
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
When updating a parent document, check if child documents need updates too.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## Code Examples
|
|
97
|
+
|
|
98
|
+
See `EXAMPLES.md` for detailed code examples.
|
|
99
|
+
|
|
100
|
+
## Validation Checklist
|
|
101
|
+
|
|
102
|
+
What to verify during the review phase before completing the task.
|
|
103
|
+
|
|
104
|
+
## Common Mistakes
|
|
105
|
+
|
|
106
|
+
Anti-patterns and things to explicitly avoid. See `TROUBLESHOOTING.md`.
|
|
107
|
+
|
|
108
|
+
## Integration Notes
|
|
109
|
+
|
|
110
|
+
How this skill interacts with other skills.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# generators Troubleshooting & Common Mistakes
|
|
2
|
+
|
|
3
|
+
## 1. Generic Boilerplate Generation
|
|
4
|
+
|
|
5
|
+
- **Symptom**: Generated documentation contains placeholders like [Insert DB Name here].
|
|
6
|
+
- **Root Cause**: Generating docs before clarifying core project constraints.
|
|
7
|
+
- **Fix**: Run the interview-me protocol before generating technical documentation.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
schemaVersion: 2
|
|
2
|
+
name: generators
|
|
3
|
+
category: engineering
|
|
4
|
+
type: compiler
|
|
5
|
+
description: >
|
|
6
|
+
Generates complete project documentation (PRD, Architecture, Database, API, UI,
|
|
7
|
+
Roadmap, Tasks) from ideas and templates with incremental update support.
|
|
8
|
+
version: 1.0.0
|
|
9
|
+
resources:
|
|
10
|
+
- EXAMPLES.md
|
|
11
|
+
- SKILL.md
|
|
12
|
+
- TROUBLESHOOTING.md
|
|
13
|
+
- VALIDATION.json
|
|
14
|
+
- templates/API.md
|
|
15
|
+
- templates/ARCHITECTURE.md
|
|
16
|
+
- templates/DATABASE.md
|
|
17
|
+
- templates/DECISION.md
|
|
18
|
+
- templates/PRD.md
|
|
19
|
+
- templates/PROJECT_GRAPH.md
|
|
20
|
+
- templates/ROADMAP.md
|
|
21
|
+
- templates/TASKS.md
|
|
22
|
+
- templates/UI.md
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# {{Project Name}} - API Specification
|
|
2
|
+
|
|
3
|
+
## Base URL
|
|
4
|
+
|
|
5
|
+
`{{base_url}}` (e.g., `https://api.example.com/v1`)
|
|
6
|
+
|
|
7
|
+
## Authentication
|
|
8
|
+
|
|
9
|
+
{{auth_method}} (e.g., Bearer token via JWT)
|
|
10
|
+
|
|
11
|
+
## Endpoints
|
|
12
|
+
|
|
13
|
+
### {{Module Name}}
|
|
14
|
+
|
|
15
|
+
#### `{{METHOD}} {{path}}`
|
|
16
|
+
|
|
17
|
+
{{description}}
|
|
18
|
+
|
|
19
|
+
**Request:**
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{{request_body}}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Response (200):**
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{{response_body}}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Errors:**
|
|
32
|
+
|
|
33
|
+
| Code | Description |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| 400 | {{bad_request_reason}} |
|
|
36
|
+
| 401 | Unauthorized |
|
|
37
|
+
| 404 | {{not_found_reason}} |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Error Format
|
|
42
|
+
|
|
43
|
+
All errors follow this format:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"error": {
|
|
48
|
+
"code": "ERROR_CODE",
|
|
49
|
+
"message": "Human-readable message",
|
|
50
|
+
"details": {}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Pagination
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"data": [...],
|
|
60
|
+
"pagination": {
|
|
61
|
+
"page": 1,
|
|
62
|
+
"per_page": 20,
|
|
63
|
+
"total": 100,
|
|
64
|
+
"total_pages": 5
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Rate Limiting
|
|
70
|
+
|
|
71
|
+
- {{rate_limit}} requests per {{window}}
|
|
72
|
+
- Headers: `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`
|
|
73
|
+
|
|
74
|
+
## Versioning
|
|
75
|
+
|
|
76
|
+
- URL-based: `/v1/`, `/v2/`
|
|
77
|
+
- Breaking changes require new version
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# {{Project Name}} - System Architecture
|
|
2
|
+
|
|
3
|
+
## Architecture Overview
|
|
4
|
+
<!-- High-level architecture description and diagram -->
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
{{architecture_diagram}}
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Tech Stack
|
|
11
|
+
|
|
12
|
+
| Layer | Technology | Reason |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| Frontend | {{e.g., Next.js + React}} | {{reason}} |
|
|
15
|
+
| Backend | {{e.g., Node.js + Express}} | {{reason}} |
|
|
16
|
+
| Database | {{e.g., PostgreSQL}} | {{reason}} |
|
|
17
|
+
| Cache | {{e.g., Redis}} | {{reason}} |
|
|
18
|
+
| Auth | {{e.g., JWT + OAuth2}} | {{reason}} |
|
|
19
|
+
| Hosting | {{e.g., Vercel + Railway}} | {{reason}} |
|
|
20
|
+
|
|
21
|
+
## System Components
|
|
22
|
+
|
|
23
|
+
### {{Component 1 Name}}
|
|
24
|
+
|
|
25
|
+
- **Responsibility:** {{what it does}}
|
|
26
|
+
- **Interfaces:** {{what it exposes}}
|
|
27
|
+
- **Dependencies:** {{what it depends on}}
|
|
28
|
+
|
|
29
|
+
### {{Component 2 Name}}
|
|
30
|
+
|
|
31
|
+
- **Responsibility:** {{what it does}}
|
|
32
|
+
- **Interfaces:** {{what it exposes}}
|
|
33
|
+
- **Dependencies:** {{what it depends on}}
|
|
34
|
+
|
|
35
|
+
## Data Flow
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
User → Frontend → API Gateway → Service Layer → Database
|
|
39
|
+
↓
|
|
40
|
+
Cache Layer
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Directory Structure
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
{{project_root}}/
|
|
47
|
+
├── src/
|
|
48
|
+
│ ├── modules/ # Feature modules
|
|
49
|
+
│ │ ├── {{module_1}}/
|
|
50
|
+
│ │ └── {{module_2}}/
|
|
51
|
+
│ ├── shared/ # Shared utilities
|
|
52
|
+
│ ├── config/ # Configuration
|
|
53
|
+
│ └── types/ # Type definitions
|
|
54
|
+
├── tests/
|
|
55
|
+
├── docs/
|
|
56
|
+
└── infrastructure/
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Security Architecture
|
|
60
|
+
<!-- Authentication, authorization, data protection -->
|
|
61
|
+
|
|
62
|
+
## Scalability Considerations
|
|
63
|
+
<!-- How will this scale? What are the bottlenecks? -->
|
|
64
|
+
|
|
65
|
+
## Error Handling Strategy
|
|
66
|
+
<!-- How are errors propagated, logged, and reported? -->
|
|
67
|
+
|
|
68
|
+
## Key Architectural Decisions
|
|
69
|
+
<!-- Reference to ADRs in docs/decisions/ -->
|
|
70
|
+
- See `docs/decisions/` for all architectural decisions with rationale
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# {{Project Name}} - Database Schema
|
|
2
|
+
|
|
3
|
+
## Database Engine
|
|
4
|
+
|
|
5
|
+
{{e.g., PostgreSQL 16}}
|
|
6
|
+
|
|
7
|
+
## Entity Relationship Diagram
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
{{ER_diagram}}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Tables
|
|
14
|
+
|
|
15
|
+
### {{table_name}}
|
|
16
|
+
|
|
17
|
+
| Column | Type | Constraints | Description |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| id | UUID | PK, DEFAULT gen_random_uuid() | Primary key |
|
|
20
|
+
| {{column}} | {{type}} | {{constraints}} | {{description}} |
|
|
21
|
+
| created_at | TIMESTAMPTZ | NOT NULL, DEFAULT NOW() | Creation timestamp |
|
|
22
|
+
| updated_at | TIMESTAMPTZ | NOT NULL, DEFAULT NOW() | Last update timestamp |
|
|
23
|
+
|
|
24
|
+
**Indexes:**
|
|
25
|
+
|
|
26
|
+
- `idx_{{table}}_{{column}}` ON ({{column}})
|
|
27
|
+
|
|
28
|
+
**Relations:**
|
|
29
|
+
|
|
30
|
+
- {{table_name}}.{{fk_column}} → {{related_table}}.id
|
|
31
|
+
|
|
32
|
+
## Migrations Strategy
|
|
33
|
+
<!-- How are schema changes applied? -->
|
|
34
|
+
- Tool: {{e.g., Prisma Migrate, Alembic, Knex}}
|
|
35
|
+
- Naming: `YYYYMMDD_HHMMSS_description`
|
|
36
|
+
- Rule: Never modify existing migrations, always create new ones
|
|
37
|
+
|
|
38
|
+
## Seed Data
|
|
39
|
+
<!-- What data needs to exist for the app to work? -->
|
|
40
|
+
|
|
41
|
+
## Performance Considerations
|
|
42
|
+
<!-- Indexes, query optimization, connection pooling -->
|