ai-dev-starter 0.0.0-stage → 1.0.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.
Files changed (42) hide show
  1. package/LICENSE +35 -0
  2. package/README.md +383 -2
  3. package/adapters/antigravity/AGENTS.md +59 -0
  4. package/adapters/antigravity/skills/architecture-review/SKILL.md +33 -0
  5. package/adapters/antigravity/skills/bug-fix/SKILL.md +36 -0
  6. package/adapters/antigravity/skills/code-review/SKILL.md +34 -0
  7. package/adapters/antigravity/skills/feature-development/SKILL.md +37 -0
  8. package/adapters/antigravity/skills/performance-audit/SKILL.md +34 -0
  9. package/adapters/antigravity/skills/refactor/SKILL.md +35 -0
  10. package/adapters/antigravity/skills/security-audit/SKILL.md +35 -0
  11. package/adapters/antigravity/skills/test-generation/SKILL.md +34 -0
  12. package/adapters/cursor/bug-fix.mdc +38 -0
  13. package/adapters/cursor/code-review.mdc +56 -0
  14. package/adapters/cursor/core-rules.mdc +49 -0
  15. package/adapters/cursor/feature-development.mdc +31 -0
  16. package/adapters/cursor/performance-arch-tests.mdc +57 -0
  17. package/adapters/cursor/refactor-and-security.mdc +50 -0
  18. package/bin/ai-dev-starter.js +2 -0
  19. package/core/agent-principles.md +96 -0
  20. package/core/git-analysis.md +150 -0
  21. package/core/review-methodology.md +154 -0
  22. package/core/safety-policy.md +70 -0
  23. package/core/severity-levels.md +104 -0
  24. package/package.json +40 -4
  25. package/scripts/ai-dev-starter.js +709 -0
  26. package/scripts/detector.js +405 -0
  27. package/standards/backend.md +84 -0
  28. package/standards/database.md +100 -0
  29. package/standards/frontend.md +81 -0
  30. package/standards/security.md +84 -0
  31. package/standards/testing.md +132 -0
  32. package/templates/architecture-decision.md +92 -0
  33. package/templates/project-context.md +144 -0
  34. package/templates/review-report.md +102 -0
  35. package/workflows/architecture-review.md +186 -0
  36. package/workflows/bug-fix.md +149 -0
  37. package/workflows/code-review.md +189 -0
  38. package/workflows/feature-development.md +154 -0
  39. package/workflows/performance-audit.md +169 -0
  40. package/workflows/refactor.md +128 -0
  41. package/workflows/security-audit.md +164 -0
  42. package/workflows/test-generation.md +168 -0
@@ -0,0 +1,186 @@
1
+ # Workflow: Architecture Review
2
+
3
+ > **Purpose:** Evaluate the structural health, design quality, and scalability of the codebase.
4
+ > **Authorization:** Read-only. No file writes.
5
+ > **Scope:** Structural patterns, not code-level defects (use Code Review for those).
6
+
7
+ ---
8
+
9
+ ## Trigger
10
+
11
+ - "architecture review", "design review", "evaluate structure"
12
+ - "بررسی معماری", "ارزیابی ساختار"
13
+
14
+ ---
15
+
16
+ ## Required Context
17
+
18
+ 1. `core/agent-principles.md`
19
+ 2. `.agents/project-context.md`
20
+
21
+ ---
22
+
23
+ ## Execution Steps
24
+
25
+ ### Step 1 — Map the Structure
26
+
27
+ ```bash
28
+ # High-level directory tree
29
+ find . -maxdepth 3 -not -path "*/.git/*" -not -path "*/node_modules/*" \
30
+ -not -path "*/vendor/*" -not -path "*/__pycache__/*" | sort | head -100
31
+
32
+ # Count files by type
33
+ find . -name "*.php" -not -path "*/vendor/*" | wc -l
34
+ find . -name "*.ts" -not -path "*/node_modules/*" | wc -l
35
+
36
+ # Largest files (complexity indicator)
37
+ find . -name "*.php" -not -path "*/vendor/*" | xargs wc -l 2>/dev/null | sort -rn | head -20
38
+
39
+ # Dependency manifest
40
+ cat composer.json 2>/dev/null || cat package.json 2>/dev/null
41
+ ```
42
+
43
+ ### Step 2 — Identify the Architectural Pattern
44
+
45
+ Determine which pattern(s) the project uses:
46
+ - **MVC** (Laravel, Ruby on Rails, Django).
47
+ - **Clean Architecture / Hexagonal** (domain, application, infrastructure layers).
48
+ - **Domain-Driven Design** (bounded contexts, aggregates).
49
+ - **Microservices** (multiple services with their own data stores).
50
+ - **Monolith with modules**.
51
+ - **Component-based** (React, Vue, Angular with feature directories).
52
+
53
+ Identify by reading:
54
+ - Directory structure.
55
+ - Base classes and interfaces.
56
+ - Naming conventions.
57
+ - Dependency injection setup.
58
+
59
+ ### Step 3 — Evaluate Layer Boundaries
60
+
61
+ For each identified layer boundary, check:
62
+
63
+ #### Controllers / Route Handlers
64
+ - Do they contain business logic? (Anti-pattern: fat controllers)
65
+ - Do they directly query the database? (Anti-pattern: bypassing service layer)
66
+ - Do they handle authorization? (Expected: middleware or policy)
67
+
68
+ ```bash
69
+ # Check controller file sizes
70
+ wc -l app/Http/Controllers/*.php | sort -rn | head -10
71
+
72
+ # Look for direct DB calls in controllers
73
+ grep -rn "DB::\|->where\|->find\|->create" --include="*.php" app/Http/Controllers/ | head -10
74
+ ```
75
+
76
+ #### Service / Use Case Layer
77
+ - Is business logic centralized here?
78
+ - Are services reusable across controllers and jobs?
79
+
80
+ #### Data Layer
81
+ - Are repositories or Eloquent models the data access mechanism?
82
+ - Is there a consistent pattern?
83
+
84
+ #### Frontend (if applicable)
85
+ - Are components responsible for data fetching? (Acceptable in React, problematic if mixed with business logic)
86
+ - Is state management centralized appropriately?
87
+
88
+ ### Step 4 — Evaluate Coupling and Cohesion
89
+
90
+ **Tight Coupling Signals:**
91
+ ```bash
92
+ # Classes importing many other classes
93
+ grep -rn "^use " --include="*.php" app/Http/Controllers/ | awk '{print NF}' | sort -rn | head -10
94
+
95
+ # Circular dependencies
96
+ # (Manual inspection: Class A imports B, B imports A)
97
+ grep -rn "^use App\\" --include="*.php" app/Services/ | head -20
98
+ ```
99
+
100
+ **Low Cohesion Signals:**
101
+ - Classes with many unrelated public methods.
102
+ - Files > 500 lines.
103
+ - Controllers with methods for unrelated entities.
104
+
105
+ ### Step 5 — Evaluate Dependencies
106
+
107
+ ```bash
108
+ # Third-party dependencies
109
+ cat composer.json | grep -A100 '"require"' | grep -v "php\|ext-"
110
+ # or
111
+ cat package.json | grep -A100 '"dependencies"'
112
+ ```
113
+
114
+ Assess:
115
+ - Are dependencies actively maintained?
116
+ - Are there multiple packages solving the same problem?
117
+ - Are there unnecessary dependencies for simple tasks?
118
+
119
+ ### Step 6 — Evaluate Scalability
120
+
121
+ Consider:
122
+ - **Database:** Are there single points of contention (table locks, unindexed joins)?
123
+ - **State:** Is application state stored in-process (limits horizontal scaling)?
124
+ - **Queues:** Are heavy operations async?
125
+ - **Caching:** Is expensive computation cached?
126
+
127
+ ### Step 7 — Generate Report
128
+
129
+ ```markdown
130
+ ## Architecture Review Report
131
+
132
+ **Project:** <name>
133
+ **Pattern:** <identified pattern>
134
+ **Date:** YYYY-MM-DD
135
+
136
+ ---
137
+
138
+ ### Executive Summary
139
+ <3–5 sentences: overall health, main strengths, main concerns>
140
+
141
+ ---
142
+
143
+ ### Strengths
144
+ - <What the architecture does well>
145
+
146
+ ---
147
+
148
+ ### Concerns
149
+
150
+ #### [P1] Fat Controllers — Business Logic Leaking from Service Layer
151
+ **Evidence:** `OrderController.php` (342 lines) contains pricing calculations, inventory checks, and email sending.
152
+ **Impact:** Logic cannot be reused, cannot be unit tested in isolation, and grows indefinitely.
153
+ **Recommendation:** Extract to `OrderService` with clearly named methods.
154
+
155
+ ---
156
+
157
+ ### Recommendations
158
+ 1. <Highest priority structural improvement>
159
+ 2. ...
160
+
161
+ ---
162
+
163
+ ### Dependency Health
164
+ | Package | Status | Concern |
165
+ |---------|--------|---------|
166
+ | `laravel/framework` | Current | None |
167
+ | `abandoned/package` | Abandoned | Replace with X |
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Completion Criteria
173
+
174
+ - Project structure mapped and pattern identified.
175
+ - Layer boundaries evaluated.
176
+ - Coupling and cohesion assessed.
177
+ - Dependencies reviewed.
178
+ - Findings are structural, not code-level.
179
+
180
+ ---
181
+
182
+ ## Limitations
183
+
184
+ - Cannot evaluate runtime behavior or actual performance.
185
+ - Cannot evaluate team conventions or processes.
186
+ - Cannot assess security of infrastructure or deployment.
@@ -0,0 +1,149 @@
1
+ # Workflow: Bug Fix
2
+
3
+ > **Purpose:** Investigate a reported bug, identify root cause, and implement a minimal fix.
4
+ > **Authorization:** Read files freely. Write only to fix-related files. Run tests with user awareness.
5
+ > **Auto-commit:** Never.
6
+
7
+ ---
8
+
9
+ ## Trigger
10
+
11
+ User reports a bug with any of:
12
+ - Error message, stack trace, or log output.
13
+ - Description of unexpected behavior.
14
+ - Test failure name.
15
+ - "باگ", "خطا", "bug fix", "fix this error"
16
+
17
+ ---
18
+
19
+ ## Required Context
20
+
21
+ 1. `core/agent-principles.md`
22
+ 2. `core/safety-policy.md`
23
+ 3. `.agents/project-context.md`
24
+
25
+ ---
26
+
27
+ ## Execution Steps
28
+
29
+ ### Step 1 — Understand the Bug Report
30
+
31
+ Ask for clarification only if the minimum required information is absent:
32
+ - **What is the unexpected behavior?** (or error message / stack trace)
33
+ - **What was the expected behavior?**
34
+ - **How to reproduce?** (steps, URL, command, test name)
35
+
36
+ If the user has provided a stack trace or error message, proceed without asking.
37
+
38
+ ### Step 2 — Establish Evidence
39
+
40
+ ```bash
41
+ # Check git status to understand current state
42
+ git status
43
+ git log --oneline -10
44
+
45
+ # Search for the error message in source
46
+ grep -rn "ErrorMessage\|ExceptionClass" --include="*.php" --include="*.ts" src/
47
+
48
+ # Find the failing test if applicable
49
+ grep -rn "test_name\|it('description'" tests/ --include="*.php" --include="*.ts"
50
+ ```
51
+
52
+ Do not claim to have reproduced the bug unless you have executed the reproduction steps and observed the failure.
53
+
54
+ ### Step 3 — Identify Root Cause
55
+
56
+ Trace the execution path:
57
+ 1. Entry point (route, CLI command, event handler).
58
+ 2. Each function call in the stack.
59
+ 3. The specific line that produces the incorrect behavior.
60
+ 4. The underlying condition that triggers it.
61
+
62
+ Document the root cause hypothesis before proposing a fix.
63
+
64
+ ### Step 4 — Identify Affected Code
65
+
66
+ ```bash
67
+ # Find all usages of the affected function/class
68
+ grep -rn "functionName\|ClassName" --include="*.php" src/ | grep -v "\.git"
69
+
70
+ # Find related tests
71
+ find tests/ -name "*Test*" | xargs grep -l "ClassName" 2>/dev/null
72
+ ```
73
+
74
+ Determine:
75
+ - Minimum scope of the fix (single line, function, class).
76
+ - Whether the fix could affect other callers.
77
+ - Whether existing tests cover the fix path.
78
+
79
+ ### Step 5 — Propose Fix
80
+
81
+ Present the fix plan to the user before implementing:
82
+
83
+ ```markdown
84
+ ## Proposed Fix
85
+
86
+ **Root Cause:** <one sentence>
87
+
88
+ **Fix Scope:** `path/to/file.php` line 42–55
89
+
90
+ **Change:**
91
+ ```php
92
+ // Before
93
+ $result = $value / $count;
94
+
95
+ // After (handles zero count)
96
+ $result = $count > 0 ? $value / $count : 0;
97
+ ```
98
+
99
+ **Side Effects:** None — this function is only called from X and Y.
100
+
101
+ **Tests to run:** `php artisan test --filter=TestClassName`
102
+
103
+ Shall I implement this fix?
104
+ ```
105
+
106
+ **Wait for user approval before modifying any files.**
107
+
108
+ ### Step 6 — Implement
109
+
110
+ After approval:
111
+ 1. Apply the minimal change.
112
+ 2. Do not reformat unrelated code.
113
+ 3. Do not rename unrelated variables.
114
+ 4. Do not add unrelated improvements.
115
+
116
+ ### Step 7 — Run Tests
117
+
118
+ ```bash
119
+ # Run the relevant tests (not the full suite unless needed)
120
+ php artisan test --filter=TestName
121
+ # or
122
+ npm test -- --testPathPattern=ComponentName
123
+ # or
124
+ pytest tests/test_module.py::test_function
125
+ ```
126
+
127
+ Report the actual test output. Do not claim tests passed without evidence.
128
+
129
+ ### Step 8 — Explain the Change
130
+
131
+ Provide:
132
+ 1. Summary of what changed and why.
133
+ 2. Test results (actual output).
134
+ 3. Any follow-up concerns (related code that may have the same bug).
135
+
136
+ ---
137
+
138
+ ## Completion Criteria
139
+
140
+ - Root cause identified and documented.
141
+ - Minimal fix implemented (no scope creep).
142
+ - Relevant tests run and results reported.
143
+ - User explicitly approved the fix before implementation.
144
+
145
+ ---
146
+
147
+ ## Boundaries
148
+
149
+ Do not fix unrelated issues encountered during investigation. Note them separately as observations.
@@ -0,0 +1,189 @@
1
+ # Workflow: Code Review
2
+
3
+ > **Purpose:** Analyze Git changes and produce a structured, evidence-based review report.
4
+ > **Authorization:** Read-only. No file writes. No commits.
5
+ > **Report Language:** See project-context.md → `report_language` (default: Persian).
6
+
7
+ ---
8
+
9
+ ## Trigger
10
+
11
+ User says any of:
12
+ - "review my code", "review my changes", "code review"
13
+ - "بررسی کد", "ریویو کن"
14
+ - Provides a branch name or PR URL to review.
15
+
16
+ ---
17
+
18
+ ## Required Context
19
+
20
+ Before starting, load:
21
+ 1. `core/agent-principles.md`
22
+ 2. `core/git-analysis.md`
23
+ 3. `core/review-methodology.md`
24
+ 4. `core/severity-levels.md`
25
+ 5. `.agents/project-context.md` (if present)
26
+
27
+ ---
28
+
29
+ ## Execution Steps
30
+
31
+ ### Step 1 — Orient
32
+ ```bash
33
+ # Confirm we are in a git repository
34
+ git rev-parse --show-toplevel
35
+
36
+ # Get current branch
37
+ git branch --show-current
38
+
39
+ # Determine comparison base
40
+ git remote show origin | grep "HEAD branch"
41
+ # Or: git symbolic-ref refs/remotes/origin/HEAD --short
42
+ ```
43
+
44
+ If the user specified a branch or base, use that. Otherwise use the auto-detected base.
45
+
46
+ ### Step 2 — Enumerate Changes
47
+ ```bash
48
+ # Committed changes
49
+ git diff --name-status origin/main...HEAD
50
+ git log origin/main..HEAD --oneline
51
+
52
+ # Staged changes
53
+ git diff --cached --name-status
54
+
55
+ # Unstaged changes
56
+ git diff --name-status
57
+ ```
58
+
59
+ Build the change summary: branch, base, file list, commit count.
60
+
61
+ ### Step 3 — Read Diffs
62
+ ```bash
63
+ git diff origin/main...HEAD
64
+ ```
65
+
66
+ Read the full diff. For large diffs (>500 lines), process file by file.
67
+
68
+ ### Step 4 — Read Affected Files
69
+
70
+ For each modified file:
71
+ 1. Read the file to understand the full context of changed lines.
72
+ 2. Identify what functions, classes, or modules are affected.
73
+ 3. Note imports and dependencies relevant to the changes.
74
+
75
+ Do not read files that have no changes unless they are critical dependencies.
76
+
77
+ ### Step 5 — Gather Supporting Context
78
+
79
+ For each finding candidate:
80
+ - Read related files (e.g., models, validators, tests, routes).
81
+ - Read migration files if schema changes are present.
82
+ - Read test files covering the changed code.
83
+
84
+ ```bash
85
+ # Find tests for a changed file
86
+ find . -name "*.test.*" -o -name "*.spec.*" -o -name "*Test.php" | \
87
+ xargs grep -l "ClassName\|functionName" 2>/dev/null | head -10
88
+
89
+ # Find routes
90
+ grep -rn "Route::" routes/ 2>/dev/null | grep "endpoint"
91
+ ```
92
+
93
+ ### Step 6 — Analyze
94
+
95
+ Apply review dimensions from `core/review-methodology.md` in this order:
96
+ 1. Correctness and Business Logic
97
+ 2. Security
98
+ 3. Data Integrity
99
+ 4. Performance
100
+ 5. Architecture
101
+ 6. Test Coverage
102
+ 7. Code Quality
103
+
104
+ For each candidate finding, complete the verification checklist before recording it.
105
+
106
+ ### Step 7 — Verify Findings
107
+
108
+ For every finding:
109
+ - [ ] The issue exists in newly added lines (not pre-existing).
110
+ - [ ] I can point to the exact file, line, and code.
111
+ - [ ] I can describe the realistic impact scenario.
112
+ - [ ] I checked for mitigating factors (middleware, validators, tests).
113
+ - [ ] I can suggest a concrete fix.
114
+
115
+ Discard findings that fail this checklist.
116
+
117
+ ### Step 8 — Generate Report
118
+
119
+ Produce the report in the project's configured `report_language`.
120
+
121
+ Use the report template from `templates/review-report.md`.
122
+
123
+ ---
124
+
125
+ ## Report Template
126
+
127
+ ```markdown
128
+ ## گزارش بررسی کد / Code Review Report
129
+
130
+ **شاخه (Branch):** `feature/xyz` → `main`
131
+ **تعداد فایل‌های تغییریافته:** N
132
+ **تعداد کامیت‌ها:** M
133
+ **تاریخ:** YYYY-MM-DD
134
+
135
+ ---
136
+
137
+ ### خلاصه تغییرات (Walkthrough)
138
+ <2–4 جمله توضیح می‌دهند که این تغییر چه می‌کند>
139
+
140
+ ---
141
+
142
+ ### یافته‌ها (Findings)
143
+
144
+ #### [P0 — بحرانی] <عنوان>
145
+ **فایل:** `path/to/file.php` خط ۴۲
146
+
147
+ **مشکل:** <توضیح مشکل>
148
+
149
+ **شواهد:**
150
+ ```php
151
+ // کد مشکل‌دار
152
+ ```
153
+
154
+ **تأثیر:** <توضیح واقع‌گرایانه>
155
+
156
+ **پیشنهاد رفع:** <راه‌حل مشخص>
157
+
158
+ **روش تأیید:** <چگونه مطمئن شویم که مشکل رفع شد>
159
+
160
+ ---
161
+
162
+ ### مشاهدات (Observations)
163
+ <مشکلات موجود قبلاً که خارج از محدوده تغییر هستند>
164
+
165
+ ---
166
+
167
+ ### نکات مثبت (Positive Notes)
168
+ <چه چیزهایی خوب انجام شده>
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Completion Criteria
174
+
175
+ - All changed files have been reviewed.
176
+ - Findings are ordered P0 → P3.
177
+ - Each finding has file, line, evidence, impact, and fix.
178
+ - No speculative findings without code-level evidence.
179
+ - Report language matches project configuration.
180
+
181
+ ---
182
+
183
+ ## Limitations
184
+
185
+ This workflow cannot:
186
+ - Access external CI/CD results.
187
+ - Run tests automatically.
188
+ - Review changes in external repositories without clone access.
189
+ - Detect runtime behaviors not visible in code.
@@ -0,0 +1,154 @@
1
+ # Workflow: Feature Development
2
+
3
+ > **Purpose:** Implement a new feature following the project's existing architecture and conventions.
4
+ > **Authorization:** Read freely. Write incrementally within authorized scope.
5
+ > **Auto-commit:** Never.
6
+
7
+ ---
8
+
9
+ ## Trigger
10
+
11
+ User requests a new feature:
12
+ - "add feature X", "implement Y", "build Z"
13
+ - "اضافه کن", "پیاده‌سازی کن", "بساز"
14
+
15
+ ---
16
+
17
+ ## Required Context
18
+
19
+ 1. `core/agent-principles.md`
20
+ 2. `core/safety-policy.md`
21
+ 3. `.agents/project-context.md`
22
+ 4. Relevant standards from `standards/` based on project tech stack.
23
+
24
+ ---
25
+
26
+ ## Execution Steps
27
+
28
+ ### Step 1 — Understand Requirements
29
+
30
+ Before writing a single line of code, confirm:
31
+ - **What** the feature does (user-facing behavior).
32
+ - **Who** uses it (user role, API consumer, background job).
33
+ - **Where** it integrates with existing functionality.
34
+ - **What it must not do** (constraints, out-of-scope items).
35
+
36
+ If the requirements are ambiguous, ask targeted questions. Maximum 3 questions at a time.
37
+
38
+ ### Step 2 — Inspect Existing Architecture
39
+
40
+ ```bash
41
+ # Understand project structure
42
+ ls -la
43
+ cat composer.json # or package.json
44
+
45
+ # Find similar existing features
46
+ grep -rn "similarPattern\|relatedFeature" src/ --include="*.php" -l | head -10
47
+
48
+ # Understand routing conventions
49
+ cat routes/web.php # Laravel
50
+ cat routes/api.php
51
+ # or
52
+ find . -name "*.routes.*" -not -path "*/node_modules/*" | head -5
53
+
54
+ # Understand data models
55
+ ls app/Models/ 2>/dev/null || ls src/entities/ 2>/dev/null || echo "Check project structure"
56
+
57
+ # Check test conventions
58
+ ls tests/ 2>/dev/null; ls __tests__/ 2>/dev/null; ls spec/ 2>/dev/null
59
+ ```
60
+
61
+ Identify:
62
+ - The project's layering pattern (MVC, Clean Architecture, etc.).
63
+ - Naming conventions from existing code.
64
+ - Reusable components (services, repositories, hooks, utilities).
65
+ - The testing framework and test file location conventions.
66
+
67
+ ### Step 3 — Present Implementation Plan
68
+
69
+ Before writing code, present a plan:
70
+
71
+ ```markdown
72
+ ## Implementation Plan: <Feature Name>
73
+
74
+ **Approach:** <One paragraph describing the technical approach>
75
+
76
+ **Files to create:**
77
+ - `app/Http/Controllers/FeatureController.php` — HTTP handler
78
+ - `app/Services/FeatureService.php` — Business logic
79
+ - `app/Models/Feature.php` — Data model (if new)
80
+ - `database/migrations/xxxx_create_features_table.php` — Schema
81
+ - `tests/Feature/FeatureTest.php` — Feature tests
82
+
83
+ **Files to modify:**
84
+ - `routes/api.php` — Add new endpoints
85
+ - `app/Providers/AppServiceProvider.php` — Register service (if needed)
86
+
87
+ **Dependencies introduced:** None
88
+
89
+ **Breaking changes:** None
90
+
91
+ **Estimated scope:** Medium
92
+
93
+ Shall I proceed with this plan?
94
+ ```
95
+
96
+ **Wait for user approval before writing any files.**
97
+
98
+ ### Step 4 — Implement Incrementally
99
+
100
+ Implement one logical unit at a time:
101
+ 1. Database schema / migration (if needed).
102
+ 2. Data model.
103
+ 3. Business logic layer (service, use case).
104
+ 4. HTTP / API layer (controller, route).
105
+ 5. Frontend (component, page, hook) if applicable.
106
+ 6. Tests.
107
+
108
+ After each unit, describe what was done and what comes next.
109
+
110
+ ### Step 5 — Follow Existing Conventions
111
+
112
+ - Match the naming patterns from similar existing code (do not invent new patterns).
113
+ - Match the import style.
114
+ - Match the error handling style.
115
+ - Match the validation approach.
116
+ - Do not introduce new linting rules or formatting changes.
117
+
118
+ ### Step 6 — Write Tests
119
+
120
+ Identify what must be tested:
121
+ - Happy path.
122
+ - Expected failure cases (validation errors, not-found, unauthorized).
123
+ - Edge cases specific to this feature.
124
+
125
+ Write tests compatible with the project's existing testing setup.
126
+
127
+ ### Step 7 — Self-Review
128
+
129
+ Before declaring completion, run the Code Review workflow mentally on your own changes:
130
+ - Security: Are inputs validated and sanitized?
131
+ - Authorization: Are endpoints protected?
132
+ - Data integrity: Are mutations wrapped in transactions?
133
+ - Performance: Any N+1 queries introduced?
134
+
135
+ ### Step 8 — Run Tests
136
+
137
+ ```bash
138
+ # Run only the new feature tests
139
+ php artisan test --filter=FeatureName
140
+ # or
141
+ npm test -- --testPathPattern=FeatureName
142
+ ```
143
+
144
+ Report actual test output.
145
+
146
+ ---
147
+
148
+ ## Completion Criteria
149
+
150
+ - Requirements confirmed before implementation.
151
+ - Plan approved by user before writing files.
152
+ - Implementation follows existing conventions.
153
+ - Tests written and passing.
154
+ - No unrelated code changed.