mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
- Convert 40 JS files to TypeScript (CLI, tools, core, MCP server) - Add Zod for runtime parameter validation - Add type definitions in src/types/ - Keep src/templates/ as JavaScript (dashboard frontend) - Update bin entries to use dist/ - Add tsconfig.json with strict mode - Add backward-compatible exports for tests - All 39 tests passing Breaking changes: None (backward compatible) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
123 lines
1.9 KiB
Plaintext
123 lines
1.9 KiB
Plaintext
# Rule Template: API Rules (Backend/Fullstack Only)
|
|
|
|
## Variables
|
|
- {TECH_STACK_NAME}: Tech stack display name
|
|
- {FILE_EXT}: File extension pattern
|
|
- {API_FRAMEWORK}: API framework (Express, FastAPI, etc)
|
|
|
|
## Output Format
|
|
|
|
```markdown
|
|
---
|
|
paths:
|
|
- "**/api/**/*.{FILE_EXT}"
|
|
- "**/routes/**/*.{FILE_EXT}"
|
|
- "**/endpoints/**/*.{FILE_EXT}"
|
|
- "**/controllers/**/*.{FILE_EXT}"
|
|
- "**/handlers/**/*.{FILE_EXT}"
|
|
---
|
|
|
|
# {TECH_STACK_NAME} API Rules
|
|
|
|
## Endpoint Design
|
|
|
|
[REST/GraphQL conventions from Exa research]
|
|
|
|
### URL Structure
|
|
- Resource naming (plural nouns)
|
|
- Nesting depth limits
|
|
- Query parameter conventions
|
|
- Version prefixing
|
|
|
|
### HTTP Methods
|
|
- GET: Read operations
|
|
- POST: Create operations
|
|
- PUT/PATCH: Update operations
|
|
- DELETE: Remove operations
|
|
|
|
### Status Codes
|
|
- 2xx: Success responses
|
|
- 4xx: Client errors
|
|
- 5xx: Server errors
|
|
|
|
## Request Validation
|
|
|
|
[Input validation patterns]
|
|
|
|
### Schema Validation
|
|
```{lang}
|
|
// Example validation schema
|
|
```
|
|
|
|
### Required Fields
|
|
- Validation approach
|
|
- Error messages format
|
|
- Sanitization rules
|
|
|
|
## Response Format
|
|
|
|
[Standard response structures]
|
|
|
|
### Success Response
|
|
```json
|
|
{
|
|
"data": {},
|
|
"meta": {}
|
|
}
|
|
```
|
|
|
|
### Pagination
|
|
```json
|
|
{
|
|
"data": [],
|
|
"pagination": {
|
|
"page": 1,
|
|
"limit": 20,
|
|
"total": 100
|
|
}
|
|
}
|
|
```
|
|
|
|
## Error Responses
|
|
|
|
[Error handling for APIs]
|
|
|
|
### Error Format
|
|
```json
|
|
{
|
|
"error": {
|
|
"code": "ERROR_CODE",
|
|
"message": "Human readable message",
|
|
"details": {}
|
|
}
|
|
}
|
|
```
|
|
|
|
### Common Error Codes
|
|
- VALIDATION_ERROR
|
|
- NOT_FOUND
|
|
- UNAUTHORIZED
|
|
- FORBIDDEN
|
|
|
|
## Authentication & Authorization
|
|
|
|
[Auth patterns]
|
|
- Token handling
|
|
- Permission checks
|
|
- Rate limiting
|
|
|
|
## Documentation
|
|
|
|
[API documentation standards]
|
|
- OpenAPI/Swagger
|
|
- Inline documentation
|
|
- Example requests/responses
|
|
```
|
|
|
|
## Content Guidelines
|
|
|
|
- Focus on API-specific patterns
|
|
- Include request/response examples
|
|
- Cover security considerations
|
|
- Reference framework conventions
|