tlc-claude-code 2.2.0 → 2.3.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.
@@ -122,6 +122,23 @@ src/modules/{entity}/
122
122
  - No credentials — use environment variables.
123
123
  - No magic numbers or strings — use named constants or enums.
124
124
 
125
+ ### Configuration
126
+ - All `process.env` access MUST be in a config module — never in services or controllers.
127
+ - Validate all required env vars at startup with a schema (Zod/Joi).
128
+ - No silent empty-string fallbacks for secrets or connection strings.
129
+
130
+ ### Security
131
+ - Every data-access endpoint MUST check resource ownership, not just authentication.
132
+ - Never return secrets (API keys, tokens, passwords) in API responses or HTML.
133
+ - Hash OTPs, reset tokens, and session secrets before storing — never plaintext.
134
+ - Escape all dynamic values in HTML output — no raw interpolation.
135
+ - No inline HTML string builders for new pages — use a proper frontend or templating engine.
136
+ - Tests MUST prove that user A cannot read/modify user B's data.
137
+
138
+ ### Dependency Injection
139
+ - Never manually instantiate services/providers with `new` — use DI.
140
+ - Register all providers in the DI container.
141
+
125
142
  ### File and Folder Limits
126
143
  - Files: warn at 500 lines, error at 1000 lines.
127
144
  - Folders: warn at 8 files, error at 15 files.
@@ -52,6 +52,11 @@ Run `auditProject(projectPath)` which executes:
52
52
  | **Missing Return Types** | Exported functions without explicit return type | warning |
53
53
  | **Missing Parameter Types** | Function parameters without type annotations | error |
54
54
  | **Weak tsconfig** | `strict: true` not enabled in tsconfig.json | warning |
55
+ | **Direct `process.env`** | `process.env.` usage outside config module files | error |
56
+ | **Unescaped HTML** | Template literals containing HTML tags with `${` interpolation | error |
57
+ | **Secrets in Responses** | Response objects containing fields named `apiKey`, `secret`, `token`, `password` | error |
58
+ | **Manual Instantiation** | `new .*Provider(` or `new .*Service(` in application code | warning |
59
+ | **Missing Ownership Check** | Controller methods with `@Param('id')` but no ownership/authorization guard | warning |
55
60
 
56
61
  ### Step 3: Generate Report
57
62
 
@@ -109,6 +114,13 @@ Status: FAILED (18 issues found)
109
114
  JSDoc Coverage: 8 issues (42% of exports undocumented)
110
115
  Import Style: PASSED
111
116
 
117
+ SECURITY & CONFIG
118
+ Direct process.env: 3 issues (outside config module)
119
+ Unescaped HTML: 2 issues
120
+ Secrets in Responses: 1 issue
121
+ Manual Instantiation: 1 issue
122
+ Missing Ownership: 2 issues
123
+
112
124
  Report saved to: .planning/AUDIT-REPORT.md
113
125
 
114
126
  Fix automatically? Run /tlc:cleanup
@@ -166,7 +166,7 @@ Senior engineers know when rules don't apply:
166
166
 
167
167
  This is the core TLC command. Tests before code, one task at a time.
168
168
 
169
- **Overdrive Mode (Opus 4.6):** When tasks are independent, TLC auto-detects and offers parallel execution with multiple agents. Agents are assigned models based on task complexity (opus for heavy, sonnet for standard, haiku for light). Failed agents can be resumed. No arbitrary cap on agent count.
169
+ **Parallel by default:** When tasks are independent, TLC auto-detects and runs them in parallel. Multiple providers (Claude + Codex) get their own git worktrees and tmux panes. Single provider uses in-process agents. No flags needed it just works.
170
170
 
171
171
  ## Usage
172
172
 
@@ -185,74 +185,80 @@ This is the core TLC command. Tests before code, one task at a time.
185
185
 
186
186
  Read all `.planning/phases/{phase}-*-PLAN.md` files for this phase.
187
187
 
188
- ### Step 1a: Overdrive Detection (Auto-Parallel, Opus 4.6)
188
+ ### Step 1a: Auto-Parallel Detection
189
189
 
190
- After loading plans, analyze task dependencies to determine if parallel execution is possible.
190
+ After loading plans, analyze task dependencies and available providers to pick the best execution strategy automatically.
191
191
 
192
- **Check for dependencies:**
193
- ```javascript
194
- // Patterns that indicate dependencies:
195
- // - "depends on task N"
196
- // - "after task N"
197
- // - "requires task N"
198
- // - "blocked by task N"
199
- // - "## Dependencies" section with task relationships
200
- ```
201
-
202
- **Decision logic:**
192
+ **Detection:**
203
193
  1. Parse all tasks from plan
204
- 2. Look for dependency markers in task descriptions
205
- 3. Check "## Dependencies" section if present
206
- 4. Identify independent tasks (no dependencies)
207
- 5. Estimate task complexity for model assignment (heavy/standard/light)
194
+ 2. Check "## Dependencies" section for task relationships
195
+ 3. Identify independent tasks (no unmet dependencies)
196
+ 4. Read `.tlc/.router-state.json` for available providers
197
+ 5. Check if tmux is available
208
198
 
209
- **If 2+ independent tasks found:**
210
- ```
211
- 🚀 Overdrive Mode Available (Opus 4.6)
199
+ **Strategy selection (automatic, no flags needed):**
212
200
 
213
- Phase 3 has 4 independent tasks that can run in parallel:
214
- - Task 1: Create user schema [opus] (heavy)
215
- - Task 2: Add validation helpers [sonnet] (standard)
216
- - Task 3: Write migration scripts [sonnet] (standard)
217
- - Task 4: Create seed data [haiku] (light)
201
+ | Condition | Strategy | What happens |
202
+ |-----------|----------|--------------|
203
+ | 2+ independent tasks, Claude + Codex available, tmux available | **Worktree + Tmux** | Each task gets own git worktree + tmux pane. Claude and Codex work simultaneously. |
204
+ | 2+ independent tasks, Claude + Codex available, no tmux | **Worktree + Background** | Same but without tmux visibility. |
205
+ | 2+ independent tasks, single provider only | **In-process agents** | Agent tool spawns parallel sub-agents (sonnet/haiku by complexity). |
206
+ | All tasks have dependencies | **Sequential** | One task at a time, in dependency order. |
207
+ | 1 task only | **Sequential** | Just build it. |
218
208
 
219
- Recommended: 4 agents (one per independent task)
209
+ **No prompt, no options menu.** TLC picks the best strategy and runs it. User sees:
220
210
 
221
- Options:
222
- 1) Overdrive mode (parallel agents) [Recommended]
223
- 2) Sequential mode (one task at a time)
224
- 3) Let me pick which tasks to parallelize
225
211
  ```
212
+ Phase 3 has 4 independent tasks.
213
+ Providers: claude, codex (2 available)
214
+ Strategy: worktree + tmux (parallel)
226
215
 
227
- **Model auto-selection per task complexity:**
228
- | Complexity | Model | When |
229
- |-----------|-------|------|
230
- | Heavy | opus | Architecture, multi-file features, security, auth, database |
231
- | Standard | sonnet | Normal implementation tasks (default) |
232
- | Light | haiku | Config, boilerplate, DTOs, enums, constants, seed data |
216
+ Task 1: Create user schema → claude [worktree-phase-3-task-1]
217
+ Task 2: Add validation helpers → codex [worktree-phase-3-task-2]
218
+ Task 3: Write migration scripts → claude [worktree-phase-3-task-3]
219
+ Task 4: Create seed data → codex [worktree-phase-3-task-4]
233
220
 
234
- Override with `--model sonnet` to force all agents to the same model.
221
+ Launching...
222
+ ```
235
223
 
236
- **Router-aware model selection:**
237
- Before assigning models, check `.tlc.json` for `router.providers` and `router.capabilities`. If the project has a router config, respect it:
238
- - Use configured providers for their assigned capabilities (e.g., Gemini for design tasks)
239
- - Fall back to the complexity table above only when no router config exists
240
- - Run `/tlc:llm status` to see current routing
224
+ Or for single provider:
225
+ ```
226
+ Phase 3 has 4 independent tasks.
227
+ Providers: claude (1 available)
228
+ Strategy: in-process agents (parallel)
241
229
 
242
- **If tasks have dependencies (waterfall):**
230
+ Task 1: Create user schema → opus (heavy)
231
+ Task 2: Add validation helpers → sonnet (standard)
232
+ Task 3: Write migration scripts → sonnet (standard)
233
+ Task 4: Create seed data → haiku (light)
234
+
235
+ Launching...
243
236
  ```
244
- 📋 Sequential Mode
245
237
 
238
+ Or for waterfall:
239
+ ```
246
240
  Phase 3 tasks have dependencies:
247
241
  Task 2 depends on Task 1
248
242
  Task 3 depends on Task 2
249
243
 
250
- Running in sequential order.
244
+ Strategy: sequential
245
+
246
+ Starting Task 1...
251
247
  ```
252
248
 
253
- ### Step 1b: Execute Overdrive (if selected) — Opus 4.6 Multi-Agent
249
+ **Model auto-selection (in-process agent mode):**
250
+ | Complexity | Model | When |
251
+ |-----------|-------|------|
252
+ | Heavy | opus | Architecture, multi-file features, security, auth, database |
253
+ | Standard | sonnet | Normal implementation tasks (default) |
254
+ | Light | haiku | Config, boilerplate, DTOs, enums, constants, seed data |
255
+
256
+ **Provider round-robin (worktree mode):**
257
+ Tasks alternate between available providers. If Claude + Codex are both available, odd tasks go to Claude, even to Codex. Respects router state — never dispatches to unavailable providers.
254
258
 
255
- When overdrive mode is selected, spawn parallel agents with per-task model selection:
259
+ ### Step 1b: Execute Parallel Build
260
+
261
+ **Worktree + Tmux mode** (multi-provider):
256
262
 
257
263
  ```
258
264
  🚀 Launching Overdrive Mode (Opus 4.6)
@@ -338,11 +344,45 @@ Task(resume="AGENT_ID", prompt="Continue from where you left off. Fix any errors
338
344
  - When user asks "check on agents"
339
345
  - After each agent completes
340
346
 
341
- **After all agents complete:**
342
- 1. Run full test suite
347
+ **Before spawning agents (integration branch):**
348
+
349
+ Create an integration branch so all worktrees merge into one place, producing a single clean PR:
350
+
351
+ ```javascript
352
+ const { createIntegrationBranch } = require('./server/lib/orchestration/worktree-manager');
353
+ const { branch } = createIntegrationBranch(phaseNumber, { exec, baseBranch: 'main' });
354
+ // branch = 'phase/42'
355
+ ```
356
+
357
+ All worktrees branch off `phase/{N}`, not `main`. This means each worktree's diff is small and relative to the integration branch, not the entire main history.
358
+
359
+ **After all agents complete — sequential merge-back:**
360
+
361
+ ```javascript
362
+ const { mergeAllWorktrees, listWorktrees } = require('./server/lib/orchestration/worktree-manager');
363
+
364
+ // Filter to only THIS phase's worktrees — don't merge unrelated work
365
+ const allWorktrees = listWorktrees({ exec });
366
+ const worktrees = allWorktrees.filter(wt => wt.name.startsWith(`phase-${phaseNumber}-`));
367
+ const result = mergeAllWorktrees(worktrees, `phase/${phaseNumber}`, { exec });
368
+
369
+ // result.merged = ['task-1', 'task-3', 'task-4'] — successfully merged
370
+ // result.conflicts = ['task-2'] — needs manual resolution
371
+ ```
372
+
373
+ `mergeAllWorktrees` does the following automatically:
374
+ 1. **Analyzes file overlap** — worktrees touching disjoint files merge first
375
+ 2. **Merges one at a time** into `phase/{N}`
376
+ 3. **Rebases remaining worktrees** onto the updated `phase/{N}` after each merge
377
+ 4. **Skips conflicting worktrees** — preserves them for manual resolution, continues with others
378
+ 5. **Cleans up** merged worktrees (removes worktree dir + branch)
379
+
380
+ After merge-back:
381
+ 1. Run full test suite on the integration branch
343
382
  2. Verify all tasks pass
344
- 3. Report results
345
- 4. Continue to Step 8 (verification)
383
+ 3. If conflicts exist, report them with file lists
384
+ 4. If clean, the integration branch is ready for a single PR to main
385
+ 5. Continue to Step 8 (verification)
346
386
 
347
387
  ### Step 1c: Sync and Claim (Multi-User, Sequential Only)
348
388
 
@@ -706,11 +746,17 @@ git diff --name-status main...HEAD
706
746
  1. **Test Coverage** - Every implementation file has a test file
707
747
  2. **TDD Compliance** - Commits show test-first pattern (score ≥ 50%)
708
748
  3. **Security Scan** - No hardcoded secrets, eval(), innerHTML, etc.
709
- 4. **File Size** - No file exceeds 1000 lines (warning at 500+)
710
- 5. **Folder Size** - No folder exceeds 15 files (warning at 8+)
711
- 6. **Strict Typing** - No `any` types in new/changed files
712
- 7. **Return Types** - All exported functions have explicit return types
713
- 8. **Module Structure** - Files grouped by domain entity, not by type
749
+ 4. **Authorization** - Every data-access endpoint has ownership checks, not just auth guards
750
+ 5. **Secrets Exposure** - No API keys, tokens, or passwords returned in responses/HTML
751
+ 6. **Config Hygiene** - No `process.env` outside config module; config validated at startup
752
+ 7. **Output Encoding** - No unescaped `${...}` interpolation in HTML template strings
753
+ 8. **Sensitive Data** - OTPs, reset tokens, session secrets are hashed before storage
754
+ 9. **DI Compliance** - No manual `new Service()` / `new Provider()` in application code
755
+ 10. **File Size** - No file exceeds 1000 lines (warning at 500+)
756
+ 11. **Folder Size** - No folder exceeds 15 files (warning at 8+)
757
+ 12. **Strict Typing** - No `any` types in new/changed files
758
+ 13. **Return Types** - All exported functions have explicit return types
759
+ 14. **Module Structure** - Files grouped by domain entity, not by type
714
760
 
715
761
  **Review output:**
716
762
 
@@ -721,8 +767,11 @@ git diff --name-status main...HEAD
721
767
  Test Coverage: ✅ 5/5 files covered
722
768
  TDD Score: 75% ✅
723
769
  Security: ✅ No issues
770
+ Authorization: ✅ All endpoints have ownership checks
771
+ Secrets Exposure: ✅ No secrets in responses
772
+ Config Hygiene: ✅ No process.env outside config
773
+ Output Encoding: ✅ All HTML output escaped
724
774
  File Sizes: ✅ All under 1000 lines
725
- Folder Sizes: ✅ All under 15 files
726
775
  Strict Typing: ✅ No `any` found
727
776
  Return Types: ✅ All exports typed
728
777
 
@@ -893,10 +942,10 @@ Found: 2-PLAN.md (4 tasks)
893
942
  🚀 Overdrive Mode Available (Opus 4.6)
894
943
 
895
944
  Phase 2 has 4 independent tasks:
896
- - Task 1: Create API routes [sonnet] (standard)
897
- - Task 2: Add input validation [sonnet] (standard)
898
- - Task 3: Write error handlers [sonnet] (standard)
899
- - Task 4: Add rate limiting config [haiku] (light)
945
+ - Task 1: Create API routes [opus]
946
+ - Task 2: Add input validation [opus]
947
+ - Task 3: Write error handlers [opus]
948
+ - Task 4: Add rate limiting config [opus]
900
949
 
901
950
  Recommended: 4 agents (one per task)
902
951
 
@@ -910,17 +959,17 @@ User: 1
910
959
  Claude: 🚀 Launching Overdrive Mode (Opus 4.6)
911
960
 
912
961
  Spawning 4 agents...
913
- [Agent 1] Task 1: Create API routes [sonnet] - STARTED
914
- [Agent 2] Task 2: Add input validation [sonnet] - STARTED
915
- [Agent 3] Task 3: Write error handlers [sonnet] - STARTED
916
- [Agent 4] Task 4: Add rate limiting config [haiku] - STARTED
962
+ [Agent 1] Task 1: Create API routes [opus] - STARTED
963
+ [Agent 2] Task 2: Add input validation [opus] - STARTED
964
+ [Agent 3] Task 3: Write error handlers [opus] - STARTED
965
+ [Agent 4] Task 4: Add rate limiting config [opus] - STARTED
917
966
 
918
967
  ... agents working in background ...
919
968
 
920
- [Agent 4] ✅ Task 4 complete (1 commit) [haiku - fast]
921
- [Agent 2] ✅ Task 2 complete (3 commits) [sonnet]
922
- [Agent 1] ✅ Task 1 complete (4 commits) [sonnet]
923
- [Agent 3] ✅ Task 3 complete (2 commits) [sonnet]
969
+ [Agent 4] ✅ Task 4 complete (1 commit) [opus]
970
+ [Agent 2] ✅ Task 2 complete (3 commits) [opus]
971
+ [Agent 1] ✅ Task 1 complete (4 commits) [opus]
972
+ [Agent 3] ✅ Task 3 complete (2 commits) [opus]
924
973
 
925
974
  All agents complete. Running full test suite...
926
975
  ✅ 24 tests passing
@@ -951,7 +1000,7 @@ Phase 2 complete. Ready for /tlc:verify 2
951
1000
  - Merge conflicts → Agents working on same files (rare if tasks are truly independent)
952
1001
  - One agent failed → Other agents continue; resume failed agent or fix manually
953
1002
  - Want sequential instead → Use `--sequential` flag: `/tlc:build 2 --sequential`
954
- - Cost too high → Use `--model haiku` to force all agents to haiku
1003
+ - Cost too high → Use `--agents 2` to limit parallelism
955
1004
  - Agent running too long → Use `--max-turns 30` to limit execution
956
1005
 
957
1006
  ## Flags
@@ -960,16 +1009,15 @@ Phase 2 complete. Ready for /tlc:verify 2
960
1009
  |------|-------------|
961
1010
  | `--sequential` | Force sequential execution even if tasks are independent |
962
1011
  | `--agents N` | Limit parallel agents to N (default: one per independent task) |
963
- | `--model MODEL` | Force all agents to use a specific model (opus, sonnet, haiku) |
1012
+ | `--model opus` | Force all agents to opus (default all tiers use opus) |
964
1013
  | `--max-turns N` | Limit each agent's execution to N turns (default: 50) |
965
- | `--parallel` | Multi-agent with git worktrees + tmux. Each task gets its own worktree and tmux pane. Claude and Codex work simultaneously. |
966
- | `--parallel --providers claude,codex` | Force specific providers for parallel mode |
967
- | `--parallel --no-tmux` | Parallel worktrees but without tmux visibility (background processes) |
968
- | `--parallel --dry-run` | Preview execution plan: show DAG, task assignments, provider routing |
1014
+ | `--providers claude,codex` | Force specific providers (default: auto-detect from router state) |
1015
+ | `--no-tmux` | Skip tmux panes, run worktree agents in background |
1016
+ | `--dry-run` | Preview execution plan without running (show DAG, task assignments) |
969
1017
 
970
- ## When Overdrive is NOT Used
1018
+ ## When Parallel is NOT Used
971
1019
 
972
- Overdrive auto-detects but won't activate when:
1020
+ Parallel is the default but won't activate when:
973
1021
  - Only 1 task in phase
974
1022
  - All tasks have dependencies (waterfall)
975
1023
  - Tasks modify the same files
@@ -89,6 +89,15 @@ For a phase that's been (partially) built, verify TLC compliance:
89
89
  - [ ] No hardcoded secrets, URLs, or credentials (check for patterns)
90
90
  - [ ] No skipped tests (`.skip`, `xit`, `xdescribe`)
91
91
 
92
+ **Security & Config (CODING-STANDARDS §6, §21, §22):**
93
+ - [ ] Every data-access endpoint has ownership check (not just auth — verify user owns the resource)
94
+ - [ ] No secrets (API keys, tokens, passwords) returned in API responses or rendered in HTML
95
+ - [ ] No `process.env` in services/controllers — all config through validated config module
96
+ - [ ] No unescaped `${...}` interpolation in HTML template strings
97
+ - [ ] OTPs, reset tokens, session secrets are hashed before storage (not plaintext)
98
+ - [ ] No `new ServiceClass()` / `new ProviderClass()` — use DI container
99
+ - [ ] Tests prove user A cannot read/modify user B's data (ownership test)
100
+
92
101
  **Process:**
93
102
  - [ ] Phase plan exists and tasks are checked off
94
103
  - [ ] Implementation matches what was planned (no scope creep)
@@ -207,7 +207,18 @@ Start writing tests now, or save backlog for later?
207
207
 
208
208
  **If "Start now":** Begin writing tests for the first critical path item using Red-Green-Refactor (but code already exists, so focus on capturing current behavior).
209
209
 
210
- ### 9. Create CLAUDE.md
210
+ ### 9. Inject Standards (CLAUDE.md + CODING-STANDARDS.md)
211
+
212
+ **First, inject both standards files using the standards-injector module:**
213
+
214
+ ```javascript
215
+ const { injectStandards } = require('./lib/standards/standards-injector');
216
+ const results = await injectStandards(projectPath);
217
+ // Creates CLAUDE.md and CODING-STANDARDS.md from templates if missing
218
+ // Appends TLC section to existing CLAUDE.md if present
219
+ ```
220
+
221
+ **If the module is not available** (e.g., TLC server not installed locally), create `CLAUDE.md` manually and copy `CODING-STANDARDS.md` from the TLC templates directory.
211
222
 
212
223
  Create `CLAUDE.md` to enforce TLC workflow over Claude's default behaviors:
213
224
 
@@ -116,6 +116,8 @@ git log --oneline --name-status main..HEAD
116
116
 
117
117
  Scan diff for common security issues:
118
118
 
119
+ **Pattern-Based Checks:**
120
+
119
121
  | Pattern | Issue | Severity |
120
122
  |---------|-------|----------|
121
123
  | `password = "..."` | Hardcoded password | HIGH |
@@ -126,6 +128,17 @@ Scan diff for common security issues:
126
128
  | `exec("..." + var)` | Command injection | HIGH |
127
129
  | `SELECT...WHERE...+` | SQL injection | HIGH |
128
130
 
131
+ **Semantic Security Checks (read the code, not just grep):**
132
+
133
+ | Check | What to Look For | Severity |
134
+ |-------|-----------------|----------|
135
+ | **Ownership/IDOR** | Controller methods that take an ID param (`req.params.id`, `@Param('id')`) and query data without checking the requesting user owns the resource. Every data-access endpoint MUST verify ownership, not just authentication. | HIGH |
136
+ | **Secrets in responses** | Response objects, DTOs, or `res.json()`/`res.send()` calls that include fields like `apiKey`, `secret`, `token`, `password`, `webhookSecret`. Secrets are write-only — never return them. | HIGH |
137
+ | **Direct `process.env`** | `process.env.` usage in service, controller, or middleware files. All env access MUST go through a validated config module. Grep: `process\.env\.` in non-config files. | MEDIUM |
138
+ | **Unescaped HTML** | Template literals that build HTML with `${...}` interpolation of variables (e.g., `` `<h1>${user.name}</h1>` ``). All dynamic values in HTML MUST be escaped. | HIGH |
139
+ | **Plaintext sensitive data** | OTP codes, reset tokens, or session secrets stored without hashing. Look for database inserts/updates of these values without a hash step. | HIGH |
140
+ | **Manual instantiation** | `new SomeProvider(...)` or `new SomeService(...)` in application code instead of using DI. | MEDIUM |
141
+
129
142
  **Fail if:** Any HIGH severity issues found.
130
143
 
131
144
  ### Step 5b: Coding Standards Check
@@ -311,6 +324,12 @@ After Steps 2-6 complete, if ANY issues were found:
311
324
  | `any` type | Replace with proper interface | If domain type unclear |
312
325
  | File >1000 lines | Split into sub-modules | If split strategy unclear |
313
326
  | Security vulnerability | Patch it | If fix might break behavior |
327
+ | Missing ownership check | Add guard/check | If ownership model unclear |
328
+ | Secrets in response | Remove or mask fields | If field is needed by client |
329
+ | Direct `process.env` | Move to config module | If config module doesn't exist yet |
330
+ | Unescaped HTML | Add escapeHtml() | If templating engine preferred |
331
+ | Plaintext sensitive data | Add hash step | - |
332
+ | Manual `new Service()` | Convert to DI | If DI container not set up |
314
333
  | Codex-flagged bug | Apply suggestion | If suggestion conflicts with Claude |
315
334
  | Merge conflict | - | Always human |
316
335