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,169 @@
1
+ # Workflow: Performance Audit
2
+
3
+ > **Purpose:** Identify measurable or evidence-supported performance bottlenecks.
4
+ > **Authorization:** Read-only. No file writes.
5
+ > **Principle:** Prioritize evidence-supported issues over theoretical ones.
6
+
7
+ ---
8
+
9
+ ## Trigger
10
+
11
+ - "performance audit", "slow queries", "optimize", "performance review"
12
+ - "بررسی کارایی", "بهینه‌سازی", "کوئری کند"
13
+
14
+ ---
15
+
16
+ ## Required Context
17
+
18
+ 1. `core/agent-principles.md`
19
+ 2. `core/severity-levels.md`
20
+ 3. `.agents/project-context.md`
21
+
22
+ ---
23
+
24
+ ## Execution Steps
25
+
26
+ ### Step 1 — Define Scope
27
+
28
+ Confirm:
29
+ - Specific area (database, frontend, API, background jobs) or full audit?
30
+ - Any known slow endpoints or operations?
31
+ - Current scale (approximate record counts, concurrent users).
32
+
33
+ ### Step 2 — Database Query Analysis
34
+
35
+ #### N+1 Query Detection
36
+ ```bash
37
+ # Laravel: look for loops that contain queries
38
+ grep -rn "foreach\|for (" --include="*.php" app/ | head -20
39
+ # Then manually inspect each loop body for ORM calls
40
+
41
+ # Check for missing eager loading
42
+ grep -rn "->get()\|->first()\|->find(" --include="*.php" app/ | head -20
43
+
44
+ # Look for ->with() usage (eager loading)
45
+ grep -rn "->with(\|->load(" --include="*.php" app/ | head -20
46
+ ```
47
+
48
+ #### Missing Indexes
49
+ ```bash
50
+ # Find migration files and check indexed columns
51
+ find database/migrations -name "*.php" | xargs grep -l "index\|foreign\|unique" | head -10
52
+ # Review recent migrations
53
+ ls -t database/migrations | head -5 | xargs -I{} cat database/migrations/{}
54
+ ```
55
+
56
+ #### Unbounded Queries
57
+ ```bash
58
+ # Queries without pagination or LIMIT
59
+ grep -rn "->get()\|->all()\|SELECT \*" --include="*.php" --include="*.ts" app/ src/ | \
60
+ grep -v "paginate\|limit\|take\|LIMIT" | head -20
61
+ ```
62
+
63
+ #### Expensive Aggregations
64
+ ```bash
65
+ grep -rn "->count()\|->sum()\|->avg()\|->max()\|->min()" --include="*.php" app/ | head -20
66
+ ```
67
+
68
+ ### Step 3 — API and HTTP Analysis
69
+
70
+ ```bash
71
+ # Synchronous external HTTP calls
72
+ grep -rn "Http::\|curl_exec\|file_get_contents.*http\|axios\.\|fetch(" --include="*.php" --include="*.ts" app/ src/ | head -20
73
+
74
+ # Large response payloads
75
+ grep -rn "toArray()\|->toJson()\|json_encode" --include="*.php" app/ | head -20
76
+
77
+ # Missing caching
78
+ grep -rn "Cache::\|Redis::\|remember\|cache(" --include="*.php" app/ | head -20
79
+ # If caching is absent in hot paths, flag for investigation
80
+ ```
81
+
82
+ ### Step 4 — Frontend / Rendering Analysis
83
+
84
+ ```bash
85
+ # Large bundle imports
86
+ grep -rn "import \* as\|require(" --include="*.ts" --include="*.tsx" --include="*.js" src/ | head -20
87
+
88
+ # Non-lazy-loaded routes
89
+ grep -rn "import {" --include="*.tsx" --include="*.ts" src/app/ | head -20
90
+
91
+ # Missing React.memo / useMemo / useCallback on expensive components
92
+ grep -rn "useEffect\|useState" --include="*.tsx" src/ | head -20
93
+ ```
94
+
95
+ ### Step 5 — Background Jobs
96
+
97
+ ```bash
98
+ # Large job payloads
99
+ grep -rn "dispatch\|Queue::" --include="*.php" app/ | head -20
100
+
101
+ # Synchronous operations in job handlers
102
+ grep -rn "Http::\|curl\|file_get_contents" --include="*.php" app/Jobs/ | head -20
103
+ ```
104
+
105
+ ### Step 6 — Analyze Findings
106
+
107
+ For each potential performance issue, assess:
108
+ - **Measurable?** Can the impact be quantified or is it theoretical?
109
+ - **Scale-dependent?** At what data volume or request rate does this become a problem?
110
+ - **Evidence?** Can you identify the specific query, loop, or call that is slow?
111
+
112
+ Do not report speculative performance concerns without evidence.
113
+
114
+ ### Step 7 — Generate Report
115
+
116
+ ```markdown
117
+ ## Performance Audit Report
118
+
119
+ **Scope:** [Module / Full Codebase]
120
+ **Date:** YYYY-MM-DD
121
+
122
+ ---
123
+
124
+ ### Critical Issues (P0–P1)
125
+
126
+ #### [P1] N+1 Query in OrderController::index
127
+
128
+ **File:** `app/Http/Controllers/OrderController.php` line 45
129
+
130
+ **Problem:**
131
+ Loop fetches related `Customer` model for each `Order` individually.
132
+
133
+ **Evidence:**
134
+ ```php
135
+ foreach ($orders as $order) {
136
+ $customerName = $order->customer->name; // DB query per iteration
137
+ }
138
+ ```
139
+
140
+ **Impact at scale:**
141
+ 100 orders → 101 queries. 10,000 orders → 10,001 queries. Response time degrades linearly.
142
+
143
+ **Fix:**
144
+ ```php
145
+ $orders = Order::with('customer')->paginate(50);
146
+ ```
147
+
148
+ **Verification:**
149
+ Enable query logging: `DB::enableQueryLog()`. Confirm single query after fix.
150
+
151
+ ---
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Completion Criteria
157
+
158
+ - Database query patterns inspected.
159
+ - N+1 risks identified with specific code locations.
160
+ - Missing indexes identified where queries exist on unindexed columns.
161
+ - Each finding has evidence and estimated impact at scale.
162
+
163
+ ---
164
+
165
+ ## Limitations
166
+
167
+ - Cannot profile actual query execution plans without database access.
168
+ - Cannot measure frontend bundle sizes without build output.
169
+ - Cannot identify application-layer bottlenecks without profiling tools (Telescope, Xdebug, New Relic).
@@ -0,0 +1,128 @@
1
+ # Workflow: Refactoring
2
+
3
+ > **Purpose:** Improve code structure and maintainability without changing observable behavior.
4
+ > **Authorization:** Read freely. Write incrementally within authorized scope.
5
+ > **Golden Rule:** If behavior changes, it is not refactoring — stop and discuss.
6
+
7
+ ---
8
+
9
+ ## Trigger
10
+
11
+ - "refactor", "clean up", "simplify", "improve readability"
12
+ - "ریفکتور", "بهبود کد", "ساده‌سازی"
13
+
14
+ ---
15
+
16
+ ## Required Context
17
+
18
+ 1. `core/agent-principles.md`
19
+ 2. `core/safety-policy.md`
20
+ 3. `.agents/project-context.md`
21
+
22
+ ---
23
+
24
+ ## Execution Steps
25
+
26
+ ### Step 1 — Understand Scope
27
+
28
+ Confirm:
29
+ - Which file(s) or module(s) are in scope.
30
+ - What quality problem the user wants to address.
31
+ - Whether there is existing test coverage (critical for safe refactoring).
32
+
33
+ ### Step 2 — Assess Test Coverage
34
+
35
+ ```bash
36
+ # Run existing tests to establish baseline
37
+ php artisan test --filter=ScopeClass
38
+ # or
39
+ npm test -- --testPathPattern=ScopedModule
40
+ ```
41
+
42
+ **If no tests exist:** Alert the user.
43
+ > "⚠️ No tests found covering this code. Refactoring without tests risks introducing regressions. Recommend writing tests first. Shall I generate tests before refactoring?"
44
+
45
+ Do not proceed with refactoring on untested code without user explicit acknowledgment of the risk.
46
+
47
+ ### Step 3 — Identify Improvements
48
+
49
+ Look for:
50
+
51
+ | Anti-Pattern | Description |
52
+ |---|---|
53
+ | Long method | Function > 30 lines doing multiple things |
54
+ | Deep nesting | More than 3 levels of if/loop nesting |
55
+ | Duplicated logic | Same logic copy-pasted in 2+ places |
56
+ | God class | Class doing too many unrelated things |
57
+ | Magic values | Hardcoded numbers or strings without explanation |
58
+ | Primitive obsession | Using raw strings/ints where a type/enum fits |
59
+ | Dead code | Unreachable, commented-out, or unused code |
60
+ | Leaky abstraction | Implementation details exposed across layer boundary |
61
+
62
+ ### Step 4 — Present Refactoring Plan
63
+
64
+ ```markdown
65
+ ## Refactoring Plan: <File or Module>
66
+
67
+ **Current problems:**
68
+ 1. `processOrder()` is 120 lines doing validation, calculation, and persistence.
69
+ 2. Magic number `0.15` appears 4 times without explanation.
70
+ 3. Nested condition depth reaches 5 levels.
71
+
72
+ **Proposed changes:**
73
+ 1. Extract `validateOrder()`, `calculateTotals()`, `persistOrder()`.
74
+ 2. Define `const TAX_RATE = 0.15` with a comment.
75
+ 3. Replace nested conditions with early returns.
76
+
77
+ **Behavior preserved:** Yes — externally visible interface unchanged.
78
+ **Tests needed:** Existing tests will cover all changes.
79
+
80
+ Shall I proceed?
81
+ ```
82
+
83
+ **Wait for approval before writing any files.**
84
+
85
+ ### Step 5 — Implement in Small Steps
86
+
87
+ Apply one change category at a time:
88
+ 1. Extract methods / functions.
89
+ 2. Eliminate duplication.
90
+ 3. Rename for clarity.
91
+ 4. Remove dead code.
92
+ 5. Restructure control flow.
93
+
94
+ Run tests after each step:
95
+ ```bash
96
+ php artisan test --filter=ScopeClass
97
+ ```
98
+
99
+ If any test fails: **stop**, report the failure, and revert the last step.
100
+
101
+ ### Step 6 — Verify Behavior Preservation
102
+
103
+ After all changes:
104
+ ```bash
105
+ # Run the full test suite for the affected module
106
+ php artisan test --filter=ScopeModule
107
+ ```
108
+
109
+ Report actual output. Do not declare success without evidence.
110
+
111
+ ---
112
+
113
+ ## Boundaries
114
+
115
+ - Do not add features during refactoring.
116
+ - Do not change public APIs or interfaces.
117
+ - Do not modify database migrations.
118
+ - Do not change test assertions.
119
+ - Do not reformat code outside the changed functions.
120
+
121
+ ---
122
+
123
+ ## Completion Criteria
124
+
125
+ - Original behavior preserved (tests still pass).
126
+ - Code is measurably simpler (fewer lines, less nesting, less duplication).
127
+ - No scope creep.
128
+ - Tests ran and results reported.
@@ -0,0 +1,164 @@
1
+ # Workflow: Security Audit
2
+
3
+ > **Purpose:** Identify realistic security vulnerabilities in the codebase.
4
+ > **Authorization:** Read-only. No file writes. No commits.
5
+ > **Scope:** Realistic vulnerabilities only. No theoretical or low-evidence findings.
6
+
7
+ ---
8
+
9
+ ## Trigger
10
+
11
+ - "security audit", "security review", "vulnerability check"
12
+ - "بررسی امنیتی", "آسیب‌پذیری"
13
+
14
+ ---
15
+
16
+ ## Required Context
17
+
18
+ 1. `core/agent-principles.md`
19
+ 2. `core/severity-levels.md`
20
+ 3. `.agents/project-context.md`
21
+ 4. `standards/security.md`
22
+
23
+ ---
24
+
25
+ ## Execution Steps
26
+
27
+ ### Step 1 — Define Scope
28
+
29
+ Confirm with the user:
30
+ - Full codebase audit, or specific module/endpoint?
31
+ - Recent changes only, or entire codebase?
32
+ - Any known areas of concern?
33
+
34
+ ### Step 2 — Enumerate Attack Surface
35
+
36
+ ```bash
37
+ # Routes and endpoints
38
+ cat routes/web.php routes/api.php 2>/dev/null
39
+ # or
40
+ grep -rn "app\.(get|post|put|delete|patch)" --include="*.js" --include="*.ts" src/ | head -30
41
+
42
+ # Authentication middleware
43
+ grep -rn "auth\|middleware\|guard\|protect" --include="*.php" routes/ app/ | head -20
44
+
45
+ # Public endpoints (no auth)
46
+ grep -rn "Route::" routes/web.php | grep -v "auth\|middleware" | head -20
47
+ ```
48
+
49
+ Identify:
50
+ - All authentication entry points.
51
+ - All endpoints that mutate data.
52
+ - All endpoints that return sensitive data.
53
+ - All file upload or download handlers.
54
+ - All external service integrations.
55
+
56
+ ### Step 3 — Inspect Vulnerability Categories
57
+
58
+ #### A. Injection
59
+
60
+ ```bash
61
+ # SQL Injection — look for raw queries or string concatenation
62
+ grep -rn "DB::select\|DB::statement\|whereRaw\|orderByRaw\|havingRaw" --include="*.php" app/ | head -20
63
+ grep -rn "query\|exec\|execute" --include="*.js" --include="*.ts" src/ | grep "req\.\|user\.\|\$_" | head -20
64
+
65
+ # Command Injection
66
+ grep -rn "exec\|shell_exec\|system\|passthru\|popen\|proc_open" --include="*.php" app/ | head -10
67
+ grep -rn "exec\|spawn\|execSync\|execFile" --include="*.ts" --include="*.js" src/ | head -10
68
+
69
+ # XSS — unescaped output
70
+ grep -rn "echo \$\|{!!\|v-html\|dangerouslySetInnerHTML" --include="*.php" --include="*.blade.php" --include="*.tsx" . | head -20
71
+ ```
72
+
73
+ #### B. Authentication and Authorization
74
+
75
+ ```bash
76
+ # Missing auth middleware
77
+ grep -rn "Route::\(get\|post\|put\|delete\)" routes/ | head -30
78
+
79
+ # Authorization checks in controllers
80
+ grep -rn "\$this->authorize\|Gate::\|can(\|Policy" --include="*.php" app/Http/Controllers/ | head -20
81
+
82
+ # JWT / session validation
83
+ grep -rn "token\|jwt\|session\|cookie" --include="*.php" --include="*.ts" app/ src/ | grep -i "valid\|verif\|check" | head -10
84
+ ```
85
+
86
+ #### C. Sensitive Data Exposure
87
+
88
+ ```bash
89
+ # Hardcoded secrets
90
+ grep -rn "password\|secret\|key\|token" --include="*.php" --include="*.ts" --include="*.js" . \
91
+ | grep -v "\.env\|config\|test\|spec\|\.git" \
92
+ | grep -i "['\"].\{8,\}['\"]" | head -20
93
+
94
+ # API responses that may leak sensitive data
95
+ grep -rn "toArray\|toJson\|->makeHidden\|->makeVisible\|hidden\|visible" --include="*.php" app/Models/ | head -20
96
+
97
+ # Error messages that expose internals
98
+ grep -rn "getMessage\|getTrace\|debug.*true\|APP_DEBUG" --include="*.php" . | grep -v test | head -10
99
+ ```
100
+
101
+ #### D. Mass Assignment
102
+
103
+ ```bash
104
+ # Laravel: unguarded models
105
+ grep -rn "unguarded\|fillable\|guarded" --include="*.php" app/Models/ | head -20
106
+ grep -rn "\$request->all()\|\$request->input()" --include="*.php" app/Http/ | head -20
107
+ ```
108
+
109
+ #### E. CSRF and Request Forgery
110
+
111
+ ```bash
112
+ # Check which routes are exempt from CSRF
113
+ grep -rn "VerifyCsrfToken\|except\|csrf" --include="*.php" app/Http/Middleware/ | head -10
114
+ ```
115
+
116
+ #### F. File Operations
117
+
118
+ ```bash
119
+ # Unsafe file operations
120
+ grep -rn "unlink\|rename\|move\|copy\|file_put_contents" --include="*.php" app/ | head -10
121
+ grep -rn "Storage::\|File::\|Filesystem" --include="*.php" app/ | head -10
122
+
123
+ # File upload handling
124
+ grep -rn "->store\|->move\|getClientOriginalExtension\|getMimeType" --include="*.php" app/ | head -10
125
+ ```
126
+
127
+ ### Step 4 — Read and Analyze
128
+
129
+ For each suspicious pattern found, read the surrounding code:
130
+ - 20–50 lines of context around the finding.
131
+ - The route definition and middleware chain.
132
+ - The model's `$fillable` or `$guarded` list.
133
+
134
+ Apply the verification checklist from `core/review-methodology.md` before recording any finding.
135
+
136
+ ### Step 5 — Generate Report
137
+
138
+ Report findings by severity (P0 → P3).
139
+
140
+ Include for each finding:
141
+ - Vulnerability type (from OWASP category).
142
+ - File and line number.
143
+ - Exact problematic code.
144
+ - Realistic attack scenario.
145
+ - Recommended fix.
146
+
147
+ ---
148
+
149
+ ## Completion Criteria
150
+
151
+ - Full attack surface enumerated.
152
+ - All six vulnerability categories inspected.
153
+ - Each finding has evidence, attack scenario, and fix.
154
+ - No speculative findings.
155
+
156
+ ---
157
+
158
+ ## Limitations
159
+
160
+ This workflow cannot:
161
+ - Run dynamic analysis (DAST) or penetration testing.
162
+ - Inspect third-party package source code thoroughly.
163
+ - Test cryptographic implementation correctness mathematically.
164
+ - Detect vulnerabilities requiring runtime state.
@@ -0,0 +1,168 @@
1
+ # Workflow: Test Generation
2
+
3
+ > **Purpose:** Generate meaningful tests for existing or new code.
4
+ > **Authorization:** Read freely. Write only test files.
5
+ > **Constraint:** Use only the testing frameworks already present in the project.
6
+
7
+ ---
8
+
9
+ ## Trigger
10
+
11
+ - "generate tests", "write tests", "add tests", "test coverage"
12
+ - "تست بنویس", "تست اضافه کن", "پوشش تست"
13
+
14
+ ---
15
+
16
+ ## Required Context
17
+
18
+ 1. `core/agent-principles.md`
19
+ 2. `.agents/project-context.md`
20
+ 3. `standards/testing.md`
21
+
22
+ ---
23
+
24
+ ## Execution Steps
25
+
26
+ ### Step 1 — Identify Testing Setup
27
+
28
+ ```bash
29
+ # PHP
30
+ cat composer.json | grep -i "phpunit\|pest\|codeception"
31
+ ls tests/
32
+
33
+ # JavaScript / TypeScript
34
+ cat package.json | grep -i "jest\|vitest\|mocha\|cypress\|playwright"
35
+ ls __tests__/ 2>/dev/null; ls src/__tests__/ 2>/dev/null; ls tests/ 2>/dev/null
36
+
37
+ # Python
38
+ cat pyproject.toml 2>/dev/null | grep -i "pytest\|unittest"
39
+ ls tests/
40
+
41
+ # Read one existing test file to understand conventions
42
+ find tests/ -name "*.test.*" -o -name "*Test.php" -o -name "*_test.py" | head -3 | xargs cat
43
+ ```
44
+
45
+ Identify:
46
+ - Test framework (PHPUnit, Pest, Jest, Vitest, pytest).
47
+ - Test file naming conventions (`FeatureTest.php`, `Feature.test.ts`, etc.).
48
+ - Test organization (feature vs unit, mirroring `src/` structure).
49
+ - Assertion style.
50
+ - Mocking library.
51
+ - Database testing strategy (refresh, factory, fixtures).
52
+
53
+ ### Step 2 — Understand the Code to Test
54
+
55
+ Read the target class or module fully:
56
+ - Public interface (all public methods).
57
+ - Dependencies (what it needs to function).
58
+ - Error conditions (what it throws or returns on failure).
59
+
60
+ ```bash
61
+ # PHP: list public methods
62
+ grep -n "public function" app/Services/TargetService.php
63
+
64
+ # TypeScript: list exports
65
+ grep -n "^export " src/services/TargetService.ts
66
+ ```
67
+
68
+ ### Step 3 — Identify Test Cases
69
+
70
+ For each public method / exported function, identify:
71
+
72
+ | Scenario | Priority |
73
+ |----------|----------|
74
+ | Happy path (expected inputs → expected output) | High |
75
+ | Validation error (invalid input → validation error) | High |
76
+ | Not found (missing resource → 404 / null / exception) | High |
77
+ | Unauthorized (wrong permissions → 403 / error) | High |
78
+ | Boundary values (empty string, zero, max value) | Medium |
79
+ | Concurrent access (if relevant) | Medium |
80
+ | External service failure (if mocked) | Medium |
81
+
82
+ Do not generate tests for private methods directly. Test through the public interface.
83
+
84
+ ### Step 4 — Present Test Plan
85
+
86
+ ```markdown
87
+ ## Test Plan: OrderService
88
+
89
+ **Framework:** PHPUnit / Pest
90
+ **Location:** `tests/Unit/Services/OrderServiceTest.php`
91
+ **Mocks required:** `PaymentGateway`, `InventoryService`
92
+
93
+ **Test cases:**
94
+ 1. `test_create_order_with_valid_data_returns_order_model`
95
+ 2. `test_create_order_with_missing_product_throws_not_found_exception`
96
+ 3. `test_create_order_with_insufficient_stock_returns_error`
97
+ 4. `test_create_order_calls_payment_gateway_once`
98
+ 5. `test_create_order_rolls_back_on_payment_failure`
99
+
100
+ Shall I generate these tests?
101
+ ```
102
+
103
+ **Wait for approval before writing files.**
104
+
105
+ ### Step 5 — Generate Tests
106
+
107
+ Write tests that:
108
+ - Follow the project's naming and organization conventions exactly.
109
+ - Use `arrange / act / assert` (or `given / when / then`) structure with clear comments.
110
+ - Test one thing per test method.
111
+ - Have descriptive names that explain the scenario.
112
+ - Use the project's existing factory or fixture setup.
113
+
114
+ ```php
115
+ // Example: PHPUnit / Pest (PHP)
116
+ it('creates an order and charges the payment gateway', function () {
117
+ // Arrange
118
+ $paymentGateway = Mockery::mock(PaymentGateway::class);
119
+ $paymentGateway->expects('charge')->once()->andReturn(true);
120
+ $this->app->instance(PaymentGateway::class, $paymentGateway);
121
+
122
+ $product = Product::factory()->create(['stock' => 10]);
123
+
124
+ // Act
125
+ $order = app(OrderService::class)->create([
126
+ 'product_id' => $product->id,
127
+ 'quantity' => 2,
128
+ ]);
129
+
130
+ // Assert
131
+ expect($order)->toBeInstanceOf(Order::class);
132
+ expect($order->status)->toBe('confirmed');
133
+ });
134
+ ```
135
+
136
+ ### Step 6 — Run Generated Tests
137
+
138
+ ```bash
139
+ # PHP
140
+ php artisan test --filter=OrderServiceTest
141
+ # or
142
+ ./vendor/bin/pest tests/Unit/Services/OrderServiceTest.php
143
+
144
+ # JavaScript
145
+ npm test -- --testPathPattern=OrderService
146
+ # or
147
+ npx vitest run src/services/OrderService.test.ts
148
+
149
+ # Python
150
+ pytest tests/unit/test_order_service.py -v
151
+ ```
152
+
153
+ Report actual output. Do not claim tests pass without running them.
154
+
155
+ ---
156
+
157
+ ## Completion Criteria
158
+
159
+ - Testing framework identified from existing setup.
160
+ - Test cases cover happy path and primary failure modes.
161
+ - Generated tests follow existing conventions exactly.
162
+ - Tests run successfully (or failures are documented with explanation).
163
+
164
+ ---
165
+
166
+ ## Boundaries
167
+
168
+ Do not introduce new testing dependencies (new libraries, new assertion styles) without user approval.