Codebase Auditor (L2 Coordinator)
Coordinates 9 specialized audit workers to perform comprehensive codebase quality analysis.
Purpose & Scope
- Coordinates 9 audit workers (ln-621 through ln-629) running in parallel
- Research current best practices for detected tech stack via MCP tools ONCE
- Pass shared context to all workers (token-efficient)
- Aggregate worker results into single consolidated report
- Create single refactoring task in Linear under Epic 0 with all findings
- Manual invocation by user; not part of Story pipeline
Workflow
- Discovery: Load tech_stack.md, principles.md, package manifests, auto-discover Team ID
- Research: Query MCP tools for current best practices per major dependency ONCE
- Build Context: Create contextStore with best practices + tech stack metadata
- Domain Discovery: Detect project domains from folder structure (NEW)
- Delegate: Two-stage delegation - global workers + domain-aware workers (UPDATED)
- Aggregate: Collect worker results, group by domain, calculate scores
- Generate Report: Build consolidated report with Domain Health Summary, Findings by Domain
- Create Task: Create Linear task in Epic 0 titled "Codebase Refactoring: [YYYY-MM-DD]"
Phase 1: Discovery
Load project metadata:
docs/project/tech_stack.md - detect tech stack for research
docs/principles.md - project-specific quality principles
- Package manifests:
package.json, requirements.txt, go.mod, Cargo.toml
- Auto-discover Team ID from
docs/tasks/kanban_board.md
Extract metadata only (not full codebase scan):
- Programming language(s)
- Major frameworks/libraries
- Database system(s)
- Build tools
- Test framework(s)
Phase 2: Research Best Practices (ONCE)
For each major dependency identified in Phase 1:
- Use
mcp__Ref__ref_search_documentation for current best practices
- Use
mcp__context7__get-library-docs for up-to-date library documentation
- Focus areas by technology type:
| Type |
Research Focus |
| Web Framework |
Async patterns, middleware, error handling, request lifecycle |
| ML/AI Libraries |
Inference optimization, memory management, batching |
| Database |
Connection pooling, transactions, query optimization |
| Containerization |
Multi-stage builds, security, layer caching |
| Language Runtime |
Idioms, performance patterns, memory management |
Build contextStore:
{
"tech_stack": {...},
"best_practices": {...},
"principles": {...},
"codebase_root": "..."
}
Phase 3: Domain Discovery
Purpose: Detect project domains from folder structure for domain-aware auditing.
Algorithm:
Priority 1: Explicit domain folders
- Check for:
src/domains/*/, src/features/*/, src/modules/*/
- Monorepo patterns:
packages/*/, libs/*/, apps/*/
- If found (>1 match) → use these as domains
Priority 2: Top-level src/ folders*
- List folders:
src/users/, src/orders/, src/payments/
- Exclude infrastructure:
utils, shared, common, lib, helpers, config, types, interfaces, constants, middleware, infrastructure, core
- If remaining >1 → use as domains
Priority 3: Fallback to global mode
- If <2 domains detected →
domain_mode = "global"
- All workers scan entire codebase (backward-compatible behavior)
Heuristics for domain detection:
| Heuristic |
Indicator |
Example |
| File count |
>5 files in folder |
src/users/ with 12 files |
| Structure |
controllers/, services/, models/ present |
MVC/Clean Architecture |
| Barrel export |
index.ts/index.js exists |
Module pattern |
| README |
README.md describes domain |
Domain documentation |
Output:
{
"domain_mode": "domain-aware",
"all_domains": [
{"name": "users", "path": "src/users", "file_count": 45, "is_shared": false},
{"name": "orders", "path": "src/orders", "file_count": 32, "is_shared": false},
{"name": "shared", "path": "src/shared", "file_count": 15, "is_shared": true}
]
}
Shared folder handling:
- Folders named
shared, common, utils, lib, core → mark is_shared: true
- Shared code audited but grouped separately in report
- Does not affect domain-specific scores
Phase 4: Delegate to Workers
Phase 4a: Global Workers (PARALLEL)
Global workers scan entire codebase (not domain-aware):
| # |
Worker |
Priority |
What It Audits |
| 1 |
ln-621-security-auditor |
CRITICAL |
Hardcoded secrets, SQL injection, XSS, insecure deps |
| 2 |
ln-622-build-auditor |
CRITICAL |
Compiler/linter errors, deprecations, type errors |
| 5 |
ln-625-dependencies-auditor |
MEDIUM |
Outdated packages, unused deps, custom implementations |
| 6 |
ln-626-dead-code-auditor |
LOW |
Dead code, unused imports/variables, commented-out code |
| 7 |
ln-627-observability-auditor |
MEDIUM |
Structured logging, health checks, metrics, tracing |
| 8 |
ln-628-concurrency-auditor |
HIGH |
Race conditions, async/await, resource contention |
| 9 |
ln-629-lifecycle-auditor |
MEDIUM |
Bootstrap, graceful shutdown, resource cleanup |
Invocation (7 workers in PARALLEL):
FOR EACH worker IN [ln-621, ln-622, ln-625, ln-626, ln-627, ln-628, ln-629]:
Skill(skill=worker, args=JSON.stringify(contextStore))
Phase 4b: Domain-Aware Workers (PARALLEL per domain)
Domain-aware workers run once per domain:
| # |
Worker |
Priority |
What It Audits |
| 3 |
ln-623-architecture-auditor |
HIGH |
DRY/KISS/YAGNI violations, layer breaks, TODO/FIXME |
| 4 |
ln-624-code-quality-auditor |
MEDIUM |
Cyclomatic complexity, O(n²), N+1 queries, magic numbers |
Invocation (2 workers × N domains):
IF domain_mode == "domain-aware":
FOR EACH domain IN all_domains:
domain_context = {
...contextStore,
domain_mode: "domain-aware",
current_domain: { name: domain.name, path: domain.path }
}
// Invoke both workers for this domain
Skill(skill="ln-623-architecture-auditor", args=JSON.stringify(domain_context))
Skill(skill="ln-624-code-quality-auditor", args=JSON.stringify(domain_context))
ELSE:
// Fallback: invoke once for entire codebase (global mode)
Skill(skill="ln-623-architecture-auditor", args=JSON.stringify(contextStore))
Skill(skill="ln-624-code-quality-auditor", args=JSON.stringify(contextStore))
Parallelism strategy:
- Phase 4a: All 7 global workers run in PARALLEL
- Phase 4b: All (2 × N) domain-aware invocations run in PARALLEL
- Example: 3 domains → 6 invocations (ln-363×3 + ln-364×3) in single message
Phase 5: Aggregate Results
Collect results from workers:
Global worker output (unchanged):
{
"category": "Security",
"score": 7,
"total_issues": 5,
"critical": 1,
"high": 2,
"medium": 2,
"low": 0,
"findings": [...]
}
Domain-aware worker output (NEW):
{
"category": "Architecture & Design",
"score": 6,
"domain": "users",
"scan_path": "src/users",
"total_issues": 4,
"critical": 1,
"high": 2,
"medium": 1,
"low": 0,
"findings": [
{
"severity": "CRITICAL",
"location": "src/users/controllers/UserController.ts:45",
"issue": "Controller directly uses Repository",
"principle": "Layer Separation (Clean Architecture)",
"recommendation": "Create UserService",
"effort": "L",
"domain": "users"
}
]
}
Aggregation steps:
- Global workers → merge findings (as before)
- Domain-aware workers → group by domain.name:
- Calculate domain-level scores (Architecture + Quality per domain)
- Build Domain Health Summary table
- Overall score → average of all category scores (Architecture/Quality averaged across domains)
- Severity summary → sum critical/high/medium/low across ALL workers
- Findings grouping:
- Global categories (Security, Build, etc.) → single table
- Domain-aware categories → subtables per domain
Output Format
## Codebase Audit Report - [DATE]
### Executive Summary
[2-3 sentences on overall codebase health, major risks, and key strengths]
### Compliance Score
| Category | Score | Notes |
|----------|-------|-------|
| Security | X/10 | ... |
| Build Health | X/10 | ... |
| Architecture & Design | X/10 | ... |
| Code Quality | X/10 | ... |
| Dependencies & Reuse | X/10 | ... |
| Dead Code | X/10 | ... |
| Observability | X/10 | ... |
| Concurrency | X/10 | ... |
| Lifecycle | X/10 | ... |
| **Overall** | **X/10** | |
### Severity Summary
| Severity | Count |
|----------|-------|
| Critical | X |
| High | X |
| Medium | X |
| Low | X |
### Domain Health Summary (NEW - if domain_mode="domain-aware")
| Domain | Files | Arch Score | Quality Score | Issues |
|--------|-------|------------|---------------|--------|
| users | 45 | 7/10 | 8/10 | 5 |
| orders | 32 | 5/10 | 6/10 | 8 |
| payments | 28 | 8/10 | 7/10 | 3 |
| shared | 15 | 6/10 | 9/10 | 2 |
| **Total** | **120** | **6.5/10** | **7.5/10** | **18** |
### Strengths
- [What's done well in this codebase]
- [Good patterns and practices identified]
### Findings by Category
#### 1. Security (Global)
| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
|----------|----------|-------|-------------------|----------------|--------|
| CRITICAL | src/api/auth.ts:45 | Hardcoded API key | Secrets Management | Move to .env | S |
#### 2. Build Health (Global)
| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
|----------|----------|-------|-------------------|----------------|--------|
| CRITICAL | Multiple files | TypeScript strict errors | Type Safety | Fix types | S |
#### 3. Architecture & Design (Domain-Grouped)
##### Domain: users (src/users/)
| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
|----------|----------|-------|-------------------|----------------|--------|
| CRITICAL | UserController.ts:12 | Controller→Repository bypass | Layer Separation | Add Service layer | L |
##### Domain: orders (src/orders/)
| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
|----------|----------|-------|-------------------|----------------|--------|
| HIGH | OrderService.ts:45 | DRY violation (duplicate validation) | DRY Principle | Extract to validators/ | M |
##### Domain: shared (src/shared/)
| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
|----------|----------|-------|-------------------|----------------|--------|
| MEDIUM | utils.ts:78 | TODO older than 6 months | Code Hygiene | Complete or remove | S |
#### 4. Code Quality (Domain-Grouped)
##### Domain: users (src/users/)
| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
|----------|----------|-------|-------------------|----------------|--------|
| HIGH | UserService.ts:120 | Complexity 25 | Maintainability | Split function | M |
... (continue for remaining global categories: 5-9)
### Recommended Actions (Priority-Sorted)
| Priority | Category | Domain | Location | Issue | Recommendation | Effort |
|----------|----------|--------|----------|-------|----------------|--------|
| CRITICAL | Security | - | src/api/auth.ts:45 | Hardcoded API key | Move to .env | S |
| CRITICAL | Architecture | users | UserController.ts:12 | Controller→Repository bypass | Add Service layer | L |
| CRITICAL | Build | - | Multiple files | TypeScript strict errors | Fix types | S |
| HIGH | Architecture | orders | OrderService.ts:45 | DRY violation | Extract to validators/ | M |
| HIGH | Code Quality | users | UserService.ts:120 | Complexity 25 | Split function | M |
### Priority Actions
1. Fix all Critical issues before next release
2. Address High issues within current sprint
3. Plan Medium issues for technical debt sprint
4. Track Low issues in backlog
### Sources Consulted
- [Framework] best practices: [URL from MCP Ref]
- [Library] documentation: [URL from Context7]
Phase 6: Create Linear Task
Create task in Epic 0:
- Title:
Codebase Refactoring: [YYYY-MM-DD]
- Description: Full report from Phase 5 (markdown format)
- Team: Auto-discovered from kanban_board.md
- Epic: 0 (technical debt / refactoring epic)
- Labels:
refactoring, technical-debt, audit
- Priority: Based on highest severity findings (Critical → Urgent, High → High, etc.)
Critical Rules
- Two-stage delegation: Global workers (7) + Domain-aware workers (2 × N domains)
- Domain discovery: Auto-detect domains from folder structure; fallback to global mode
- Parallel execution: All workers (global + domain-aware) run in PARALLEL
- Single context gathering: Research best practices ONCE, pass contextStore to all workers
- Metadata-only loading: Coordinator loads metadata only; workers load full file contents
- Domain-grouped output: Architecture & Code Quality findings grouped by domain
- Language preservation: Task description in project's language (EN/RU from kanban_board.md)
- Single task: Create ONE task with all findings; do not create multiple tasks
- Do not audit: Coordinator orchestrates only; audit logic lives in workers
Definition of Done
- Best practices researched via MCP tools for major dependencies
- Domain discovery completed (domain_mode determined)
- contextStore built with tech stack + best practices + domain info
- Global workers (7) invoked in PARALLEL
- Domain-aware workers (2 × N domains) invoked in PARALLEL
- All workers completed successfully (or reported errors)
- Results aggregated with domain grouping
- Domain Health Summary built (if domain_mode="domain-aware")
- Compliance score (X/10) calculated per category + overall
- Executive Summary and Strengths sections included
- Linear task created in Epic 0 with full report
- Sources consulted listed with URLs
Workers
See individual worker SKILL.md files for detailed audit rules:
Reference Files
- Principles:
docs/principles.md
- Tech stack:
docs/project/tech_stack.md
- Kanban board:
docs/tasks/kanban_board.md
Version: 5.0.0
Last Updated: 2025-12-23
1---
2name: ln-620-codebase-auditor
3description: Coordinates 9 specialized audit workers (security, build, architecture, code quality, dependencies, dead code, observability, concurrency, lifecycle). Researches best practices, delegates parallel audits, aggregates results into single Linear task in Epic 0.
4allowed-tools: Read, Grep, Glob, Bash, WebFetch, WebSearch, mcp__Ref, mcp__context7, mcp__linear-server, Skill
5metadata:
6 source: https://skillmd.com/skills/aibot88/ln-620-codebase-auditor
7---
8
9# Codebase Auditor (L2 Coordinator)
10
11Coordinates 9 specialized audit workers to perform comprehensive codebase quality analysis.
12
13## Purpose & Scope
14
15- **Coordinates 9 audit workers** (ln-621 through ln-629) running in parallel
16- Research current best practices for detected tech stack via MCP tools ONCE
17- Pass shared context to all workers (token-efficient)
18- Aggregate worker results into single consolidated report
19- Create single refactoring task in Linear under Epic 0 with all findings
20- Manual invocation by user; not part of Story pipeline
21
22## Workflow
23
241) **Discovery:** Load tech_stack.md, principles.md, package manifests, auto-discover Team ID
252) **Research:** Query MCP tools for current best practices per major dependency ONCE
263) **Build Context:** Create contextStore with best practices + tech stack metadata
274) **Domain Discovery:** Detect project domains from folder structure (NEW)
285) **Delegate:** Two-stage delegation - global workers + domain-aware workers (UPDATED)
296) **Aggregate:** Collect worker results, group by domain, calculate scores
307) **Generate Report:** Build consolidated report with Domain Health Summary, Findings by Domain
318) **Create Task:** Create Linear task in Epic 0 titled "Codebase Refactoring: [YYYY-MM-DD]"
32
33## Phase 1: Discovery
34
35**Load project metadata:**
36- `docs/project/tech_stack.md` - detect tech stack for research
37- `docs/principles.md` - project-specific quality principles
38- Package manifests: `package.json`, `requirements.txt`, `go.mod`, `Cargo.toml`
39- Auto-discover Team ID from `docs/tasks/kanban_board.md`
40
41**Extract metadata only** (not full codebase scan):
42- Programming language(s)
43- Major frameworks/libraries
44- Database system(s)
45- Build tools
46- Test framework(s)
47
48## Phase 2: Research Best Practices (ONCE)
49
50**For each major dependency identified in Phase 1:**
51
521. Use `mcp__Ref__ref_search_documentation` for current best practices
532. Use `mcp__context7__get-library-docs` for up-to-date library documentation
543. Focus areas by technology type:
55
56| Type | Research Focus |
57|------|----------------|
58| Web Framework | Async patterns, middleware, error handling, request lifecycle |
59| ML/AI Libraries | Inference optimization, memory management, batching |
60| Database | Connection pooling, transactions, query optimization |
61| Containerization | Multi-stage builds, security, layer caching |
62| Language Runtime | Idioms, performance patterns, memory management |
63
64**Build contextStore:**
65```json
66{
67 "tech_stack": {...},
68 "best_practices": {...},
69 "principles": {...},
70 "codebase_root": "..."
71}
72```
73
74## Phase 3: Domain Discovery
75
76**Purpose:** Detect project domains from folder structure for domain-aware auditing.
77
78**Algorithm:**
79
801. **Priority 1: Explicit domain folders**
81 - Check for: `src/domains/*/`, `src/features/*/`, `src/modules/*/`
82 - Monorepo patterns: `packages/*/`, `libs/*/`, `apps/*/`
83 - If found (>1 match) → use these as domains
84
852. **Priority 2: Top-level src/* folders**
86 - List folders: `src/users/`, `src/orders/`, `src/payments/`
87 - Exclude infrastructure: `utils`, `shared`, `common`, `lib`, `helpers`, `config`, `types`, `interfaces`, `constants`, `middleware`, `infrastructure`, `core`
88 - If remaining >1 → use as domains
89
903. **Priority 3: Fallback to global mode**
91 - If <2 domains detected → `domain_mode = "global"`
92 - All workers scan entire codebase (backward-compatible behavior)
93
94**Heuristics for domain detection:**
95
96| Heuristic | Indicator | Example |
97|-----------|-----------|---------|
98| File count | >5 files in folder | `src/users/` with 12 files |
99| Structure | controllers/, services/, models/ present | MVC/Clean Architecture |
100| Barrel export | index.ts/index.js exists | Module pattern |
101| README | README.md describes domain | Domain documentation |
102
103**Output:**
104```json
105{
106 "domain_mode": "domain-aware",
107 "all_domains": [
108 {"name": "users", "path": "src/users", "file_count": 45, "is_shared": false},
109 {"name": "orders", "path": "src/orders", "file_count": 32, "is_shared": false},
110 {"name": "shared", "path": "src/shared", "file_count": 15, "is_shared": true}
111 ]
112}
113```
114
115**Shared folder handling:**
116- Folders named `shared`, `common`, `utils`, `lib`, `core` → mark `is_shared: true`
117- Shared code audited but grouped separately in report
118- Does not affect domain-specific scores
119
120## Phase 4: Delegate to Workers
121
122### Phase 4a: Global Workers (PARALLEL)
123
124**Global workers** scan entire codebase (not domain-aware):
125
126| # | Worker | Priority | What It Audits |
127|---|--------|----------|----------------|
128| 1 | ln-621-security-auditor | CRITICAL | Hardcoded secrets, SQL injection, XSS, insecure deps |
129| 2 | ln-622-build-auditor | CRITICAL | Compiler/linter errors, deprecations, type errors |
130| 5 | ln-625-dependencies-auditor | MEDIUM | Outdated packages, unused deps, custom implementations |
131| 6 | ln-626-dead-code-auditor | LOW | Dead code, unused imports/variables, commented-out code |
132| 7 | ln-627-observability-auditor | MEDIUM | Structured logging, health checks, metrics, tracing |
133| 8 | ln-628-concurrency-auditor | HIGH | Race conditions, async/await, resource contention |
134| 9 | ln-629-lifecycle-auditor | MEDIUM | Bootstrap, graceful shutdown, resource cleanup |
135
136**Invocation (7 workers in PARALLEL):**
137```javascript
138FOR EACH worker IN [ln-621, ln-622, ln-625, ln-626, ln-627, ln-628, ln-629]:
139 Skill(skill=worker, args=JSON.stringify(contextStore))
140```
141
142### Phase 4b: Domain-Aware Workers (PARALLEL per domain)
143
144**Domain-aware workers** run once per domain:
145
146| # | Worker | Priority | What It Audits |
147|---|--------|----------|----------------|
148| 3 | ln-623-architecture-auditor | HIGH | DRY/KISS/YAGNI violations, layer breaks, TODO/FIXME |
149| 4 | ln-624-code-quality-auditor | MEDIUM | Cyclomatic complexity, O(n²), N+1 queries, magic numbers |
150
151**Invocation (2 workers × N domains):**
152```javascript
153IF domain_mode == "domain-aware":
154 FOR EACH domain IN all_domains:
155 domain_context = {
156 ...contextStore,
157 domain_mode: "domain-aware",
158 current_domain: { name: domain.name, path: domain.path }
159 }
160 // Invoke both workers for this domain
161 Skill(skill="ln-623-architecture-auditor", args=JSON.stringify(domain_context))
162 Skill(skill="ln-624-code-quality-auditor", args=JSON.stringify(domain_context))
163ELSE:
164 // Fallback: invoke once for entire codebase (global mode)
165 Skill(skill="ln-623-architecture-auditor", args=JSON.stringify(contextStore))
166 Skill(skill="ln-624-code-quality-auditor", args=JSON.stringify(contextStore))
167```
168
169**Parallelism strategy:**
170- Phase 4a: All 7 global workers run in PARALLEL
171- Phase 4b: All (2 × N) domain-aware invocations run in PARALLEL
172- Example: 3 domains → 6 invocations (ln-363×3 + ln-364×3) in single message
173
174## Phase 5: Aggregate Results
175
176**Collect results from workers:**
177
178**Global worker output (unchanged):**
179```json
180{
181 "category": "Security",
182 "score": 7,
183 "total_issues": 5,
184 "critical": 1,
185 "high": 2,
186 "medium": 2,
187 "low": 0,
188 "findings": [...]
189}
190```
191
192**Domain-aware worker output (NEW):**
193```json
194{
195 "category": "Architecture & Design",
196 "score": 6,
197 "domain": "users",
198 "scan_path": "src/users",
199 "total_issues": 4,
200 "critical": 1,
201 "high": 2,
202 "medium": 1,
203 "low": 0,
204 "findings": [
205 {
206 "severity": "CRITICAL",
207 "location": "src/users/controllers/UserController.ts:45",
208 "issue": "Controller directly uses Repository",
209 "principle": "Layer Separation (Clean Architecture)",
210 "recommendation": "Create UserService",
211 "effort": "L",
212 "domain": "users"
213 }
214 ]
215}
216```
217
218**Aggregation steps:**
219
2201. **Global workers** → merge findings (as before)
2212. **Domain-aware workers** → group by domain.name:
222 - Calculate domain-level scores (Architecture + Quality per domain)
223 - Build Domain Health Summary table
2243. **Overall score** → average of all category scores (Architecture/Quality averaged across domains)
2254. **Severity summary** → sum critical/high/medium/low across ALL workers
2265. **Findings grouping:**
227 - Global categories (Security, Build, etc.) → single table
228 - Domain-aware categories → subtables per domain
229
230## Output Format
231
232```markdown
233## Codebase Audit Report - [DATE]
234
235### Executive Summary
236[2-3 sentences on overall codebase health, major risks, and key strengths]
237
238### Compliance Score
239
240| Category | Score | Notes |
241|----------|-------|-------|
242| Security | X/10 | ... |
243| Build Health | X/10 | ... |
244| Architecture & Design | X/10 | ... |
245| Code Quality | X/10 | ... |
246| Dependencies & Reuse | X/10 | ... |
247| Dead Code | X/10 | ... |
248| Observability | X/10 | ... |
249| Concurrency | X/10 | ... |
250| Lifecycle | X/10 | ... |
251| **Overall** | **X/10** | |
252
253### Severity Summary
254
255| Severity | Count |
256|----------|-------|
257| Critical | X |
258| High | X |
259| Medium | X |
260| Low | X |
261
262### Domain Health Summary (NEW - if domain_mode="domain-aware")
263
264| Domain | Files | Arch Score | Quality Score | Issues |
265|--------|-------|------------|---------------|--------|
266| users | 45 | 7/10 | 8/10 | 5 |
267| orders | 32 | 5/10 | 6/10 | 8 |
268| payments | 28 | 8/10 | 7/10 | 3 |
269| shared | 15 | 6/10 | 9/10 | 2 |
270| **Total** | **120** | **6.5/10** | **7.5/10** | **18** |
271
272### Strengths
273- [What's done well in this codebase]
274- [Good patterns and practices identified]
275
276### Findings by Category
277
278#### 1. Security (Global)
279
280| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
281|----------|----------|-------|-------------------|----------------|--------|
282| CRITICAL | src/api/auth.ts:45 | Hardcoded API key | Secrets Management | Move to .env | S |
283
284#### 2. Build Health (Global)
285
286| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
287|----------|----------|-------|-------------------|----------------|--------|
288| CRITICAL | Multiple files | TypeScript strict errors | Type Safety | Fix types | S |
289
290#### 3. Architecture & Design (Domain-Grouped)
291
292##### Domain: users (src/users/)
293
294| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
295|----------|----------|-------|-------------------|----------------|--------|
296| CRITICAL | UserController.ts:12 | Controller→Repository bypass | Layer Separation | Add Service layer | L |
297
298##### Domain: orders (src/orders/)
299
300| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
301|----------|----------|-------|-------------------|----------------|--------|
302| HIGH | OrderService.ts:45 | DRY violation (duplicate validation) | DRY Principle | Extract to validators/ | M |
303
304##### Domain: shared (src/shared/)
305
306| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
307|----------|----------|-------|-------------------|----------------|--------|
308| MEDIUM | utils.ts:78 | TODO older than 6 months | Code Hygiene | Complete or remove | S |
309
310#### 4. Code Quality (Domain-Grouped)
311
312##### Domain: users (src/users/)
313
314| Severity | Location | Issue | Principle Violated | Recommendation | Effort |
315|----------|----------|-------|-------------------|----------------|--------|
316| HIGH | UserService.ts:120 | Complexity 25 | Maintainability | Split function | M |
317
318... (continue for remaining global categories: 5-9)
319
320### Recommended Actions (Priority-Sorted)
321
322| Priority | Category | Domain | Location | Issue | Recommendation | Effort |
323|----------|----------|--------|----------|-------|----------------|--------|
324| CRITICAL | Security | - | src/api/auth.ts:45 | Hardcoded API key | Move to .env | S |
325| CRITICAL | Architecture | users | UserController.ts:12 | Controller→Repository bypass | Add Service layer | L |
326| CRITICAL | Build | - | Multiple files | TypeScript strict errors | Fix types | S |
327| HIGH | Architecture | orders | OrderService.ts:45 | DRY violation | Extract to validators/ | M |
328| HIGH | Code Quality | users | UserService.ts:120 | Complexity 25 | Split function | M |
329
330### Priority Actions
3311. Fix all Critical issues before next release
3322. Address High issues within current sprint
3333. Plan Medium issues for technical debt sprint
3344. Track Low issues in backlog
335
336### Sources Consulted
337- [Framework] best practices: [URL from MCP Ref]
338- [Library] documentation: [URL from Context7]
339```
340
341## Phase 6: Create Linear Task
342
343Create task in Epic 0:
344- Title: `Codebase Refactoring: [YYYY-MM-DD]`
345- Description: Full report from Phase 5 (markdown format)
346- Team: Auto-discovered from kanban_board.md
347- Epic: 0 (technical debt / refactoring epic)
348- Labels: `refactoring`, `technical-debt`, `audit`
349- Priority: Based on highest severity findings (Critical → Urgent, High → High, etc.)
350
351## Critical Rules
352
353- **Two-stage delegation:** Global workers (7) + Domain-aware workers (2 × N domains)
354- **Domain discovery:** Auto-detect domains from folder structure; fallback to global mode
355- **Parallel execution:** All workers (global + domain-aware) run in PARALLEL
356- **Single context gathering:** Research best practices ONCE, pass contextStore to all workers
357- **Metadata-only loading:** Coordinator loads metadata only; workers load full file contents
358- **Domain-grouped output:** Architecture & Code Quality findings grouped by domain
359- **Language preservation:** Task description in project's language (EN/RU from kanban_board.md)
360- **Single task:** Create ONE task with all findings; do not create multiple tasks
361- **Do not audit:** Coordinator orchestrates only; audit logic lives in workers
362
363## Definition of Done
364
365- Best practices researched via MCP tools for major dependencies
366- Domain discovery completed (domain_mode determined)
367- contextStore built with tech stack + best practices + domain info
368- Global workers (7) invoked in PARALLEL
369- Domain-aware workers (2 × N domains) invoked in PARALLEL
370- All workers completed successfully (or reported errors)
371- Results aggregated with domain grouping
372- Domain Health Summary built (if domain_mode="domain-aware")
373- Compliance score (X/10) calculated per category + overall
374- Executive Summary and Strengths sections included
375- Linear task created in Epic 0 with full report
376- Sources consulted listed with URLs
377
378## Workers
379
380See individual worker SKILL.md files for detailed audit rules:
381- [ln-621-security-auditor](../ln-621-security-auditor/SKILL.md)
382- [ln-622-build-auditor](../ln-622-build-auditor/SKILL.md)
383- [ln-623-architecture-auditor](../ln-623-architecture-auditor/SKILL.md)
384- [ln-624-code-quality-auditor](../ln-624-code-quality-auditor/SKILL.md)
385- [ln-625-dependencies-auditor](../ln-625-dependencies-auditor/SKILL.md)
386- [ln-626-dead-code-auditor](../ln-626-dead-code-auditor/SKILL.md)
387- [ln-627-observability-auditor](../ln-627-observability-auditor/SKILL.md)
388- [ln-628-concurrency-auditor](../ln-628-concurrency-auditor/SKILL.md)
389- [ln-629-lifecycle-auditor](../ln-629-lifecycle-auditor/SKILL.md)
390
391## Reference Files
392
393- Principles: `docs/principles.md`
394- Tech stack: `docs/project/tech_stack.md`
395- Kanban board: `docs/tasks/kanban_board.md`
396
397---
398**Version:** 5.0.0
399**Last Updated:** 2025-12-23