@acmeacmeio/setup-sh 0.2.6
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/README.md +212 -0
- package/package.json +39 -0
- package/src/cli.mjs +614 -0
- package/templates/.claude/agents/code-simplifier.md +52 -0
- package/templates/.claude/commands/auto.md +85 -0
- package/templates/.claude/commands/clean-copy.md +93 -0
- package/templates/.claude/commands/fix-issue.md +34 -0
- package/templates/.claude/commands/review.md +46 -0
- package/templates/.claude/router/classify.js +241 -0
- package/templates/.claude/router/registry.json +49 -0
- package/templates/.claude/settings.json +113 -0
- package/templates/.claude/skills/api-design/SKILL.md +77 -0
- package/templates/.claude/skills/security-review/SKILL.md +65 -0
- package/templates/.codex/config.toml +31 -0
- package/templates/.codex/skills/api-design/SKILL.md +77 -0
- package/templates/.codex/skills/security-review/SKILL.md +65 -0
- package/templates/.cursor/commands/auto.md +55 -0
- package/templates/.cursor/commands/clean-copy.md +80 -0
- package/templates/.cursor/commands/code-simplifier.md +28 -0
- package/templates/.cursor/commands/fix-issue.md +28 -0
- package/templates/.cursor/commands/review.md +41 -0
- package/templates/.cursor/hooks.json +11 -0
- package/templates/.cursor/rules/api-design.mdc +80 -0
- package/templates/.cursor/rules/git-workflow.mdc +73 -0
- package/templates/.cursor/rules/security.mdc +69 -0
- package/templates/.cursor/rules/tdd.mdc +35 -0
- package/templates/.cursor/rules/typescript.mdc +82 -0
- package/templates/.cursorignore.template +20 -0
- package/templates/.gitignore.template +10 -0
- package/templates/.mcp.json +16 -0
- package/templates/AGENTS.md +118 -0
- package/templates/CLAUDE.md +138 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# API Design Skill
|
|
2
|
+
|
|
3
|
+
## REST + Zod Patterns
|
|
4
|
+
|
|
5
|
+
### Route Structure
|
|
6
|
+
|
|
7
|
+
| Method | Path | Purpose |
|
|
8
|
+
| ------ | -------------- | -------- |
|
|
9
|
+
| GET | /resources | List all |
|
|
10
|
+
| GET | /resources/:id | Get one |
|
|
11
|
+
| POST | /resources | Create |
|
|
12
|
+
| PUT | /resources/:id | Replace |
|
|
13
|
+
| PATCH | /resources/:id | Update |
|
|
14
|
+
| DELETE | /resources/:id | Delete |
|
|
15
|
+
|
|
16
|
+
### Validation with Zod
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
|
|
21
|
+
// Define schemas
|
|
22
|
+
const CreateUserSchema = z.object({
|
|
23
|
+
email: z.string().email(),
|
|
24
|
+
name: z.string().min(1).max(100),
|
|
25
|
+
role: z.enum(["user", "admin"]).default("user"),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Infer types from schemas
|
|
29
|
+
type CreateUserInput = z.infer<typeof CreateUserSchema>;
|
|
30
|
+
|
|
31
|
+
// Validate at controller boundary
|
|
32
|
+
app.post("/users", async (req, res) => {
|
|
33
|
+
const result = CreateUserSchema.safeParse(req.body);
|
|
34
|
+
if (!result.success) {
|
|
35
|
+
return res.status(400).json({
|
|
36
|
+
error: "Validation failed",
|
|
37
|
+
details: result.error.flatten(),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// result.data is fully typed
|
|
41
|
+
const user = await userService.create(result.data);
|
|
42
|
+
return res.status(201).json({ data: user });
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Response Format
|
|
47
|
+
|
|
48
|
+
**Success (single)**
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{ "data": { "id": "123", "name": "John" } }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Success (list)**
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{ "data": [...], "total": 100, "page": 1, "pageSize": 20 }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Error**
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{ "error": "Validation failed", "field": "email", "code": "INVALID_EMAIL" }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### HTTP Status Codes
|
|
67
|
+
|
|
68
|
+
| Code | Usage |
|
|
69
|
+
| ---- | ------------------------- |
|
|
70
|
+
| 200 | Success (GET, PUT, PATCH) |
|
|
71
|
+
| 201 | Created (POST) |
|
|
72
|
+
| 204 | No content (DELETE) |
|
|
73
|
+
| 400 | Validation error |
|
|
74
|
+
| 401 | Unauthorized |
|
|
75
|
+
| 403 | Forbidden |
|
|
76
|
+
| 404 | Not found |
|
|
77
|
+
| 500 | Internal error |
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Security Review Skill
|
|
2
|
+
|
|
3
|
+
## Security Audit Checklist
|
|
4
|
+
|
|
5
|
+
### Authentication
|
|
6
|
+
|
|
7
|
+
- [ ] Tokens are validated on every request
|
|
8
|
+
- [ ] Passwords are hashed with bcrypt or argon2 (not MD5/SHA1)
|
|
9
|
+
- [ ] Sessions expire appropriately
|
|
10
|
+
- [ ] Password reset tokens are single-use and time-limited
|
|
11
|
+
- [ ] Multi-factor authentication where appropriate
|
|
12
|
+
|
|
13
|
+
### Authorization
|
|
14
|
+
|
|
15
|
+
- [ ] Users can only access their own data
|
|
16
|
+
- [ ] Admin endpoints require admin role
|
|
17
|
+
- [ ] API keys are scoped appropriately
|
|
18
|
+
- [ ] Role checks happen server-side, not just client
|
|
19
|
+
- [ ] Sensitive operations require re-authentication
|
|
20
|
+
|
|
21
|
+
### Input Validation
|
|
22
|
+
|
|
23
|
+
- [ ] All user input is validated (Zod schemas at boundaries)
|
|
24
|
+
- [ ] SQL queries use parameterized statements
|
|
25
|
+
- [ ] File uploads are restricted by type and size
|
|
26
|
+
- [ ] URLs and redirects are validated against allowlist
|
|
27
|
+
- [ ] HTML output is escaped to prevent XSS
|
|
28
|
+
|
|
29
|
+
### Secrets Management
|
|
30
|
+
|
|
31
|
+
- [ ] No hardcoded credentials in code
|
|
32
|
+
- [ ] Environment variables for all secrets
|
|
33
|
+
- [ ] .env files are gitignored
|
|
34
|
+
- [ ] Secrets rotated regularly
|
|
35
|
+
- [ ] Different credentials per environment
|
|
36
|
+
|
|
37
|
+
### Data Protection
|
|
38
|
+
|
|
39
|
+
- [ ] Sensitive data encrypted at rest
|
|
40
|
+
- [ ] HTTPS enforced in production
|
|
41
|
+
- [ ] Passwords never logged
|
|
42
|
+
- [ ] PII minimized and access-controlled
|
|
43
|
+
- [ ] Data retention policies enforced
|
|
44
|
+
|
|
45
|
+
### Error Handling
|
|
46
|
+
|
|
47
|
+
- [ ] No stack traces in production responses
|
|
48
|
+
- [ ] Generic error messages to users
|
|
49
|
+
- [ ] Detailed errors logged server-side
|
|
50
|
+
- [ ] Failed login attempts rate-limited
|
|
51
|
+
|
|
52
|
+
### Dependencies
|
|
53
|
+
|
|
54
|
+
- [ ] Dependencies regularly updated
|
|
55
|
+
- [ ] Known vulnerabilities addressed (npm audit)
|
|
56
|
+
- [ ] Minimal dependencies (smaller attack surface)
|
|
57
|
+
- [ ] Lock files committed (package-lock.json)
|
|
58
|
+
|
|
59
|
+
## Common Vulnerabilities
|
|
60
|
+
|
|
61
|
+
1. **SQL Injection**: Use parameterized queries
|
|
62
|
+
2. **XSS**: Escape HTML output, use CSP headers
|
|
63
|
+
3. **CSRF**: Use CSRF tokens for state-changing requests
|
|
64
|
+
4. **IDOR**: Verify user owns the resource they're accessing
|
|
65
|
+
5. **Secrets in Code**: Use environment variables
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# ACME-SOUL Codex Configuration
|
|
2
|
+
# Generated by @acmeacmeio/setup-sh
|
|
3
|
+
|
|
4
|
+
# Model and approval settings
|
|
5
|
+
model = "gpt-4.1"
|
|
6
|
+
approval_policy = "on-failure"
|
|
7
|
+
|
|
8
|
+
# Sandbox mode: "workspace-write" allows writing to workspace but restricts system access
|
|
9
|
+
# Other options: "off", "workspace-read", "full"
|
|
10
|
+
sandbox_mode = "workspace-write"
|
|
11
|
+
|
|
12
|
+
# Feature flags
|
|
13
|
+
[features]
|
|
14
|
+
shell_snapshot = true
|
|
15
|
+
|
|
16
|
+
# MCP Servers Configuration
|
|
17
|
+
# Note: Codex integrates MCP servers directly in config.toml
|
|
18
|
+
[mcpServers.github]
|
|
19
|
+
command = "npx"
|
|
20
|
+
args = ["-y", "@modelcontextprotocol/server-github"]
|
|
21
|
+
|
|
22
|
+
[mcpServers.github.env]
|
|
23
|
+
GITHUB_PERSONAL_ACCESS_TOKEN = "${GITHUB_TOKEN}"
|
|
24
|
+
|
|
25
|
+
[mcpServers.sequential-thinking]
|
|
26
|
+
command = "npx"
|
|
27
|
+
args = ["-y", "@modelcontextprotocol/server-sequential-thinking"]
|
|
28
|
+
|
|
29
|
+
# Notification hooks (Codex only supports post-execution notify hooks)
|
|
30
|
+
# [hooks]
|
|
31
|
+
# notify = ["your-notification-command"]
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# API Design Skill
|
|
2
|
+
|
|
3
|
+
## REST + Zod Patterns
|
|
4
|
+
|
|
5
|
+
### Route Structure
|
|
6
|
+
|
|
7
|
+
| Method | Path | Purpose |
|
|
8
|
+
| ------ | -------------- | -------- |
|
|
9
|
+
| GET | /resources | List all |
|
|
10
|
+
| GET | /resources/:id | Get one |
|
|
11
|
+
| POST | /resources | Create |
|
|
12
|
+
| PUT | /resources/:id | Replace |
|
|
13
|
+
| PATCH | /resources/:id | Update |
|
|
14
|
+
| DELETE | /resources/:id | Delete |
|
|
15
|
+
|
|
16
|
+
### Validation with Zod
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
|
|
21
|
+
// Define schemas
|
|
22
|
+
const CreateUserSchema = z.object({
|
|
23
|
+
email: z.string().email(),
|
|
24
|
+
name: z.string().min(1).max(100),
|
|
25
|
+
role: z.enum(["user", "admin"]).default("user"),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Infer types from schemas
|
|
29
|
+
type CreateUserInput = z.infer<typeof CreateUserSchema>;
|
|
30
|
+
|
|
31
|
+
// Validate at controller boundary
|
|
32
|
+
app.post("/users", async (req, res) => {
|
|
33
|
+
const result = CreateUserSchema.safeParse(req.body);
|
|
34
|
+
if (!result.success) {
|
|
35
|
+
return res.status(400).json({
|
|
36
|
+
error: "Validation failed",
|
|
37
|
+
details: result.error.flatten(),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// result.data is fully typed
|
|
41
|
+
const user = await userService.create(result.data);
|
|
42
|
+
return res.status(201).json({ data: user });
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Response Format
|
|
47
|
+
|
|
48
|
+
**Success (single)**
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{ "data": { "id": "123", "name": "John" } }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Success (list)**
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{ "data": [...], "total": 100, "page": 1, "pageSize": 20 }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Error**
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{ "error": "Validation failed", "field": "email", "code": "INVALID_EMAIL" }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### HTTP Status Codes
|
|
67
|
+
|
|
68
|
+
| Code | Usage |
|
|
69
|
+
| ---- | ------------------------- |
|
|
70
|
+
| 200 | Success (GET, PUT, PATCH) |
|
|
71
|
+
| 201 | Created (POST) |
|
|
72
|
+
| 204 | No content (DELETE) |
|
|
73
|
+
| 400 | Validation error |
|
|
74
|
+
| 401 | Unauthorized |
|
|
75
|
+
| 403 | Forbidden |
|
|
76
|
+
| 404 | Not found |
|
|
77
|
+
| 500 | Internal error |
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Security Review Skill
|
|
2
|
+
|
|
3
|
+
## Security Audit Checklist
|
|
4
|
+
|
|
5
|
+
### Authentication
|
|
6
|
+
|
|
7
|
+
- [ ] Tokens are validated on every request
|
|
8
|
+
- [ ] Passwords are hashed with bcrypt or argon2 (not MD5/SHA1)
|
|
9
|
+
- [ ] Sessions expire appropriately
|
|
10
|
+
- [ ] Password reset tokens are single-use and time-limited
|
|
11
|
+
- [ ] Multi-factor authentication where appropriate
|
|
12
|
+
|
|
13
|
+
### Authorization
|
|
14
|
+
|
|
15
|
+
- [ ] Users can only access their own data
|
|
16
|
+
- [ ] Admin endpoints require admin role
|
|
17
|
+
- [ ] API keys are scoped appropriately
|
|
18
|
+
- [ ] Role checks happen server-side, not just client
|
|
19
|
+
- [ ] Sensitive operations require re-authentication
|
|
20
|
+
|
|
21
|
+
### Input Validation
|
|
22
|
+
|
|
23
|
+
- [ ] All user input is validated (Zod schemas at boundaries)
|
|
24
|
+
- [ ] SQL queries use parameterized statements
|
|
25
|
+
- [ ] File uploads are restricted by type and size
|
|
26
|
+
- [ ] URLs and redirects are validated against allowlist
|
|
27
|
+
- [ ] HTML output is escaped to prevent XSS
|
|
28
|
+
|
|
29
|
+
### Secrets Management
|
|
30
|
+
|
|
31
|
+
- [ ] No hardcoded credentials in code
|
|
32
|
+
- [ ] Environment variables for all secrets
|
|
33
|
+
- [ ] .env files are gitignored
|
|
34
|
+
- [ ] Secrets rotated regularly
|
|
35
|
+
- [ ] Different credentials per environment
|
|
36
|
+
|
|
37
|
+
### Data Protection
|
|
38
|
+
|
|
39
|
+
- [ ] Sensitive data encrypted at rest
|
|
40
|
+
- [ ] HTTPS enforced in production
|
|
41
|
+
- [ ] Passwords never logged
|
|
42
|
+
- [ ] PII minimized and access-controlled
|
|
43
|
+
- [ ] Data retention policies enforced
|
|
44
|
+
|
|
45
|
+
### Error Handling
|
|
46
|
+
|
|
47
|
+
- [ ] No stack traces in production responses
|
|
48
|
+
- [ ] Generic error messages to users
|
|
49
|
+
- [ ] Detailed errors logged server-side
|
|
50
|
+
- [ ] Failed login attempts rate-limited
|
|
51
|
+
|
|
52
|
+
### Dependencies
|
|
53
|
+
|
|
54
|
+
- [ ] Dependencies regularly updated
|
|
55
|
+
- [ ] Known vulnerabilities addressed (npm audit)
|
|
56
|
+
- [ ] Minimal dependencies (smaller attack surface)
|
|
57
|
+
- [ ] Lock files committed (package-lock.json)
|
|
58
|
+
|
|
59
|
+
## Common Vulnerabilities
|
|
60
|
+
|
|
61
|
+
1. **SQL Injection**: Use parameterized queries
|
|
62
|
+
2. **XSS**: Escape HTML output, use CSP headers
|
|
63
|
+
3. **CSRF**: Use CSRF tokens for state-changing requests
|
|
64
|
+
4. **IDOR**: Verify user owns the resource they're accessing
|
|
65
|
+
5. **Secrets in Code**: Use environment variables
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Intent Router
|
|
2
|
+
|
|
3
|
+
Automatically classify user intent and route to the appropriate workflow.
|
|
4
|
+
|
|
5
|
+
## Available Commands
|
|
6
|
+
|
|
7
|
+
- `fix-issue` - Fix a GitHub issue following TDD workflow
|
|
8
|
+
- `review` - Run code review checklist
|
|
9
|
+
- `clean-copy` - Restructure commits into clean history
|
|
10
|
+
- `code-simplifier` - Simplify code for clarity and maintainability
|
|
11
|
+
|
|
12
|
+
## Task
|
|
13
|
+
|
|
14
|
+
Classify the request and determine the best workflow.
|
|
15
|
+
|
|
16
|
+
### Classification Process
|
|
17
|
+
|
|
18
|
+
1. **Extract key intent** from the natural language request
|
|
19
|
+
2. **Match against available commands** - find the best matching workflow
|
|
20
|
+
3. **Extract arguments** - pull out issue numbers, branch names, or other parameters
|
|
21
|
+
4. **Determine confidence** - how well does this match?
|
|
22
|
+
|
|
23
|
+
### Confidence Guidelines
|
|
24
|
+
|
|
25
|
+
- **0.9-1.0**: Exact trigger phrase match
|
|
26
|
+
- **0.7-0.9**: Clear intent, slightly different wording
|
|
27
|
+
- **0.5-0.7**: Probable match, some ambiguity
|
|
28
|
+
- **Below 0.5**: Ask user to clarify
|
|
29
|
+
|
|
30
|
+
### If Low Confidence
|
|
31
|
+
|
|
32
|
+
If confidence is below 0.7, present options to the user:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
I'm not sure which workflow you want. Did you mean:
|
|
36
|
+
|
|
37
|
+
1. fix-issue - Fix a GitHub issue with TDD
|
|
38
|
+
2. review - Review code changes
|
|
39
|
+
3. clean-copy - Restructure commits
|
|
40
|
+
4. code-simplifier - Simplify and clean up code
|
|
41
|
+
|
|
42
|
+
Please choose or rephrase your request.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Examples
|
|
46
|
+
|
|
47
|
+
| Input | Match | Confidence |
|
|
48
|
+
| ----------------------- | ---------- | ---------- |
|
|
49
|
+
| "fix issue #123" | fix-issue | 0.95 |
|
|
50
|
+
| "I need to fix bug 456" | fix-issue | 0.85 |
|
|
51
|
+
| "review my changes" | review | 0.90 |
|
|
52
|
+
| "clean up my commits" | clean-copy | 0.85 |
|
|
53
|
+
| "simplify this code" | code-simplifier | 0.90 |
|
|
54
|
+
| "clean up this function"| code-simplifier | 0.80 |
|
|
55
|
+
| "help me code" | - | 0.30 |
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Clean Copy
|
|
2
|
+
|
|
3
|
+
Reimplement the current branch with clean, atomic commits suitable for reviewer comprehension.
|
|
4
|
+
|
|
5
|
+
## Context
|
|
6
|
+
|
|
7
|
+
Gather current state:
|
|
8
|
+
|
|
9
|
+
- **Source branch**: `git branch --show-current`
|
|
10
|
+
- **Git status**: `git status --short`
|
|
11
|
+
- **Commits since main**: `git log main..HEAD --oneline`
|
|
12
|
+
- **Diff stats**: `git diff main...HEAD --stat`
|
|
13
|
+
- **Full diff**: `git diff main...HEAD`
|
|
14
|
+
|
|
15
|
+
## Task
|
|
16
|
+
|
|
17
|
+
Create a new branch with restructured commits that tell a clear story.
|
|
18
|
+
|
|
19
|
+
### Steps
|
|
20
|
+
|
|
21
|
+
1. **Validate source branch**
|
|
22
|
+
- Ensure no uncommitted changes
|
|
23
|
+
- Ensure branch is up to date with main
|
|
24
|
+
|
|
25
|
+
2. **Analyze the full diff**
|
|
26
|
+
- Understand the complete intended final state
|
|
27
|
+
- Identify logical units of change
|
|
28
|
+
|
|
29
|
+
3. **Create clean branch from main**
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git checkout main
|
|
33
|
+
git pull origin main
|
|
34
|
+
git checkout -b {source_branch}-clean
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
4. **Plan commit storyline**
|
|
38
|
+
- Break changes into self-contained logical steps
|
|
39
|
+
- Each commit should represent a single coherent idea
|
|
40
|
+
- Order commits so each builds on the previous (tutorial-style)
|
|
41
|
+
- Aim for 3-7 commits typically
|
|
42
|
+
|
|
43
|
+
5. **Reimplement step-by-step**
|
|
44
|
+
For each logical unit:
|
|
45
|
+
- Apply the relevant changes
|
|
46
|
+
- Write a clear commit message following conventional commits
|
|
47
|
+
- Use `git commit --no-verify` for intermediate commits (types/tests may not pass until complete)
|
|
48
|
+
|
|
49
|
+
6. **Verify final state matches source**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git diff {source_branch}..HEAD
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This diff should be empty. If not, reconcile differences.
|
|
56
|
+
|
|
57
|
+
7. **Final commit verification**
|
|
58
|
+
- The final commit must NOT use `--no-verify`
|
|
59
|
+
- All checks (lint, types, tests) must pass
|
|
60
|
+
|
|
61
|
+
8. **Create PR**
|
|
62
|
+
- Follow project PR conventions
|
|
63
|
+
- Link to original branch or issue
|
|
64
|
+
|
|
65
|
+
### Rules
|
|
66
|
+
|
|
67
|
+
- End state must be byte-for-byte identical to source branch
|
|
68
|
+
- Each commit message should explain _why_, not just _what_
|
|
69
|
+
- If the source branch has a linked issue, reference it in the PR
|
|
70
|
+
|
|
71
|
+
### Example Commit Storyline
|
|
72
|
+
|
|
73
|
+
For a feature adding user authentication:
|
|
74
|
+
|
|
75
|
+
1. `feat: add User model and database migration`
|
|
76
|
+
2. `feat: implement password hashing utilities`
|
|
77
|
+
3. `feat: add login/logout API endpoints`
|
|
78
|
+
4. `feat: add session middleware`
|
|
79
|
+
5. `test: add authentication integration tests`
|
|
80
|
+
6. `docs: update API documentation with auth endpoints`
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Code Simplifier
|
|
2
|
+
|
|
3
|
+
Simplify and refine code for clarity, consistency, and maintainability while preserving all functionality.
|
|
4
|
+
|
|
5
|
+
## Process
|
|
6
|
+
|
|
7
|
+
1. Analyze the target code for complexity
|
|
8
|
+
2. Identify simplification opportunities
|
|
9
|
+
3. Propose and implement improvements
|
|
10
|
+
|
|
11
|
+
## Simplification Strategies
|
|
12
|
+
|
|
13
|
+
- Extract repeated code into functions
|
|
14
|
+
- Replace complex conditionals with early returns
|
|
15
|
+
- Simplify nested structures
|
|
16
|
+
- Use descriptive names that eliminate need for comments
|
|
17
|
+
- Remove dead code and unused variables
|
|
18
|
+
- Apply SOLID principles where appropriate
|
|
19
|
+
- AVOID nested ternary operators - prefer switch/if-else
|
|
20
|
+
|
|
21
|
+
## Rules
|
|
22
|
+
|
|
23
|
+
- NEVER change functionality
|
|
24
|
+
- Preserve all existing tests
|
|
25
|
+
- Make one logical change at a time
|
|
26
|
+
- Explain each simplification clearly
|
|
27
|
+
- Focus on readability over cleverness
|
|
28
|
+
- Choose clarity over brevity
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Fix Issue Workflow
|
|
2
|
+
|
|
3
|
+
When fixing a GitHub issue:
|
|
4
|
+
|
|
5
|
+
1. **Understand the issue**
|
|
6
|
+
- Read the issue description and comments
|
|
7
|
+
- Understand the expected vs actual behavior
|
|
8
|
+
- Identify affected files and components
|
|
9
|
+
|
|
10
|
+
2. **Write a failing test**
|
|
11
|
+
- Create a test that reproduces the issue
|
|
12
|
+
- Run it to confirm it fails
|
|
13
|
+
- The test should clearly demonstrate the bug
|
|
14
|
+
|
|
15
|
+
3. **Implement the fix**
|
|
16
|
+
- Write minimal code to fix the issue
|
|
17
|
+
- Keep changes focused on the bug
|
|
18
|
+
- Don't refactor unrelated code
|
|
19
|
+
|
|
20
|
+
4. **Verify the fix**
|
|
21
|
+
- Run the new test to confirm it passes
|
|
22
|
+
- Run all related tests to ensure no regressions
|
|
23
|
+
- Run lint and typecheck
|
|
24
|
+
|
|
25
|
+
5. **Create a PR**
|
|
26
|
+
- Use conventional commit: `fix: description`
|
|
27
|
+
- Reference the issue: `Fixes #123`
|
|
28
|
+
- Include before/after behavior in PR description
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Code Review Checklist
|
|
2
|
+
|
|
3
|
+
Review the code against this checklist:
|
|
4
|
+
|
|
5
|
+
## Testing
|
|
6
|
+
|
|
7
|
+
- [ ] Tests cover the changes
|
|
8
|
+
- [ ] Edge cases are tested
|
|
9
|
+
- [ ] Tests are readable and maintainable
|
|
10
|
+
|
|
11
|
+
## Code Quality
|
|
12
|
+
|
|
13
|
+
- [ ] No console.log or debug code
|
|
14
|
+
- [ ] No commented-out code
|
|
15
|
+
- [ ] Types are explicit (no `any`)
|
|
16
|
+
- [ ] No hardcoded values that should be config
|
|
17
|
+
- [ ] Follows existing patterns in codebase
|
|
18
|
+
|
|
19
|
+
## Error Handling
|
|
20
|
+
|
|
21
|
+
- [ ] Errors are handled appropriately
|
|
22
|
+
- [ ] Error messages are helpful
|
|
23
|
+
- [ ] No silent failures
|
|
24
|
+
|
|
25
|
+
## Security
|
|
26
|
+
|
|
27
|
+
- [ ] No credentials or secrets in code
|
|
28
|
+
- [ ] User input is validated
|
|
29
|
+
- [ ] No SQL injection or XSS vulnerabilities
|
|
30
|
+
|
|
31
|
+
## Performance
|
|
32
|
+
|
|
33
|
+
- [ ] No obvious performance issues
|
|
34
|
+
- [ ] No unnecessary re-renders (React)
|
|
35
|
+
- [ ] Database queries are efficient
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
- [ ] Complex logic has comments
|
|
40
|
+
- [ ] Public APIs have documentation
|
|
41
|
+
- [ ] Breaking changes are documented
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: REST API design patterns with Zod validation
|
|
3
|
+
globs: []
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# API Design Patterns
|
|
8
|
+
|
|
9
|
+
## REST + Zod
|
|
10
|
+
|
|
11
|
+
### Route Structure
|
|
12
|
+
|
|
13
|
+
| Method | Path | Purpose |
|
|
14
|
+
| ------ | -------------- | -------- |
|
|
15
|
+
| GET | /resources | List all |
|
|
16
|
+
| GET | /resources/:id | Get one |
|
|
17
|
+
| POST | /resources | Create |
|
|
18
|
+
| PUT | /resources/:id | Replace |
|
|
19
|
+
| PATCH | /resources/:id | Update |
|
|
20
|
+
| DELETE | /resources/:id | Delete |
|
|
21
|
+
|
|
22
|
+
### Validation with Zod
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { z } from "zod";
|
|
26
|
+
|
|
27
|
+
// Define schemas
|
|
28
|
+
const CreateUserSchema = z.object({
|
|
29
|
+
email: z.string().email(),
|
|
30
|
+
name: z.string().min(1).max(100),
|
|
31
|
+
role: z.enum(["user", "admin"]).default("user"),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Infer types from schemas
|
|
35
|
+
type CreateUserInput = z.infer<typeof CreateUserSchema>;
|
|
36
|
+
|
|
37
|
+
// Validate at controller boundary
|
|
38
|
+
app.post("/users", async (req, res) => {
|
|
39
|
+
const result = CreateUserSchema.safeParse(req.body);
|
|
40
|
+
if (!result.success) {
|
|
41
|
+
return res.status(400).json({
|
|
42
|
+
error: "Validation failed",
|
|
43
|
+
details: result.error.flatten(),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// result.data is fully typed
|
|
47
|
+
const user = await userService.create(result.data);
|
|
48
|
+
return res.status(201).json({ data: user });
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Response Format
|
|
53
|
+
|
|
54
|
+
**Success (single)**
|
|
55
|
+
```json
|
|
56
|
+
{ "data": { "id": "123", "name": "John" } }
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Success (list)**
|
|
60
|
+
```json
|
|
61
|
+
{ "data": [...], "total": 100, "page": 1, "pageSize": 20 }
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Error**
|
|
65
|
+
```json
|
|
66
|
+
{ "error": "Validation failed", "field": "email", "code": "INVALID_EMAIL" }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### HTTP Status Codes
|
|
70
|
+
|
|
71
|
+
| Code | Usage |
|
|
72
|
+
| ---- | ------------------------- |
|
|
73
|
+
| 200 | Success (GET, PUT, PATCH) |
|
|
74
|
+
| 201 | Created (POST) |
|
|
75
|
+
| 204 | No content (DELETE) |
|
|
76
|
+
| 400 | Validation error |
|
|
77
|
+
| 401 | Unauthorized |
|
|
78
|
+
| 403 | Forbidden |
|
|
79
|
+
| 404 | Not found |
|
|
80
|
+
| 500 | Internal error |
|