opencode-agile-agent 1.0.1
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 +71 -0
- package/bin/cli.js +434 -0
- package/bin/validate-templates.js +58 -0
- package/package.json +52 -0
- package/templates/.opencode/ARCHITECTURE.md +368 -0
- package/templates/.opencode/README.md +391 -0
- package/templates/.opencode/agents/api-designer.md +312 -0
- package/templates/.opencode/agents/backend-specialist.md +214 -0
- package/templates/.opencode/agents/code-archaeologist.md +260 -0
- package/templates/.opencode/agents/database-architect.md +212 -0
- package/templates/.opencode/agents/debugger.md +302 -0
- package/templates/.opencode/agents/developer.md +523 -0
- package/templates/.opencode/agents/devops-engineer.md +253 -0
- package/templates/.opencode/agents/documentation-writer.md +247 -0
- package/templates/.opencode/agents/explorer-agent.md +239 -0
- package/templates/.opencode/agents/feature-lead.md +302 -0
- package/templates/.opencode/agents/frontend-specialist.md +186 -0
- package/templates/.opencode/agents/game-developer.md +391 -0
- package/templates/.opencode/agents/mobile-developer.md +264 -0
- package/templates/.opencode/agents/orchestrator.md +463 -0
- package/templates/.opencode/agents/penetration-tester.md +256 -0
- package/templates/.opencode/agents/performance-optimizer.md +292 -0
- package/templates/.opencode/agents/pr-reviewer.md +468 -0
- package/templates/.opencode/agents/product-manager.md +225 -0
- package/templates/.opencode/agents/product-owner.md +264 -0
- package/templates/.opencode/agents/project-planner.md +248 -0
- package/templates/.opencode/agents/qa-automation-engineer.md +276 -0
- package/templates/.opencode/agents/security-auditor.md +260 -0
- package/templates/.opencode/agents/seo-specialist.md +266 -0
- package/templates/.opencode/agents/system-analyst.md +428 -0
- package/templates/.opencode/agents/test-engineer.md +229 -0
- package/templates/.opencode/config.template.json +129 -0
- package/templates/.opencode/rules/coding-standards.md +250 -0
- package/templates/.opencode/rules/git-conventions.md +149 -0
- package/templates/.opencode/skills/api-patterns/SKILL.md +162 -0
- package/templates/.opencode/skills/brainstorming/SKILL.md +255 -0
- package/templates/.opencode/skills/clean-code/SKILL.md +351 -0
- package/templates/.opencode/skills/code-philosophy/SKILL.md +512 -0
- package/templates/.opencode/skills/frontend-design/SKILL.md +237 -0
- package/templates/.opencode/skills/intelligent-routing/SKILL.md +195 -0
- package/templates/.opencode/skills/parallel-agents/SKILL.md +274 -0
- package/templates/.opencode/skills/plan-writing/SKILL.md +251 -0
- package/templates/.opencode/skills/systematic-debugging/SKILL.md +210 -0
- package/templates/.opencode/skills/testing-patterns/SKILL.md +252 -0
- package/templates/.opencode/workflows/brainstorm.md +110 -0
- package/templates/.opencode/workflows/create.md +108 -0
- package/templates/.opencode/workflows/debug.md +128 -0
- package/templates/.opencode/workflows/deploy.md +160 -0
- package/templates/.opencode/workflows/enhance.md +253 -0
- package/templates/.opencode/workflows/orchestrate.md +130 -0
- package/templates/.opencode/workflows/plan.md +163 -0
- package/templates/.opencode/workflows/review.md +135 -0
- package/templates/.opencode/workflows/status.md +102 -0
- package/templates/.opencode/workflows/test.md +146 -0
- package/templates/AGENTS.template.md +426 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Check project status, health, and metrics. Use for quick project overview.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# /status Workflow
|
|
6
|
+
|
|
7
|
+
Get a quick overview of project status, health, and key metrics.
|
|
8
|
+
|
|
9
|
+
## When to Use
|
|
10
|
+
|
|
11
|
+
- Starting a work session
|
|
12
|
+
- Quick project health check
|
|
13
|
+
- Before/after changes
|
|
14
|
+
- Daily standup preparation
|
|
15
|
+
|
|
16
|
+
## Workflow Steps
|
|
17
|
+
|
|
18
|
+
### Step 1: Analyze Codebase
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Gather information:
|
|
22
|
+
- Project structure
|
|
23
|
+
- Technology stack
|
|
24
|
+
- File counts
|
|
25
|
+
- Code statistics
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Step 2: Check Quality
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Run quality checks:
|
|
32
|
+
- Linting status
|
|
33
|
+
- Type check status
|
|
34
|
+
- Test status
|
|
35
|
+
- Build status
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Step 3: Check Dependencies
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Review dependencies:
|
|
42
|
+
- Outdated packages
|
|
43
|
+
- Security vulnerabilities
|
|
44
|
+
- Unused dependencies
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Step 4: Generate Report
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Create status summary:
|
|
51
|
+
- Project health score
|
|
52
|
+
- Key metrics
|
|
53
|
+
- Recommendations
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Example Output
|
|
57
|
+
|
|
58
|
+
```markdown
|
|
59
|
+
# Project Status
|
|
60
|
+
|
|
61
|
+
## Overview
|
|
62
|
+
- **Type**: Next.js Application
|
|
63
|
+
- **Framework**: React 18
|
|
64
|
+
- **Language**: TypeScript
|
|
65
|
+
|
|
66
|
+
## Statistics
|
|
67
|
+
- Files: 245
|
|
68
|
+
- Lines of code: ~15,000
|
|
69
|
+
- Components: 42
|
|
70
|
+
- Pages: 12
|
|
71
|
+
- API Routes: 8
|
|
72
|
+
|
|
73
|
+
## Quality Checks
|
|
74
|
+
| Check | Status |
|
|
75
|
+
|-------|--------|
|
|
76
|
+
| Lint | ✅ Pass |
|
|
77
|
+
| TypeScript | ✅ Pass |
|
|
78
|
+
| Tests | ✅ 156/156 |
|
|
79
|
+
| Build | ✅ Success |
|
|
80
|
+
|
|
81
|
+
## Dependencies
|
|
82
|
+
- **Total**: 48
|
|
83
|
+
- **Outdated**: 3
|
|
84
|
+
- **Vulnerabilities**: 0
|
|
85
|
+
|
|
86
|
+
## Test Coverage
|
|
87
|
+
- Statements: 82%
|
|
88
|
+
- Branches: 78%
|
|
89
|
+
- Functions: 85%
|
|
90
|
+
- Lines: 81%
|
|
91
|
+
|
|
92
|
+
## Recommendations
|
|
93
|
+
1. Update 3 outdated packages
|
|
94
|
+
2. Improve branch coverage to 80%+
|
|
95
|
+
3. Consider adding E2E tests
|
|
96
|
+
|
|
97
|
+
## Health Score: 85/100
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
**Know your project's health at a glance.**
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Run and generate tests for the codebase. Use when adding test coverage or running test suites.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# /test Workflow
|
|
6
|
+
|
|
7
|
+
Generate, run, and manage tests for your codebase.
|
|
8
|
+
|
|
9
|
+
## When to Use
|
|
10
|
+
|
|
11
|
+
- Running test suites
|
|
12
|
+
- Adding test coverage
|
|
13
|
+
- Fixing failing tests
|
|
14
|
+
- Setting up testing infrastructure
|
|
15
|
+
|
|
16
|
+
## Workflow Steps
|
|
17
|
+
|
|
18
|
+
### Step 1: Identify Test Scope
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
What to test:
|
|
22
|
+
- Specific files or functions?
|
|
23
|
+
- Full test suite?
|
|
24
|
+
- Integration tests?
|
|
25
|
+
- E2E tests?
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Step 2: Run Tests
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Unit tests
|
|
32
|
+
npm test
|
|
33
|
+
|
|
34
|
+
# With coverage
|
|
35
|
+
npm run test:coverage
|
|
36
|
+
|
|
37
|
+
# Watch mode
|
|
38
|
+
npm run test:watch
|
|
39
|
+
|
|
40
|
+
# E2E tests
|
|
41
|
+
npm run test:e2e
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Step 3: Analyze Results
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
Review results:
|
|
48
|
+
- Which tests passed?
|
|
49
|
+
- Which tests failed?
|
|
50
|
+
- What's the coverage?
|
|
51
|
+
- Are there flaky tests?
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Step 4: Fix or Add Tests
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
For failing tests:
|
|
58
|
+
1. Identify the cause
|
|
59
|
+
2. Fix the code or test
|
|
60
|
+
3. Verify fix
|
|
61
|
+
|
|
62
|
+
For missing coverage:
|
|
63
|
+
1. Identify uncovered code
|
|
64
|
+
2. Write appropriate tests
|
|
65
|
+
3. Verify coverage improvement
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Test Types
|
|
69
|
+
|
|
70
|
+
### Unit Tests
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
describe('calculateTotal', () => {
|
|
74
|
+
it('should sum item prices', () => {
|
|
75
|
+
const items = [{ price: 10 }, { price: 20 }];
|
|
76
|
+
expect(calculateTotal(items)).toBe(30);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should handle empty array', () => {
|
|
80
|
+
expect(calculateTotal([])).toBe(0);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Integration Tests
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
describe('POST /api/users', () => {
|
|
89
|
+
it('should create user', async () => {
|
|
90
|
+
const response = await request(app)
|
|
91
|
+
.post('/api/users')
|
|
92
|
+
.send({ name: 'Test', email: 'test@example.com' });
|
|
93
|
+
|
|
94
|
+
expect(response.status).toBe(201);
|
|
95
|
+
expect(response.body.name).toBe('Test');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Example
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
User: /test checkout flow
|
|
104
|
+
|
|
105
|
+
Agent: I'll help you test the checkout flow.
|
|
106
|
+
|
|
107
|
+
**Test Scope:**
|
|
108
|
+
- Unit tests for calculation functions
|
|
109
|
+
- Integration tests for API endpoints
|
|
110
|
+
- E2E test for full checkout flow
|
|
111
|
+
|
|
112
|
+
**Running Tests:**
|
|
113
|
+
|
|
114
|
+
[Unit Tests] calculateTotal
|
|
115
|
+
✅ should sum item prices
|
|
116
|
+
✅ should apply discounts
|
|
117
|
+
✅ should handle empty cart
|
|
118
|
+
|
|
119
|
+
[Unit Tests] validatePayment
|
|
120
|
+
✅ should validate card number
|
|
121
|
+
✅ should reject invalid cards
|
|
122
|
+
|
|
123
|
+
[Integration Tests] POST /api/checkout
|
|
124
|
+
✅ should process payment
|
|
125
|
+
❌ should send confirmation email
|
|
126
|
+
|
|
127
|
+
**Failed Test:**
|
|
128
|
+
- should send confirmation email
|
|
129
|
+
- Error: Email service not mocked
|
|
130
|
+
- Fix: Add mock for email service
|
|
131
|
+
|
|
132
|
+
**Coverage:**
|
|
133
|
+
- Statements: 82%
|
|
134
|
+
- Branches: 78%
|
|
135
|
+
- Functions: 85%
|
|
136
|
+
- Lines: 81%
|
|
137
|
+
|
|
138
|
+
**Next Steps:**
|
|
139
|
+
1. Fix failing email test
|
|
140
|
+
2. Add E2E test for full flow
|
|
141
|
+
3. Improve branch coverage
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
**Tests enable confident refactoring.**
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
# AGENTS.md - [Project Name]
|
|
2
|
+
|
|
3
|
+
> **Instructions for AI agents working on this project**
|
|
4
|
+
>
|
|
5
|
+
> This file defines _how_ to build. For _what_ to build, see feature requirements.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Project Stack
|
|
10
|
+
|
|
11
|
+
<!-- CUSTOMIZE THIS SECTION -->
|
|
12
|
+
|
|
13
|
+
- **Framework:** [e.g., React, Vue, Next.js, NestJS, Express]
|
|
14
|
+
- **Language:** [e.g., TypeScript, JavaScript, Python, Go]
|
|
15
|
+
- **State Management:** [e.g., Redux, Pinia, Zustand, None]
|
|
16
|
+
- **Routing:** [e.g., React Router, Vue Router, Next Router]
|
|
17
|
+
- **HTTP Client:** [e.g., Axios, Fetch, SWR]
|
|
18
|
+
- **Build Tool:** [e.g., Vite, Webpack, esbuild]
|
|
19
|
+
- **Testing:** [e.g., Jest, Vitest, Mocha]
|
|
20
|
+
- **Styling:** [e.g., Tailwind, CSS Modules, Styled Components]
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Core Documentation (CRITICAL)
|
|
25
|
+
|
|
26
|
+
Before making architectural or styling decisions, **review** these documents:
|
|
27
|
+
|
|
28
|
+
| Document | Purpose | Location |
|
|
29
|
+
|----------|---------|----------|
|
|
30
|
+
| API Standards | API response structure, error handling | `docs/api-standards.md` |
|
|
31
|
+
| UI Standards | Styling rules, component patterns | `docs/ui-standards.md` |
|
|
32
|
+
| Code Style | Linting, formatting rules | `.eslintrc.js`, `.prettierrc` |
|
|
33
|
+
| Architecture | System design, data flow | `docs/architecture.md` |
|
|
34
|
+
| Database | Schema, relationships | `docs/database.md` |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Code Conventions
|
|
39
|
+
|
|
40
|
+
### File Naming
|
|
41
|
+
|
|
42
|
+
<!-- CUSTOMIZE THESE PATTERNS -->
|
|
43
|
+
|
|
44
|
+
| Type | Pattern | Example |
|
|
45
|
+
|------|---------|---------|
|
|
46
|
+
| Components | `PascalCase.tsx` | `UserCard.tsx` |
|
|
47
|
+
| Pages | `PascalCasePage.tsx` | `LoginPage.tsx` |
|
|
48
|
+
| Stores | `camelCase.store.ts` | `auth.store.ts` |
|
|
49
|
+
| Hooks/Composables | `useCamelCase.ts` | `useAuth.ts` |
|
|
50
|
+
| Types | `camelCase.types.ts` | `user.types.ts` |
|
|
51
|
+
| Utils | `camelCase.utils.ts` | `date.utils.ts` |
|
|
52
|
+
| API | `camelCase.api.ts` | `auth.api.ts` |
|
|
53
|
+
| Tests | `*.test.ts` or `*.spec.ts` | `auth.test.ts` |
|
|
54
|
+
|
|
55
|
+
### Code Style
|
|
56
|
+
|
|
57
|
+
<!-- CUSTOMIZE THESE RULES -->
|
|
58
|
+
|
|
59
|
+
- **Indentation:** [2 spaces / 4 spaces / tabs]
|
|
60
|
+
- **Quotes:** [single / double]
|
|
61
|
+
- **Semicolons:** [required / none]
|
|
62
|
+
- **Line Width:** [80 / 100 / 120]
|
|
63
|
+
- **Trailing Commas:** [always / none / es5]
|
|
64
|
+
|
|
65
|
+
### TypeScript/JavaScript
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// ✅ GOOD: Explicit types
|
|
69
|
+
interface User {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
email: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getUser(id: string): Promise<User> {
|
|
76
|
+
return api.get(`/users/${id}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ❌ BAD: Any type
|
|
80
|
+
function getUser(id: any): any {
|
|
81
|
+
return api.get(`/users/${id}`);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Error Handling
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
// ✅ GOOD: Unknown error with proper casting
|
|
89
|
+
try {
|
|
90
|
+
await saveUser(user);
|
|
91
|
+
} catch (err: unknown) {
|
|
92
|
+
const e = err as { response?: { data?: { message?: string } } };
|
|
93
|
+
error.value = e.response?.data?.message ?? 'Operation failed';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ❌ BAD: Any error
|
|
97
|
+
try {
|
|
98
|
+
await saveUser(user);
|
|
99
|
+
} catch (err: any) {
|
|
100
|
+
error.value = err.message;
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Project-Specific Rules
|
|
107
|
+
|
|
108
|
+
<!-- ADD YOUR CUSTOM RULES HERE -->
|
|
109
|
+
|
|
110
|
+
### Rule 1: [Rule Name]
|
|
111
|
+
|
|
112
|
+
Description of the rule and why it exists.
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
// ✅ GOOD: Example
|
|
116
|
+
// ❌ BAD: Anti-example
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Rule 2: [Rule Name]
|
|
120
|
+
|
|
121
|
+
Description...
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Architecture Patterns
|
|
126
|
+
|
|
127
|
+
### State Management
|
|
128
|
+
|
|
129
|
+
<!-- CUSTOMIZE FOR YOUR STATE SOLUTION -->
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// ✅ Store pattern example
|
|
133
|
+
export const useAuthStore = defineStore('auth', () => {
|
|
134
|
+
// State
|
|
135
|
+
const user = ref<User | null>(null);
|
|
136
|
+
const loading = ref(false);
|
|
137
|
+
const error = ref<string | null>(null);
|
|
138
|
+
|
|
139
|
+
// Getters
|
|
140
|
+
const isAuthenticated = computed(() => !!user.value);
|
|
141
|
+
|
|
142
|
+
// Actions
|
|
143
|
+
async function login(credentials: LoginDto): Promise<void> {
|
|
144
|
+
loading.value = true;
|
|
145
|
+
error.value = null;
|
|
146
|
+
try {
|
|
147
|
+
user.value = await authApi.login(credentials);
|
|
148
|
+
} catch (err: unknown) {
|
|
149
|
+
const e = err as { response?: { data?: { message?: string } } };
|
|
150
|
+
error.value = e.response?.data?.message ?? 'Login failed';
|
|
151
|
+
throw err;
|
|
152
|
+
} finally {
|
|
153
|
+
loading.value = false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return { user, loading, error, isAuthenticated, login };
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### API Layer
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
// ✅ API calls separated from components
|
|
165
|
+
// src/api/user.api.ts
|
|
166
|
+
import api from './axios';
|
|
167
|
+
|
|
168
|
+
export const userApi = {
|
|
169
|
+
getAll: () => api.get<User[]>('/users'),
|
|
170
|
+
getById: (id: string) => api.get<User>(`/users/${id}`),
|
|
171
|
+
create: (data: CreateUserDto) => api.post<User>('/users', data),
|
|
172
|
+
update: (id: string, data: UpdateUserDto) => api.put<User>(`/users/${id}`, data),
|
|
173
|
+
delete: (id: string) => api.delete(`/users/${id}`),
|
|
174
|
+
};
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Component Structure
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
// ✅ Component with clear structure
|
|
181
|
+
<script setup lang="ts">
|
|
182
|
+
import { ref, computed } from 'vue';
|
|
183
|
+
import type { User } from '@/types';
|
|
184
|
+
|
|
185
|
+
// Props
|
|
186
|
+
interface Props {
|
|
187
|
+
user: User;
|
|
188
|
+
readonly?: boolean;
|
|
189
|
+
}
|
|
190
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
191
|
+
readonly: false,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Emits
|
|
195
|
+
interface Emits {
|
|
196
|
+
(e: 'update', user: User): void;
|
|
197
|
+
(e: 'delete', id: string): void;
|
|
198
|
+
}
|
|
199
|
+
const emit = defineEmits<Emits>();
|
|
200
|
+
|
|
201
|
+
// State
|
|
202
|
+
const isEditing = ref(false);
|
|
203
|
+
|
|
204
|
+
// Computed
|
|
205
|
+
const displayName = computed(() =>
|
|
206
|
+
props.user.name || 'Anonymous'
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
// Methods
|
|
210
|
+
function handleUpdate() {
|
|
211
|
+
emit('update', props.user);
|
|
212
|
+
isEditing.value = false;
|
|
213
|
+
}
|
|
214
|
+
</script>
|
|
215
|
+
|
|
216
|
+
<template>
|
|
217
|
+
<div class="user-card">
|
|
218
|
+
<!-- Template here -->
|
|
219
|
+
</div>
|
|
220
|
+
</template>
|
|
221
|
+
|
|
222
|
+
<style scoped>
|
|
223
|
+
/* Styles here */
|
|
224
|
+
</style>
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Testing Standards
|
|
230
|
+
|
|
231
|
+
### Unit Tests
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
// ✅ Test structure
|
|
235
|
+
describe('useAuthStore', () => {
|
|
236
|
+
beforeEach(() => {
|
|
237
|
+
// Setup
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
afterEach(() => {
|
|
241
|
+
// Cleanup
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('should login successfully', async () => {
|
|
245
|
+
// Arrange
|
|
246
|
+
const credentials = { email: 'test@example.com', password: 'password' };
|
|
247
|
+
|
|
248
|
+
// Act
|
|
249
|
+
await authStore.login(credentials);
|
|
250
|
+
|
|
251
|
+
// Assert
|
|
252
|
+
expect(authStore.isAuthenticated).toBe(true);
|
|
253
|
+
expect(authStore.user).toBeDefined();
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('should handle login error', async () => {
|
|
257
|
+
// Test error case
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Test Coverage
|
|
263
|
+
|
|
264
|
+
- **Minimum:** 70% coverage
|
|
265
|
+
- **Target:** 80% coverage
|
|
266
|
+
- **Critical paths:** 100% coverage (auth, payments, etc.)
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Git Workflow
|
|
271
|
+
|
|
272
|
+
### Commit Messages
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
<type>(<scope>): <subject>
|
|
276
|
+
|
|
277
|
+
<body>
|
|
278
|
+
|
|
279
|
+
<footer>
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Types:**
|
|
283
|
+
- `feat`: New feature
|
|
284
|
+
- `fix`: Bug fix
|
|
285
|
+
- `refactor`: Code refactor
|
|
286
|
+
- `docs`: Documentation
|
|
287
|
+
- `test`: Tests
|
|
288
|
+
- `chore`: Maintenance
|
|
289
|
+
|
|
290
|
+
**Example:**
|
|
291
|
+
```
|
|
292
|
+
feat(auth): add JWT refresh token support
|
|
293
|
+
|
|
294
|
+
- Implement refresh token rotation
|
|
295
|
+
- Add automatic token refresh on 401
|
|
296
|
+
- Store tokens in httpOnly cookies
|
|
297
|
+
|
|
298
|
+
Closes #123
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Branch Naming
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
<type>/<ticket>-<short-description>
|
|
305
|
+
|
|
306
|
+
Examples:
|
|
307
|
+
- feature/AUTH-123-jwt-refresh
|
|
308
|
+
- fix/PAY-456-payment-timeout
|
|
309
|
+
- refactor/CORE-789-state-management
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Performance Guidelines
|
|
315
|
+
|
|
316
|
+
### Do's
|
|
317
|
+
|
|
318
|
+
- Lazy load components and routes
|
|
319
|
+
- Memoize expensive computations
|
|
320
|
+
- Paginate large lists
|
|
321
|
+
- Use virtual scrolling for long lists
|
|
322
|
+
- Optimize images and assets
|
|
323
|
+
- Cache API responses when appropriate
|
|
324
|
+
|
|
325
|
+
### Don'ts
|
|
326
|
+
|
|
327
|
+
- Render all items in large lists
|
|
328
|
+
- Call expensive functions in render
|
|
329
|
+
- Watch large objects unnecessarily
|
|
330
|
+
- Block the main thread
|
|
331
|
+
- Make unnecessary API calls
|
|
332
|
+
- Ignore bundle size warnings
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Security Guidelines
|
|
337
|
+
|
|
338
|
+
### Authentication & Authorization
|
|
339
|
+
|
|
340
|
+
- Never store sensitive data in localStorage
|
|
341
|
+
- Use httpOnly cookies for tokens
|
|
342
|
+
- Implement CSRF protection
|
|
343
|
+
- Validate all user input
|
|
344
|
+
- Sanitize data before rendering
|
|
345
|
+
- Use parameterized queries
|
|
346
|
+
|
|
347
|
+
### Data Validation
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
// ✅ Validate at boundaries
|
|
351
|
+
import { z } from 'zod';
|
|
352
|
+
|
|
353
|
+
const UserSchema = z.object({
|
|
354
|
+
email: z.string().email(),
|
|
355
|
+
name: z.string().min(2).max(100),
|
|
356
|
+
age: z.number().min(0).max(150).optional(),
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
function createUser(data: unknown): User {
|
|
360
|
+
return UserSchema.parse(data); // Throws on invalid
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## Accessibility (a11y)
|
|
367
|
+
|
|
368
|
+
- Use semantic HTML
|
|
369
|
+
- Provide alt text for images
|
|
370
|
+
- Ensure keyboard navigation
|
|
371
|
+
- Maintain color contrast ratios
|
|
372
|
+
- Use ARIA labels when needed
|
|
373
|
+
- Test with screen readers
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## Key Reminders
|
|
378
|
+
|
|
379
|
+
<!-- ADD PROJECT-SPECIFIC REMINDERS -->
|
|
380
|
+
|
|
381
|
+
1. **[Reminder 1]** - Description
|
|
382
|
+
2. **[Reminder 2]** - Description
|
|
383
|
+
3. **[Reminder 3]** - Description
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Quick Reference
|
|
388
|
+
|
|
389
|
+
### Commands
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
# Development
|
|
393
|
+
npm run dev # Start dev server
|
|
394
|
+
npm run build # Production build
|
|
395
|
+
npm run test # Run tests
|
|
396
|
+
npm run lint # Lint check
|
|
397
|
+
npm run format # Format code
|
|
398
|
+
npm run type-check # TypeScript check
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### Important Files
|
|
402
|
+
|
|
403
|
+
```
|
|
404
|
+
src/
|
|
405
|
+
├── components/ # Reusable components
|
|
406
|
+
├── pages/ # Page components
|
|
407
|
+
├── stores/ # State management
|
|
408
|
+
├── api/ # API calls
|
|
409
|
+
├── types/ # TypeScript types
|
|
410
|
+
├── utils/ # Utility functions
|
|
411
|
+
└── hooks/ # Custom hooks/composables
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Questions?
|
|
417
|
+
|
|
418
|
+
When in doubt:
|
|
419
|
+
1. Check existing code for patterns
|
|
420
|
+
2. Read the relevant docs
|
|
421
|
+
3. Ask the team lead
|
|
422
|
+
4. Follow the principle of least surprise
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
**Keep this file updated as the project evolves.**
|