@martinffx/atelier 0.1.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 (130) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +21 -0
  3. package/README.md +285 -0
  4. package/agents/architect.md +38 -0
  5. package/agents/oracle.md +40 -0
  6. package/agents/recon.md +39 -0
  7. package/dist/atelier.js +33082 -0
  8. package/package.json +44 -0
  9. package/skills/code-conventional-commit/SKILL.md +134 -0
  10. package/skills/code-conventional-commit/evals/evals.json +23 -0
  11. package/skills/code-conventional-commit/workspace/iteration-1/eval-0/with_skill/outputs/commit-message.txt +4 -0
  12. package/skills/code-conventional-commit/workspace/iteration-1/eval-0/with_skill/outputs/eval_metadata.json +6 -0
  13. package/skills/code-conventional-commit/workspace/iteration-1/eval-1/with_skill/outputs/eval_metadata.json +6 -0
  14. package/skills/code-conventional-commit/workspace/iteration-1/eval-1/with_skill/outputs/validation-result.txt +16 -0
  15. package/skills/code-conventional-commit/workspace/iteration-1/eval-2/with_skill/outputs/commit-message.txt +8 -0
  16. package/skills/code-conventional-commit/workspace/iteration-1/eval-2/with_skill/outputs/eval_metadata.json +6 -0
  17. package/skills/code-conventional-commit/workspace/iteration-1/report.html +1325 -0
  18. package/skills/code-debug/SKILL.md +271 -0
  19. package/skills/code-debug/references/language-tools.md +139 -0
  20. package/skills/code-debug/references/techniques.md +117 -0
  21. package/skills/code-docs/SKILL.md +171 -0
  22. package/skills/code-docs/references/api-docs.md +116 -0
  23. package/skills/code-docs/references/changelog.md +64 -0
  24. package/skills/code-docs/references/readme-structure.md +94 -0
  25. package/skills/code-git-worktrees/SKILL.md +218 -0
  26. package/skills/code-perf/SKILL.md +163 -0
  27. package/skills/code-perf/references/common-bottlenecks.md +124 -0
  28. package/skills/code-perf/references/optimization-patterns.md +167 -0
  29. package/skills/code-perf/references/profiling-tools.md +126 -0
  30. package/skills/code-review/SKILL.md +78 -0
  31. package/skills/code-review/references/output.md +200 -0
  32. package/skills/code-review/references/reviewers.md +719 -0
  33. package/skills/code-review/references/rq.md +357 -0
  34. package/skills/code-review/references/rs.md +30 -0
  35. package/skills/code-security/SKILL.md +183 -0
  36. package/skills/code-security/references/owasp-top-10.md +129 -0
  37. package/skills/code-security/references/security-tools.md +102 -0
  38. package/skills/code-security/references/vulnerability-patterns.md +129 -0
  39. package/skills/code-stacked-commit/SKILL.md +155 -0
  40. package/skills/code-subagents/SKILL.md +184 -0
  41. package/skills/code-subagents/references/code-quality-reviewer-prompt.md +48 -0
  42. package/skills/code-subagents/references/implementor-prompt.md +79 -0
  43. package/skills/code-subagents/references/spec-reviewer-prompt.md +62 -0
  44. package/skills/oracle-architect/SKILL.md +246 -0
  45. package/skills/oracle-architect/references/api-design.md +345 -0
  46. package/skills/oracle-architect/references/data-modeling.md +318 -0
  47. package/skills/oracle-architect/references/ddd-patterns.md +247 -0
  48. package/skills/oracle-challenge/SKILL.md +126 -0
  49. package/skills/oracle-testing/SKILL.md +237 -0
  50. package/skills/oracle-testing/references/anti-patterns.md +618 -0
  51. package/skills/oracle-testing/references/boundaries.md +579 -0
  52. package/skills/oracle-testing/references/core-testing.md +691 -0
  53. package/skills/oracle-testing/references/edge-testing.md +794 -0
  54. package/skills/oracle-testing/references/stub-driven-tdd.md +322 -0
  55. package/skills/oracle-thinkdeep/SKILL.md +164 -0
  56. package/skills/python-architecture/SKILL.md +148 -0
  57. package/skills/python-architecture/references/data-modeling.md +558 -0
  58. package/skills/python-architecture/references/ddd.md +569 -0
  59. package/skills/python-architecture/references/functional-core.md +337 -0
  60. package/skills/python-build-tools/SKILL.md +153 -0
  61. package/skills/python-build-tools/references/basedpyright.md +321 -0
  62. package/skills/python-build-tools/references/ruff.md +225 -0
  63. package/skills/python-build-tools/references/uv.md +257 -0
  64. package/skills/python-fastapi/SKILL.md +184 -0
  65. package/skills/python-fastapi/references/api-design.md +563 -0
  66. package/skills/python-fastapi/references/dependencies.md +479 -0
  67. package/skills/python-fastapi/references/middleware.md +475 -0
  68. package/skills/python-fastapi/references/validation.md +497 -0
  69. package/skills/python-modern-python/SKILL.md +201 -0
  70. package/skills/python-modern-python/references/async.md +76 -0
  71. package/skills/python-modern-python/references/pattern-matching.md +89 -0
  72. package/skills/python-modern-python/references/typing.md +96 -0
  73. package/skills/python-monorepo/SKILL.md +146 -0
  74. package/skills/python-monorepo/references/docker.md +515 -0
  75. package/skills/python-monorepo/references/namespace-packages.md +426 -0
  76. package/skills/python-monorepo/references/workspace-config.md +341 -0
  77. package/skills/python-sqlalchemy/SKILL.md +119 -0
  78. package/skills/python-sqlalchemy/references/async.md +51 -0
  79. package/skills/python-sqlalchemy/references/models.md +67 -0
  80. package/skills/python-sqlalchemy/references/queries.md +57 -0
  81. package/skills/python-temporal/SKILL.md +128 -0
  82. package/skills/python-temporal/references/patterns.md +87 -0
  83. package/skills/python-temporal/references/testing.md +54 -0
  84. package/skills/python-testing/SKILL.md +161 -0
  85. package/skills/python-testing/references/boundaries.md +449 -0
  86. package/skills/python-testing/references/mocking.md +449 -0
  87. package/skills/python-testing/references/pytest.md +524 -0
  88. package/skills/spec-brainstorm/SKILL.md +325 -0
  89. package/skills/spec-finish/SKILL.md +159 -0
  90. package/skills/spec-implement/SKILL.md +296 -0
  91. package/skills/spec-orchestrator/SKILL.md +156 -0
  92. package/skills/spec-plan/SKILL.md +248 -0
  93. package/skills/typescript-api-design/SKILL.md +396 -0
  94. package/skills/typescript-api-design/references/error-responses.md +469 -0
  95. package/skills/typescript-build-tools/SKILL.md +447 -0
  96. package/skills/typescript-build-tools/references/biome.md +436 -0
  97. package/skills/typescript-build-tools/references/bun.md +432 -0
  98. package/skills/typescript-build-tools/references/turborepo.md +426 -0
  99. package/skills/typescript-build-tools/references/vitest.md +518 -0
  100. package/skills/typescript-drizzle-orm/SKILL.md +398 -0
  101. package/skills/typescript-drizzle-orm/references/cloudflare.md +392 -0
  102. package/skills/typescript-drizzle-orm/references/entity-pattern.md +412 -0
  103. package/skills/typescript-drizzle-orm/references/postgresql.md +191 -0
  104. package/skills/typescript-drizzle-orm/references/repository-pattern.md +479 -0
  105. package/skills/typescript-drizzle-orm/references/sqlite.md +291 -0
  106. package/skills/typescript-dynamodb-toolbox/SKILL.md +370 -0
  107. package/skills/typescript-dynamodb-toolbox/references/entity-layer.md +574 -0
  108. package/skills/typescript-dynamodb-toolbox/references/error-handling.md +495 -0
  109. package/skills/typescript-dynamodb-toolbox/references/modeling.md +332 -0
  110. package/skills/typescript-dynamodb-toolbox/references/repository-layer.md +631 -0
  111. package/skills/typescript-dynamodb-toolbox/references/testing.md +718 -0
  112. package/skills/typescript-dynamodb-toolbox/references/transactions.md +423 -0
  113. package/skills/typescript-effect-ts/SKILL.md +341 -0
  114. package/skills/typescript-effect-ts/references/core.md +412 -0
  115. package/skills/typescript-effect-ts/references/error-handling.md +468 -0
  116. package/skills/typescript-effect-ts/references/resources.md +476 -0
  117. package/skills/typescript-effect-ts/references/schema.md +536 -0
  118. package/skills/typescript-effect-ts/references/services.md +461 -0
  119. package/skills/typescript-fastify/SKILL.md +405 -0
  120. package/skills/typescript-fastify/references/plugins.md +329 -0
  121. package/skills/typescript-fastify/references/typeid.md +315 -0
  122. package/skills/typescript-functional-patterns/SKILL.md +402 -0
  123. package/skills/typescript-functional-patterns/references/adts.md +497 -0
  124. package/skills/typescript-functional-patterns/references/branded-types.md +542 -0
  125. package/skills/typescript-functional-patterns/references/migration-guide.md +695 -0
  126. package/skills/typescript-functional-patterns/references/option-result.md +585 -0
  127. package/skills/typescript-testing/SKILL.md +353 -0
  128. package/skills/typescript-testing/references/mocking.md +675 -0
  129. package/skills/typescript-testing/references/msw.md +852 -0
  130. package/skills/typescript-testing/references/snapshot-testing.md +774 -0
@@ -0,0 +1,124 @@
1
+ # Common Performance Bottlenecks
2
+
3
+ ## N+1 Query Problem
4
+
5
+ ### Symptom
6
+ Many database queries when one should suffice.
7
+
8
+ ### Diagnosis
9
+ ```sql
10
+ -- Enable query logging
11
+ -- See N+1 queries in logs
12
+ ```
13
+
14
+ ### Solution
15
+
16
+ **Before:**
17
+ ```python
18
+ for user in users:
19
+ print(user.profile.name) # Each = query
20
+ ```
21
+
22
+ **After:**
23
+ ```python
24
+ # Eager load
25
+ users = db.query(users).options(joinedload(User.profile)).all()
26
+
27
+ # Or batch
28
+ profiles = ProfileService.get_many([u.id for u in users])
29
+ ```
30
+
31
+ ---
32
+
33
+ ## Memory Leaks
34
+
35
+ ### Symptom
36
+ RSS grows over time, never回收es.
37
+
38
+ ### Diagnosis
39
+ - Chrome DevTools Memory tab
40
+ - heap snapshots before/after
41
+
42
+ ### Common Causes
43
+
44
+ 1. **Unclosed connections**
45
+ 2. **Growing caches** (no eviction)
46
+ 3. **Event listeners** (not removed)
47
+ 4. **Closures holding references**
48
+ 5. **Global variables**
49
+
50
+ ### Solution
51
+ ```javascript
52
+ // Clear cache
53
+ cache.clear();
54
+
55
+ // Remove listener
56
+ element.removeEventListener('click', handler);
57
+
58
+ // Use weak refs
59
+ const ref = new WeakRef(obj);
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Blocking I/O
65
+
66
+ ### Symptom
67
+ Thread/process blocked, can't handle other requests.
68
+
69
+ ### Solution
70
+
71
+ ```javascript
72
+ // Before: blocking
73
+ const data = fs.readFileSync('file.txt');
74
+
75
+ // After: async
76
+ const data = await fs.promises.readFile('file.txt');
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Unnecessary Work
82
+
83
+ ### Symptom
84
+ CPU high, doing redundant computation.
85
+
86
+ ### Examples
87
+
88
+ 1. **Validation twice** - in frontend and backend
89
+ 2. **Same calculation multiple times**
90
+ 3. **Processing data not needed**
91
+
92
+ ### Solution
93
+ ```javascript
94
+ // Cache expensive computations
95
+ const memoize = fn => {
96
+ const cache = new Map();
97
+ return (...args) => {
98
+ const key = JSON.stringify(args);
99
+ return cache.get(key) ?? fn(...args);
100
+ };
101
+ };
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Large Data Serialization
107
+
108
+ ### Symptom
109
+ Slow JSON serialization of large objects.
110
+
111
+ ### Solution
112
+
113
+ ```javascript
114
+ // Pagination
115
+ const page = req.query.page || 1;
116
+ const limit = 20;
117
+ const users = await db.users.findMany({
118
+ take: limit,
119
+ skip: (page - 1) * limit
120
+ });
121
+
122
+ // Streams for large files
123
+ stream.pipe(JSON.stringify());
124
+ ```
@@ -0,0 +1,167 @@
1
+ # Optimization Patterns
2
+
3
+ ## Caching
4
+
5
+ ### When
6
+ - Same data requested multiple times
7
+ - Expensive computation
8
+ - External API calls
9
+
10
+ ### Patterns
11
+
12
+ **In-memory:**
13
+ ```javascript
14
+ const cache = new Map();
15
+
16
+ async function getUser(id) {
17
+ if (cache.has(id)) return cache.get(id);
18
+ const user = await db.find(id);
19
+ cache.set(id, user);
20
+ return user;
21
+ }
22
+ ```
23
+
24
+ **With TTL:**
25
+ ```javascript
26
+ function withTTL(cache, ttl) {
27
+ return {
28
+ get(key) {
29
+ const item = cache.get(key);
30
+ if (item && Date.now() - item.timestamp < ttl) {
31
+ return item.value;
32
+ }
33
+ return null;
34
+ },
35
+ set(key, value) {
36
+ cache.set(key, { value, timestamp: Date.now() });
37
+ }
38
+ };
39
+ }
40
+ ```
41
+
42
+ **Distributed (Redis):**
43
+ ```javascript
44
+ async function getCached(key, fetcher, ttl = 300) {
45
+ const cached = await redis.get(key);
46
+ if (cached) return JSON.parse(cached);
47
+
48
+ const value = await fetcher();
49
+ await redis.set(key, JSON.stringify(value), 'EX', ttl);
50
+ return value;
51
+ }
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Lazy Loading
57
+
58
+ ### When
59
+ - Large data sets
60
+ - Heavy imports
61
+ - Optional features
62
+
63
+ ### Patterns
64
+
65
+ **Pagination:**
66
+ ```javascript
67
+ async function getUsers(page = 1, limit = 20) {
68
+ return db.users.findMany({
69
+ take: limit,
70
+ skip: (page - 1) * limit,
71
+ orderBy: { createdAt: 'desc' }
72
+ });
73
+ }
74
+ ```
75
+
76
+ **Code splitting:**
77
+ ```javascript
78
+ // Before: import everything
79
+ import * as heavy from './heavy';
80
+
81
+ // After: dynamic import
82
+ const heavy = await import('./heavy');
83
+ ```
84
+
85
+ **Virtual scrolling:**
86
+ ```javascript
87
+ // Only render visible items
88
+ <VirtualList items={users} height={400} itemHeight={40} />
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Connection Pooling
94
+
95
+ ### When
96
+ - Database connections
97
+ - HTTP clients
98
+ - WebSocket connections
99
+
100
+ ### Patterns
101
+
102
+ ```javascript
103
+ import { Pool } from 'pg';
104
+
105
+ const pool = new Pool({
106
+ max: 20,
107
+ idleTimeoutMillis: 30000,
108
+ connectionTimeoutMillis: 2000,
109
+ });
110
+
111
+ // Use throughout
112
+ const result = await pool.query('SELECT * FROM users');
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Batch Operations
118
+
119
+ ### When
120
+ - Multiple inserts/updates
121
+ - Multiple API calls
122
+
123
+ ### Patterns
124
+
125
+ **Bulk insert:**
126
+ ```javascript
127
+ // Before: N queries
128
+ for (const item of items) {
129
+ await db.insert(item);
130
+ }
131
+
132
+ // After: 1 query
133
+ await db.insertMany(items);
134
+ ```
135
+
136
+ **Batch API calls:**
137
+ ```javascript
138
+ // Use Promise.all with limit
139
+ async function batch(items, fn, limit = 10) {
140
+ const results = [];
141
+ for (let i = 0; i < items.length; i += limit) {
142
+ const batch = items.slice(i, i + limit);
143
+ results.push(...await Promise.all(batch.map(fn)));
144
+ }
145
+ return results;
146
+ }
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Memoization
152
+
153
+ ```javascript
154
+ function memoize(fn) {
155
+ const cache = new Map();
156
+ return (...args) => {
157
+ const key = JSON.stringify(args);
158
+ if (cache.has(key)) return cache.get(key);
159
+ const result = fn(...args);
160
+ cache.set(key, result);
161
+ return result;
162
+ };
163
+ }
164
+
165
+ // Usage
166
+ const fib = memoize(n => n <= 1 ? n : fib(n-1) + fib(n-2));
167
+ ```
@@ -0,0 +1,126 @@
1
+ # Profiling Tools
2
+
3
+ ## Node.js
4
+
5
+ ### Built-in
6
+
7
+ ```bash
8
+ # CPU profile
9
+ node --prof app.js
10
+ # Creates isolate-*.log
11
+
12
+ # Analyze
13
+ node --prof-process isolate-*.log
14
+
15
+ # Memory
16
+ node --inspect app.js
17
+ # Open chrome://inspect
18
+ ```
19
+
20
+ ### clinic.js
21
+
22
+ ```bash
23
+ npm install -g clinic
24
+
25
+ # CPU + event loop
26
+ clinic doctor -- node app.js
27
+
28
+ # CPU flame graph
29
+ clinic flame -- node app.js
30
+
31
+ # Memory flame graph
32
+ clinic泡沫 -- node app.js
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Python
38
+
39
+ ### cProfile
40
+
41
+ ```bash
42
+ # Profile
43
+ python -m cProfile -o profile.prof app.py
44
+
45
+ # Analyze (sorted by cumulative)
46
+ python -m cProfile -s cumulative app.py
47
+
48
+ # Analyze (sorted by time)
49
+ python -m cProfile -s tottime app.py
50
+
51
+ # Interactive
52
+ python -m cProfile -m app.py
53
+ ```
54
+
55
+ ### line-profiler
56
+
57
+ ```bash
58
+ pip install line_profiler
59
+
60
+ # Add @profile decorator
61
+ @profile
62
+ def slow_function():
63
+ ...
64
+
65
+ # Run
66
+ kernprof -l -v app.py
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Go
72
+
73
+ ### pprof
74
+
75
+ ```bash
76
+ # CPU profile
77
+ go test -cpuprofile=cpu.prof -bench=.
78
+ go tool pprof cpu.prof
79
+
80
+ # Memory profile
81
+ go test -memprofile=mem.prof -bench=.
82
+ go tool pprof mem.prof
83
+
84
+ # Web UI
85
+ go tool pprof -http=:8080 cpu.prof
86
+ ```
87
+
88
+ ### Built-in
89
+
90
+ ```bash
91
+ # Runtime stats
92
+ import runtime
93
+
94
+ func printStats() {
95
+ var m runtime.MemStats
96
+ runtime.ReadMemStats(&m)
97
+ println(m.Alloc, m.TotalAlloc, m.Mallocs)
98
+ }
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Browser
104
+
105
+ ### Chrome DevTools
106
+
107
+ 1. Open DevTools (F12)
108
+ 2. Performance tab
109
+ 3. Click Record
110
+ 4. Perform action
111
+ 5. Click Stop
112
+ 6. Analyze flame graph
113
+
114
+ ### What to Look For
115
+
116
+ - Long tasks (50ms+)
117
+ - Large paint/layout
118
+ - Expensive JS functions
119
+ - Memory growth over time
120
+
121
+ ### Memory Tab
122
+
123
+ - Take heap snapshot
124
+ - Compare snapshots
125
+ - Find detached DOM trees
126
+ - Track memory growth
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: code-review
3
+ description: Multi-agent code review with parallel specialized reviewers, architecture validation, and challenge validation. Use `rq` to request a review of diffs (defaults to main branch), `rs` to respond to review findings. Triggers on "review this", "review my code", "code review", "check for bugs", "audit this", when examining PRs, pull requests, branches, or diffs. Always asks user before applying fixes.
4
+ argument-hint: "rq [branch] | rs"
5
+ user-invocable: true
6
+ ---
7
+
8
+ # Code Review Skill
9
+
10
+ Multi-agent code analysis with parallel reviewers and challenge validation.
11
+
12
+ Uses explicit subagent dispatch patterns from [code-subagents](../code-subagents/SKILL.md).
13
+
14
+ ## Prerequisites
15
+
16
+ - **Required**: git
17
+
18
+ ## Arguments
19
+
20
+ ### Command Routing
21
+
22
+ | Invocation | Behavior |
23
+ |------------|----------|
24
+ | *(no arguments)* | Review diff to main branch |
25
+ | `rq` | Review diff to main branch |
26
+ | `rq main` | Review diff to main branch |
27
+ | `rq develop` | Review diff to develop branch |
28
+ | `feat/foo` | Review diff to feat/foo (bare branch = rq) |
29
+ | `rs` | Respond to review findings (interview mode) |
30
+
31
+ ## Subagent Architecture
32
+
33
+ ### rq (Request Review) Subagents
34
+
35
+ | Step | Subagent | Uses | Parallel | Purpose |
36
+ |------|----------|------|----------|---------|
37
+ | 1 | Triage | `scout` agent | No | Detect context, select reviewers, identify skills to load |
38
+ | 2 | Reviewers | `general` subagent | Yes (per reviewer) | Specialty analysis (loads detected skills) |
39
+ | 3 | Synthesis | `general` subagent | No | Deduplicate findings |
40
+ | 4 | Architect | `architect` agent | No | Architecture review |
41
+ | 5 | Challenge | `oracle` agent | No | Validate findings with sequential-thinking |
42
+
43
+ ### rs (Respond to Review)
44
+
45
+ No subagents. Interactive interview mode — see [rs.md](./references/rs.md).
46
+
47
+ ## Dispatch Patterns
48
+
49
+ Follows [code-subagents](../code-subagents/SKILL.md) patterns:
50
+ - **Parallel dispatch** for independent reviewers
51
+ - **Sequential dispatch** for dependent steps
52
+ - **Fresh subagent per task** — no context pollution
53
+ - **Skill loading pre-step** before each analysis phase
54
+ - **Error handling**: Log failures, continue with partial results
55
+
56
+ ## Agent Dispatch
57
+
58
+ | Agent | Used In Step |
59
+ |-------|--------------|
60
+ | `scout` | Triage (context retrieval, file analysis) |
61
+ | `architect` | Architect (architecture review) |
62
+ | `oracle` | Challenge (validate findings, sequential-thinking) |
63
+ | `general` | Reviewers, Synthesis |
64
+
65
+ See [agents/](../agents/) for agent definitions.
66
+
67
+ ## References
68
+
69
+ | Reference | Purpose |
70
+ |-----------|---------|
71
+ | [rq.md](./references/rq.md) | Request review workflow - detailed steps with prompts |
72
+ | [rs.md](./references/rs.md) | Respond to review workflow - interview mode |
73
+ | [reviewers.md](./references/reviewers.md) | Reviewer definitions and prompts |
74
+ | [output.md](./references/output.md) | Output format specification |
75
+ ## Workflow Routing
76
+
77
+ - No arguments, `rq`, or bare branch → [rq.md](./references/rq.md)
78
+ - `rs` → [rs.md](./references/rs.md)
@@ -0,0 +1,200 @@
1
+ # Output Format
2
+
3
+ ## Structured Summary
4
+
5
+ ```markdown
6
+ # Code Review: {module/files}
7
+
8
+ ## Summary
9
+ {2-3 sentence overview of changes and overall quality}
10
+
11
+ ## Statistics
12
+ - Files reviewed: N
13
+ - Findings: N Critical, N High, N Medium, N Low
14
+ - Pre-existing: N | Introduced: N
15
+
16
+ ## Critical (Fix before merge)
17
+
18
+ ### {Finding Title}
19
+
20
+ - **Location**: `file:line`
21
+ - **Severity**: Critical
22
+ - **Pre-existing**: No
23
+ - **Issue**: {What's wrong}
24
+ - **Impact**: {Why this matters}
25
+ - **Reasoning**:
26
+ <details>
27
+ <summary>Extended reasoning</summary>
28
+ {Detailed explanation of why this was flagged}
29
+ </details>
30
+ - **Suggestion**: {How to fix}
31
+
32
+ ## High Priority
33
+
34
+ ### {Finding Title}
35
+ {Same structure}
36
+
37
+ ## Medium Priority
38
+ {Same structure}
39
+
40
+ ## Low Priority
41
+ {Same structure}
42
+
43
+ ## Positive Findings
44
+
45
+ - {What the code does well}
46
+ - {Smart patterns to keep}
47
+ - {Good practices observed}
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Inline Finding Format
53
+
54
+ For each finding, provide inline comment style:
55
+
56
+ ```
57
+ [{file}:{line}] {Finding Title}
58
+ Severity: {Critical/High/Medium/Low}
59
+ Pre-existing: {Yes/No}
60
+ Issue: {Brief description}
61
+ Reasoning: {Why this matters}
62
+ Suggestion: {Fix}
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Severity Definitions
68
+
69
+ | Severity | When to use | Examples |
70
+ |----------|------------|----------|
71
+ | Critical | Security vulnerability, data loss risk, crash possible | SQL injection, auth bypass, unhandled exception that crashes |
72
+ | High | Bug causing wrong behavior, significant performance issue | Logic error, N+1 at scale, broken error handling |
73
+ | Medium | Code smell, maintainability issue, minor bug | Missing validation, excess complexity, unclear naming |
74
+ | Low | Style preference, optional improvement, educational | Naming inconsistency, missing docs, minor refactor |
75
+
76
+ ---
77
+
78
+ ## Pre-existing vs Introduced
79
+
80
+ | Type | Definition | How to detect |
81
+ |------|------------|---------------|
82
+ | Pre-existing | Bug existed before this PR | Git blame shows code unchanged |
83
+ | Introduced | Bug introduced by this PR | Code added/modified in diff |
84
+
85
+ **Marking pre-existing:**
86
+ - Check if the line was modified in the current diff
87
+ - If unchanged but flagged, mark as pre-existing
88
+ - Pre-existing findings are informational, not blocking
89
+
90
+ ---
91
+
92
+ ## Extended Reasoning
93
+
94
+ Each finding includes a collapsible section with:
95
+
96
+ 1. **Why flagged**: What triggered the finding (pattern, heuristic, context)
97
+ 2. **Verification**: How it was validated (static analysis, pattern match, context)
98
+ 3. **Evidence**: Code snippets, references, or examples
99
+ 4. **Alternative view**: If uncertain, what else to consider
100
+
101
+ Example:
102
+ ```markdown
103
+ <details>
104
+ <summary>Extended reasoning</summary>
105
+
106
+ **Why flagged**: The `query` parameter is directly interpolated into SQL string without parameterization.
107
+
108
+ **Verification**: Pattern match detected: `f"SELECT * FROM {table}"` - Python f-string in SQL context.
109
+
110
+ **Evidence**:
111
+ ```python
112
+ query = f"SELECT * FROM users WHERE id = {user_id}" # Line 42
113
+ ```
114
+
115
+ **Alternative view**: If using a query builder or ORM, check if it handles escaping internally.
116
+ </details>
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Example Output
122
+
123
+ ```markdown
124
+ # Code Review: src/auth/login.ts
125
+
126
+ ## Summary
127
+ Implements OAuth login flow with token refresh. Generally well-structured with proper error handling. One security concern around token storage and a performance issue with token validation on every request.
128
+
129
+ ## Statistics
130
+ - Files reviewed: 1
131
+ - Findings: 1 Critical, 1 High, 0 Medium, 2 Low
132
+ - Pre-existing: 1 | Introduced: 3
133
+
134
+ ## Critical (Fix before merge)
135
+
136
+ ### Token stored in localStorage
137
+
138
+ - **Location**: `src/auth/login.ts:45`
139
+ - **Severity**: Critical
140
+ - **Pre-existing**: No
141
+ - **Issue**: Access token stored in localStorage, vulnerable to XSS
142
+ - **Impact**: Any XSS vulnerability exposes user tokens
143
+ - **Reasoning**:
144
+ <details>
145
+ <summary>Extended reasoning</summary>
146
+
147
+ **Why flagged**: localStorage is accessible to any JavaScript on the page.
148
+
149
+ **Verification**: Direct localStorage API usage detected.
150
+
151
+ **Evidence**:
152
+ ```typescript
153
+ localStorage.setItem('accessToken', token); // Line 45
154
+ ```
155
+
156
+ **Alternative view**: If using httpOnly cookies is not possible, consider short-lived tokens with refresh rotation.
157
+ </details>
158
+ - **Suggestion**: Use httpOnly cookies or secure session storage
159
+
160
+ ## High Priority
161
+
162
+ ### Token validation on every request
163
+
164
+ - **Location**: `src/auth/middleware.ts:12`
165
+ - **Severity**: High
166
+ - **Pre-existing**: Yes
167
+ - **Issue**: Token validated against auth server on every request
168
+ - **Impact**: Adds 50-200ms latency per request
169
+
170
+ ## Low Priority
171
+
172
+ ### Missing JSDoc on public function
173
+
174
+ - **Location**: `src/auth/login.ts:23`
175
+ - **Severity**: Low
176
+ - **Pre-existing**: No
177
+ - **Issue**: `validateToken` lacks documentation
178
+
179
+ ### Inconsistent naming: userId vs user_id
180
+
181
+ - **Location**: `src/auth/login.ts:67`
182
+ - **Severity**: Low
183
+ - **Pre-existing**: Yes
184
+ - **Issue**: Mixed snake_case and camelCase in same file
185
+
186
+ ## Positive Findings
187
+
188
+ - Clean separation of OAuth flow into dedicated functions
189
+ - Proper error handling with typed error classes
190
+ - Token refresh logic handles edge cases well
191
+ ```
192
+
193
+ ---
194
+
195
+ ## Implementation Notes
196
+
197
+ 1. **Skills to load** are determined by Triage based on detected language/framework
198
+ 2. **Pre-existing detection** requires git blame check (not just diff)
199
+ 3. **Extended reasoning** should be collapsible in markdown renderers
200
+ 4. **Positive findings** help balance the review tone