sdtk-code-kit 0.1.3 → 0.2.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.
- package/README.md +202 -185
- package/assets/manifest/toolkit-bundle.manifest.json +49 -49
- package/assets/manifest/toolkit-bundle.sha256.txt +24 -24
- package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +78 -78
- package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +150 -150
- package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +62 -62
- package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +82 -82
- package/assets/toolkit/toolkit/sdtk-spec.config.profiles.example.json +12 -12
- package/assets/toolkit/toolkit/skills/code-brainstorm/SKILL.md +55 -55
- package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +1 -1
- package/assets/toolkit/toolkit/skills/code-debug/references/root-cause-tracing.md +68 -68
- package/assets/toolkit/toolkit/skills/code-execute/SKILL.md +74 -74
- package/assets/toolkit/toolkit/skills/code-finish/SKILL.md +205 -205
- package/assets/toolkit/toolkit/skills/code-parallel/SKILL.md +64 -64
- package/assets/toolkit/toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md +26 -26
- package/assets/toolkit/toolkit/skills/code-parallel/references/implementer-prompt.md +113 -113
- package/assets/toolkit/toolkit/skills/code-parallel/references/spec-reviewer-prompt.md +61 -61
- package/assets/toolkit/toolkit/skills/code-plan/SKILL.md +85 -85
- package/assets/toolkit/toolkit/skills/code-review/SKILL.md +79 -79
- package/assets/toolkit/toolkit/skills/code-review/references/checklist.md +125 -125
- package/assets/toolkit/toolkit/skills/code-review/references/code-reviewer.md +146 -146
- package/assets/toolkit/toolkit/skills/code-ship/SKILL.md +52 -52
- package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +1 -1
- package/assets/toolkit/toolkit/skills/code-tdd/references/testing-anti-patterns.md +299 -299
- package/assets/toolkit/toolkit/skills/code-verify/SKILL.md +144 -144
- package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +13 -13
- package/assets/toolkit/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md +140 -112
- package/bin/sdtk-code.js +14 -14
- package/package.json +4 -4
- package/src/commands/build.js +53 -53
- package/src/commands/doctor.js +52 -0
- package/src/commands/generate.js +11 -11
- package/src/commands/guardrails.js +123 -0
- package/src/commands/help.js +28 -4
- package/src/commands/plan.js +53 -53
- package/src/commands/readiness.js +77 -0
- package/src/commands/resume.js +62 -0
- package/src/commands/runtime.js +224 -224
- package/src/commands/ship.js +59 -59
- package/src/commands/start.js +89 -89
- package/src/commands/status.js +78 -0
- package/src/commands/verify.js +71 -66
- package/src/index.js +32 -1
- package/src/lib/args.js +107 -107
- package/src/lib/errors.js +41 -41
- package/src/lib/powershell.js +65 -65
- package/src/lib/scope.js +72 -72
- package/src/lib/ship-readiness.js +281 -0
- package/src/lib/toolkit-payload.js +72 -72
- package/src/lib/trust-events.js +166 -0
- package/src/lib/trust-file-scope.js +154 -0
- package/src/lib/trust-policy.js +212 -0
- package/src/lib/trust-redact.js +35 -0
- package/src/lib/trust-trace.js +179 -0
- package/src/lib/workflow-artifact.js +503 -496
- package/src/lib/workflow-build.js +127 -127
- package/src/lib/workflow-doctor.js +84 -0
- package/src/lib/workflow-handoff.js +1029 -937
- package/src/lib/workflow-intake.js +101 -101
- package/src/lib/workflow-plan.js +193 -193
- package/src/lib/workflow-review-packet.js +89 -0
- package/src/lib/workflow-ship.js +213 -213
- package/src/lib/workflow-state.js +439 -0
- package/src/lib/workflow-verify.js +43 -6
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[ValidateSet('project', 'user')]
|
|
3
|
-
[string]$Scope = 'user',
|
|
4
|
-
[string]$ProjectPath,
|
|
5
|
-
[switch]$All,
|
|
6
|
-
[switch]$Quiet
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
$ErrorActionPreference = 'Stop'
|
|
10
|
-
Set-StrictMode -Version Latest
|
|
11
|
-
|
|
12
|
-
function Resolve-CodexHome {
|
|
13
|
-
param(
|
|
14
|
-
[Parameter(Mandatory = $true)][string]$TargetScope,
|
|
15
|
-
[string]$TargetProjectPath
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
if ($TargetScope -eq 'project') {
|
|
19
|
-
if (-not $TargetProjectPath -or $TargetProjectPath.Trim().Length -eq 0) {
|
|
20
|
-
throw "Project-local Codex uninstall requires -ProjectPath."
|
|
21
|
-
}
|
|
22
|
-
if (-not (Test-Path -LiteralPath $TargetProjectPath)) {
|
|
23
|
-
New-Item -ItemType Directory -Force -Path $TargetProjectPath | Out-Null
|
|
24
|
-
}
|
|
25
|
-
$projectRoot = (Resolve-Path -LiteralPath $TargetProjectPath).Path
|
|
26
|
-
return (Join-Path $projectRoot '.codex')
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if ($env:CODEX_HOME) {
|
|
30
|
-
return $env:CODEX_HOME
|
|
31
|
-
}
|
|
32
|
-
return (Join-Path $HOME '.codex')
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
$toolkitRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
|
36
|
-
$skillsSource = Join-Path $toolkitRoot 'skills'
|
|
37
|
-
if (-not (Test-Path -LiteralPath $skillsSource)) {
|
|
38
|
-
throw "Missing toolkit skills source directory: $skillsSource"
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
$managedSkillNames = @(
|
|
42
|
-
Get-ChildItem -LiteralPath $skillsSource -Directory |
|
|
43
|
-
Sort-Object Name |
|
|
44
|
-
ForEach-Object { "sdtk-$($_.Name)" }
|
|
45
|
-
)
|
|
46
|
-
if ($managedSkillNames.Count -ne 12) {
|
|
47
|
-
throw "Expected 12 managed SDTK-CODE skills but found $($managedSkillNames.Count)."
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
$codexHome = Resolve-CodexHome -TargetScope $Scope -TargetProjectPath $ProjectPath
|
|
51
|
-
$skillsDest = Join-Path $codexHome 'skills'
|
|
52
|
-
if (-not (Test-Path -LiteralPath $skillsDest)) {
|
|
53
|
-
if (-not $Quiet) {
|
|
54
|
-
Write-Host "Codex skills directory not found: $skillsDest"
|
|
55
|
-
}
|
|
56
|
-
exit 0
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
$removed = New-Object System.Collections.Generic.List[string]
|
|
60
|
-
$missing = New-Object System.Collections.Generic.List[string]
|
|
61
|
-
foreach ($name in $managedSkillNames) {
|
|
62
|
-
$dest = Join-Path $skillsDest $name
|
|
63
|
-
if (-not (Test-Path -LiteralPath $dest)) {
|
|
64
|
-
$missing.Add($name) | Out-Null
|
|
65
|
-
continue
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
Remove-Item -LiteralPath $dest -Recurse -Force
|
|
69
|
-
$removed.Add($name) | Out-Null
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (-not $Quiet) {
|
|
73
|
-
Write-Host ""
|
|
74
|
-
Write-Host "Uninstall summary:"
|
|
75
|
-
Write-Host "- Scope: $Scope"
|
|
76
|
-
Write-Host "- Destination: $skillsDest"
|
|
77
|
-
Write-Host "- Removed: $($removed.Count)"
|
|
78
|
-
Write-Host "- Missing/Skipped: $($missing.Count)"
|
|
79
|
-
if ($Scope -eq 'project') {
|
|
80
|
-
Write-Host "- Project-local Codex uninstall touched only SDTK-CODE-managed assets under <project>/.codex/skills."
|
|
81
|
-
}
|
|
82
|
-
}
|
|
1
|
+
param(
|
|
2
|
+
[ValidateSet('project', 'user')]
|
|
3
|
+
[string]$Scope = 'user',
|
|
4
|
+
[string]$ProjectPath,
|
|
5
|
+
[switch]$All,
|
|
6
|
+
[switch]$Quiet
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
$ErrorActionPreference = 'Stop'
|
|
10
|
+
Set-StrictMode -Version Latest
|
|
11
|
+
|
|
12
|
+
function Resolve-CodexHome {
|
|
13
|
+
param(
|
|
14
|
+
[Parameter(Mandatory = $true)][string]$TargetScope,
|
|
15
|
+
[string]$TargetProjectPath
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
if ($TargetScope -eq 'project') {
|
|
19
|
+
if (-not $TargetProjectPath -or $TargetProjectPath.Trim().Length -eq 0) {
|
|
20
|
+
throw "Project-local Codex uninstall requires -ProjectPath."
|
|
21
|
+
}
|
|
22
|
+
if (-not (Test-Path -LiteralPath $TargetProjectPath)) {
|
|
23
|
+
New-Item -ItemType Directory -Force -Path $TargetProjectPath | Out-Null
|
|
24
|
+
}
|
|
25
|
+
$projectRoot = (Resolve-Path -LiteralPath $TargetProjectPath).Path
|
|
26
|
+
return (Join-Path $projectRoot '.codex')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if ($env:CODEX_HOME) {
|
|
30
|
+
return $env:CODEX_HOME
|
|
31
|
+
}
|
|
32
|
+
return (Join-Path $HOME '.codex')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
$toolkitRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
|
36
|
+
$skillsSource = Join-Path $toolkitRoot 'skills'
|
|
37
|
+
if (-not (Test-Path -LiteralPath $skillsSource)) {
|
|
38
|
+
throw "Missing toolkit skills source directory: $skillsSource"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
$managedSkillNames = @(
|
|
42
|
+
Get-ChildItem -LiteralPath $skillsSource -Directory |
|
|
43
|
+
Sort-Object Name |
|
|
44
|
+
ForEach-Object { "sdtk-$($_.Name)" }
|
|
45
|
+
)
|
|
46
|
+
if ($managedSkillNames.Count -ne 12) {
|
|
47
|
+
throw "Expected 12 managed SDTK-CODE skills but found $($managedSkillNames.Count)."
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
$codexHome = Resolve-CodexHome -TargetScope $Scope -TargetProjectPath $ProjectPath
|
|
51
|
+
$skillsDest = Join-Path $codexHome 'skills'
|
|
52
|
+
if (-not (Test-Path -LiteralPath $skillsDest)) {
|
|
53
|
+
if (-not $Quiet) {
|
|
54
|
+
Write-Host "Codex skills directory not found: $skillsDest"
|
|
55
|
+
}
|
|
56
|
+
exit 0
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
$removed = New-Object System.Collections.Generic.List[string]
|
|
60
|
+
$missing = New-Object System.Collections.Generic.List[string]
|
|
61
|
+
foreach ($name in $managedSkillNames) {
|
|
62
|
+
$dest = Join-Path $skillsDest $name
|
|
63
|
+
if (-not (Test-Path -LiteralPath $dest)) {
|
|
64
|
+
$missing.Add($name) | Out-Null
|
|
65
|
+
continue
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Remove-Item -LiteralPath $dest -Recurse -Force
|
|
69
|
+
$removed.Add($name) | Out-Null
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (-not $Quiet) {
|
|
73
|
+
Write-Host ""
|
|
74
|
+
Write-Host "Uninstall summary:"
|
|
75
|
+
Write-Host "- Scope: $Scope"
|
|
76
|
+
Write-Host "- Destination: $skillsDest"
|
|
77
|
+
Write-Host "- Removed: $($removed.Count)"
|
|
78
|
+
Write-Host "- Missing/Skipped: $($missing.Count)"
|
|
79
|
+
if ($Scope -eq 'project') {
|
|
80
|
+
Write-Host "- Project-local Codex uninstall touched only SDTK-CODE-managed assets under <project>/.codex/skills."
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$comment": "SCAFFOLD: Example profiles config for SDTKCODE. Copy to sdtk-spec.config.profiles.json and customize.",
|
|
3
|
-
"profiles": {
|
|
4
|
-
"default": {
|
|
5
|
-
"stack": {
|
|
6
|
-
"backend": "UPDATE_ME",
|
|
7
|
-
"frontend": "UPDATE_ME",
|
|
8
|
-
"database": "UPDATE_ME"
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$comment": "SCAFFOLD: Example profiles config for SDTKCODE. Copy to sdtk-spec.config.profiles.json and customize.",
|
|
3
|
+
"profiles": {
|
|
4
|
+
"default": {
|
|
5
|
+
"stack": {
|
|
6
|
+
"backend": "UPDATE_ME",
|
|
7
|
+
"frontend": "UPDATE_ME",
|
|
8
|
+
"database": "UPDATE_ME"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: code-brainstorm
|
|
3
|
-
description: Brainstorming designs before code. Use before any creative work -- creating features, building components, modifying behavior. Explores intent, requirements, and design before implementation.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Code Brainstorm
|
|
7
|
-
|
|
8
|
-
## Critical Constraints
|
|
9
|
-
- I do not take implementation action before presenting a design and getting approval.
|
|
10
|
-
- I do not treat "simple" requests as justification to skip design.
|
|
11
|
-
|
|
12
|
-
<HARD-GATE>
|
|
13
|
-
Do NOT invoke any implementation skill, write any code, scaffold any project, or take any implementation action until you have presented a design and the user has approved it. This applies to EVERY project regardless of perceived simplicity.
|
|
14
|
-
</HARD-GATE>
|
|
15
|
-
|
|
16
|
-
## Overview
|
|
17
|
-
Explore coding approaches before writing code.
|
|
18
|
-
|
|
19
|
-
The outcome is an approved design direction that can be handed to `code-plan`.
|
|
20
|
-
|
|
21
|
-
## Process
|
|
22
|
-
1. Read the current codebase context, recent changes, and relevant requirements.
|
|
23
|
-
2. Ask clarifying questions one at a time.
|
|
24
|
-
3. Propose 2-3 approaches with tradeoffs and a recommendation.
|
|
25
|
-
4. Present the design in sections sized to the problem complexity.
|
|
26
|
-
5. Record assumptions and open questions.
|
|
27
|
-
6. Get approval on the design direction.
|
|
28
|
-
7. Hand off to `code-plan`.
|
|
29
|
-
|
|
30
|
-
## Process Flow
|
|
31
|
-
```dot
|
|
32
|
-
digraph brainstorming {
|
|
33
|
-
"Explore project context" [shape=box];
|
|
34
|
-
"Ask clarifying questions" [shape=box];
|
|
35
|
-
"Propose 2-3 approaches" [shape=box];
|
|
36
|
-
"Present design sections" [shape=box];
|
|
37
|
-
"User approves design?" [shape=diamond];
|
|
38
|
-
"Revise design" [shape=box];
|
|
39
|
-
"Invoke code-plan" [shape=doublecircle];
|
|
40
|
-
|
|
41
|
-
"Explore project context" -> "Ask clarifying questions";
|
|
42
|
-
"Ask clarifying questions" -> "Propose 2-3 approaches";
|
|
43
|
-
"Propose 2-3 approaches" -> "Present design sections";
|
|
44
|
-
"Present design sections" -> "User approves design?";
|
|
45
|
-
"User approves design?" -> "Revise design" [label="no"];
|
|
46
|
-
"Revise design" -> "Present design sections";
|
|
47
|
-
"User approves design?" -> "Invoke code-plan" [label="yes"];
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Red Flags
|
|
52
|
-
- Starting code because the request looks small.
|
|
53
|
-
- Asking multiple unrelated questions in one turn.
|
|
54
|
-
- Offering only one approach when there are real tradeoffs.
|
|
55
|
-
- Moving to implementation before the design is approved.
|
|
1
|
+
---
|
|
2
|
+
name: code-brainstorm
|
|
3
|
+
description: Brainstorming designs before code. Use before any creative work -- creating features, building components, modifying behavior. Explores intent, requirements, and design before implementation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Brainstorm
|
|
7
|
+
|
|
8
|
+
## Critical Constraints
|
|
9
|
+
- I do not take implementation action before presenting a design and getting approval.
|
|
10
|
+
- I do not treat "simple" requests as justification to skip design.
|
|
11
|
+
|
|
12
|
+
<HARD-GATE>
|
|
13
|
+
Do NOT invoke any implementation skill, write any code, scaffold any project, or take any implementation action until you have presented a design and the user has approved it. This applies to EVERY project regardless of perceived simplicity.
|
|
14
|
+
</HARD-GATE>
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
Explore coding approaches before writing code.
|
|
18
|
+
|
|
19
|
+
The outcome is an approved design direction that can be handed to `code-plan`.
|
|
20
|
+
|
|
21
|
+
## Process
|
|
22
|
+
1. Read the current codebase context, recent changes, and relevant requirements.
|
|
23
|
+
2. Ask clarifying questions one at a time.
|
|
24
|
+
3. Propose 2-3 approaches with tradeoffs and a recommendation.
|
|
25
|
+
4. Present the design in sections sized to the problem complexity.
|
|
26
|
+
5. Record assumptions and open questions.
|
|
27
|
+
6. Get approval on the design direction.
|
|
28
|
+
7. Hand off to `code-plan`.
|
|
29
|
+
|
|
30
|
+
## Process Flow
|
|
31
|
+
```dot
|
|
32
|
+
digraph brainstorming {
|
|
33
|
+
"Explore project context" [shape=box];
|
|
34
|
+
"Ask clarifying questions" [shape=box];
|
|
35
|
+
"Propose 2-3 approaches" [shape=box];
|
|
36
|
+
"Present design sections" [shape=box];
|
|
37
|
+
"User approves design?" [shape=diamond];
|
|
38
|
+
"Revise design" [shape=box];
|
|
39
|
+
"Invoke code-plan" [shape=doublecircle];
|
|
40
|
+
|
|
41
|
+
"Explore project context" -> "Ask clarifying questions";
|
|
42
|
+
"Ask clarifying questions" -> "Propose 2-3 approaches";
|
|
43
|
+
"Propose 2-3 approaches" -> "Present design sections";
|
|
44
|
+
"Present design sections" -> "User approves design?";
|
|
45
|
+
"User approves design?" -> "Revise design" [label="no"];
|
|
46
|
+
"Revise design" -> "Present design sections";
|
|
47
|
+
"User approves design?" -> "Invoke code-plan" [label="yes"];
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Red Flags
|
|
52
|
+
- Starting code because the request looks small.
|
|
53
|
+
- Asking multiple unrelated questions in one turn.
|
|
54
|
+
- Offering only one approach when there are real tradeoffs.
|
|
55
|
+
- Moving to implementation before the design is approved.
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
# Root Cause Tracing
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Bugs often manifest deep in the call stack (git init in wrong directory, file created in wrong location, database opened with wrong path). Your instinct is to fix where the error appears, but that's treating a symptom.
|
|
6
|
-
|
|
7
|
-
**Core principle:** Trace backward through the call chain until you find the original trigger, then fix at the source.
|
|
8
|
-
|
|
9
|
-
## When to Use
|
|
10
|
-
|
|
11
|
-
```dot
|
|
12
|
-
digraph when_to_use {
|
|
13
|
-
"Bug appears deep in stack?" [shape=diamond];
|
|
14
|
-
"Can trace backwards?" [shape=diamond];
|
|
15
|
-
"Fix at symptom point" [shape=box];
|
|
16
|
-
"Trace to original trigger" [shape=box];
|
|
17
|
-
"Add validation at the source and boundary checks" [shape=box];
|
|
18
|
-
|
|
19
|
-
"Bug appears deep in stack?" -> "Can trace backwards?" [label="yes"];
|
|
20
|
-
"Can trace backwards?" -> "Trace to original trigger" [label="yes"];
|
|
21
|
-
"Can trace backwards?" -> "Fix at symptom point" [label="no - dead end"];
|
|
22
|
-
"Trace to original trigger" -> "Add validation at the source and boundary checks";
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**Use when:**
|
|
27
|
-
- Error happens deep in execution (not at entry point)
|
|
28
|
-
- Stack trace shows long call chain
|
|
29
|
-
- Unclear where invalid data originated
|
|
30
|
-
- Need to find which test/code triggers the problem
|
|
31
|
-
|
|
32
|
-
## The Tracing Process
|
|
33
|
-
|
|
34
|
-
### 1. Observe the Symptom
|
|
35
|
-
```
|
|
36
|
-
Error: git init failed in /Users/jesse/project/packages/core
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### 2. Find Immediate Cause
|
|
40
|
-
**What code directly causes this?**
|
|
41
|
-
```typescript
|
|
42
|
-
await execFileAsync('git', ['init'], { cwd: projectDir });
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### 3. Ask: What Called This?
|
|
46
|
-
```typescript
|
|
47
|
-
WorktreeManager.createSessionWorktree(projectDir, sessionId)
|
|
48
|
-
-> called by Session.initializeWorkspace()
|
|
49
|
-
-> called by Session.create()
|
|
50
|
-
-> called by test at Project.create()
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 4. Keep Tracing Up
|
|
54
|
-
**What value was passed?**
|
|
55
|
-
- `projectDir = ''` (empty string!)
|
|
56
|
-
- Empty string as `cwd` resolves to `process.cwd()`
|
|
57
|
-
- That's the source code directory!
|
|
58
|
-
|
|
59
|
-
### 5. Find Original Trigger
|
|
60
|
-
**Where did empty string come from?**
|
|
61
|
-
```typescript
|
|
62
|
-
const context = setupCoreTest(); // Returns { tempDir: '' }
|
|
63
|
-
Project.create('name', context.tempDir); // Accessed before beforeEach!
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Adding Stack Traces
|
|
67
|
-
|
|
68
|
-
Capture stack context before the dangerous operation, then trace the call chain backward to the original trigger.
|
|
1
|
+
# Root Cause Tracing
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Bugs often manifest deep in the call stack (git init in wrong directory, file created in wrong location, database opened with wrong path). Your instinct is to fix where the error appears, but that's treating a symptom.
|
|
6
|
+
|
|
7
|
+
**Core principle:** Trace backward through the call chain until you find the original trigger, then fix at the source.
|
|
8
|
+
|
|
9
|
+
## When to Use
|
|
10
|
+
|
|
11
|
+
```dot
|
|
12
|
+
digraph when_to_use {
|
|
13
|
+
"Bug appears deep in stack?" [shape=diamond];
|
|
14
|
+
"Can trace backwards?" [shape=diamond];
|
|
15
|
+
"Fix at symptom point" [shape=box];
|
|
16
|
+
"Trace to original trigger" [shape=box];
|
|
17
|
+
"Add validation at the source and boundary checks" [shape=box];
|
|
18
|
+
|
|
19
|
+
"Bug appears deep in stack?" -> "Can trace backwards?" [label="yes"];
|
|
20
|
+
"Can trace backwards?" -> "Trace to original trigger" [label="yes"];
|
|
21
|
+
"Can trace backwards?" -> "Fix at symptom point" [label="no - dead end"];
|
|
22
|
+
"Trace to original trigger" -> "Add validation at the source and boundary checks";
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Use when:**
|
|
27
|
+
- Error happens deep in execution (not at entry point)
|
|
28
|
+
- Stack trace shows long call chain
|
|
29
|
+
- Unclear where invalid data originated
|
|
30
|
+
- Need to find which test/code triggers the problem
|
|
31
|
+
|
|
32
|
+
## The Tracing Process
|
|
33
|
+
|
|
34
|
+
### 1. Observe the Symptom
|
|
35
|
+
```
|
|
36
|
+
Error: git init failed in /Users/jesse/project/packages/core
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. Find Immediate Cause
|
|
40
|
+
**What code directly causes this?**
|
|
41
|
+
```typescript
|
|
42
|
+
await execFileAsync('git', ['init'], { cwd: projectDir });
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 3. Ask: What Called This?
|
|
46
|
+
```typescript
|
|
47
|
+
WorktreeManager.createSessionWorktree(projectDir, sessionId)
|
|
48
|
+
-> called by Session.initializeWorkspace()
|
|
49
|
+
-> called by Session.create()
|
|
50
|
+
-> called by test at Project.create()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 4. Keep Tracing Up
|
|
54
|
+
**What value was passed?**
|
|
55
|
+
- `projectDir = ''` (empty string!)
|
|
56
|
+
- Empty string as `cwd` resolves to `process.cwd()`
|
|
57
|
+
- That's the source code directory!
|
|
58
|
+
|
|
59
|
+
### 5. Find Original Trigger
|
|
60
|
+
**Where did empty string come from?**
|
|
61
|
+
```typescript
|
|
62
|
+
const context = setupCoreTest(); // Returns { tempDir: '' }
|
|
63
|
+
Project.create('name', context.tempDir); // Accessed before beforeEach!
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Adding Stack Traces
|
|
67
|
+
|
|
68
|
+
Capture stack context before the dangerous operation, then trace the call chain backward to the original trigger.
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: code-execute
|
|
3
|
-
description: Executing implementation plans. Use when you have a written plan and need to execute it step by step with review checkpoints.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Code Execute
|
|
7
|
-
|
|
8
|
-
## Critical Constraints
|
|
9
|
-
- I do not skip ahead of the written plan or silently change task order.
|
|
10
|
-
- I do not continue after a failed checkpoint without recording the issue and correcting course.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Overview
|
|
14
|
-
|
|
15
|
-
Load the approved implementation plan, review it critically, execute tasks in order, and stop whenever checkpoints fail.
|
|
16
|
-
|
|
17
|
-
**Announce at start:** "I'm using the code-execute skill to implement this plan."
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## Process
|
|
21
|
-
|
|
22
|
-
### Step 1: Load and Review Plan
|
|
23
|
-
1. Read plan file
|
|
24
|
-
2. Review critically - identify any questions or concerns about the plan
|
|
25
|
-
3. If concerns: Raise them with the user before starting
|
|
26
|
-
4. If no concerns: create a task list and proceed
|
|
27
|
-
|
|
28
|
-
### Step 2: Execute Tasks
|
|
29
|
-
|
|
30
|
-
For each task:
|
|
31
|
-
1. Mark as in_progress
|
|
32
|
-
2. Follow each step exactly (plan has bite-sized steps)
|
|
33
|
-
3. Run verifications as specified
|
|
34
|
-
4. Mark as completed
|
|
35
|
-
|
|
36
|
-
### Step 3: Complete Development
|
|
37
|
-
|
|
38
|
-
After all tasks complete and verified:
|
|
39
|
-
- Announce: "I'm using the code-finish skill to complete this work."
|
|
40
|
-
- **REQUIRED SUB-SKILL:** Use code-finish
|
|
41
|
-
- Follow that skill to verify tests, present options, execute choice
|
|
42
|
-
|
|
43
|
-
## When to Stop and Ask for Help
|
|
44
|
-
|
|
45
|
-
**STOP executing immediately when:**
|
|
46
|
-
- Hit a blocker (missing dependency, test fails, instruction unclear)
|
|
47
|
-
- Plan has critical gaps preventing starting
|
|
48
|
-
- You don't understand an instruction
|
|
49
|
-
- Verification fails repeatedly
|
|
50
|
-
|
|
51
|
-
**Ask for clarification rather than guessing.**
|
|
52
|
-
|
|
53
|
-
## When to Revisit Earlier Steps
|
|
54
|
-
|
|
55
|
-
**Return to Review (Step 1) when:**
|
|
56
|
-
- Partner updates the plan based on your feedback
|
|
57
|
-
- Fundamental approach needs rethinking
|
|
58
|
-
|
|
59
|
-
**Don't force through blockers** - stop and ask.
|
|
60
|
-
|
|
61
|
-
## Remember
|
|
62
|
-
- Review plan critically first
|
|
63
|
-
- Follow plan steps exactly
|
|
64
|
-
- Don't skip verifications
|
|
65
|
-
- Reference skills when plan says to
|
|
66
|
-
- Stop when blocked, don't guess
|
|
67
|
-
- Never start implementation on main/master branch without explicit user consent
|
|
68
|
-
|
|
69
|
-
## Integration
|
|
70
|
-
|
|
71
|
-
**Required workflow skills:**
|
|
72
|
-
- **code-worktree** - Set up an isolated workspace before starting when the work should not happen in the current tree.
|
|
73
|
-
- **code-plan** - Creates the plan this skill executes
|
|
74
|
-
- **code-finish** - Complete development after all tasks
|
|
1
|
+
---
|
|
2
|
+
name: code-execute
|
|
3
|
+
description: Executing implementation plans. Use when you have a written plan and need to execute it step by step with review checkpoints.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Execute
|
|
7
|
+
|
|
8
|
+
## Critical Constraints
|
|
9
|
+
- I do not skip ahead of the written plan or silently change task order.
|
|
10
|
+
- I do not continue after a failed checkpoint without recording the issue and correcting course.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Load the approved implementation plan, review it critically, execute tasks in order, and stop whenever checkpoints fail.
|
|
16
|
+
|
|
17
|
+
**Announce at start:** "I'm using the code-execute skill to implement this plan."
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Process
|
|
21
|
+
|
|
22
|
+
### Step 1: Load and Review Plan
|
|
23
|
+
1. Read plan file
|
|
24
|
+
2. Review critically - identify any questions or concerns about the plan
|
|
25
|
+
3. If concerns: Raise them with the user before starting
|
|
26
|
+
4. If no concerns: create a task list and proceed
|
|
27
|
+
|
|
28
|
+
### Step 2: Execute Tasks
|
|
29
|
+
|
|
30
|
+
For each task:
|
|
31
|
+
1. Mark as in_progress
|
|
32
|
+
2. Follow each step exactly (plan has bite-sized steps)
|
|
33
|
+
3. Run verifications as specified
|
|
34
|
+
4. Mark as completed
|
|
35
|
+
|
|
36
|
+
### Step 3: Complete Development
|
|
37
|
+
|
|
38
|
+
After all tasks complete and verified:
|
|
39
|
+
- Announce: "I'm using the code-finish skill to complete this work."
|
|
40
|
+
- **REQUIRED SUB-SKILL:** Use code-finish
|
|
41
|
+
- Follow that skill to verify tests, present options, execute choice
|
|
42
|
+
|
|
43
|
+
## When to Stop and Ask for Help
|
|
44
|
+
|
|
45
|
+
**STOP executing immediately when:**
|
|
46
|
+
- Hit a blocker (missing dependency, test fails, instruction unclear)
|
|
47
|
+
- Plan has critical gaps preventing starting
|
|
48
|
+
- You don't understand an instruction
|
|
49
|
+
- Verification fails repeatedly
|
|
50
|
+
|
|
51
|
+
**Ask for clarification rather than guessing.**
|
|
52
|
+
|
|
53
|
+
## When to Revisit Earlier Steps
|
|
54
|
+
|
|
55
|
+
**Return to Review (Step 1) when:**
|
|
56
|
+
- Partner updates the plan based on your feedback
|
|
57
|
+
- Fundamental approach needs rethinking
|
|
58
|
+
|
|
59
|
+
**Don't force through blockers** - stop and ask.
|
|
60
|
+
|
|
61
|
+
## Remember
|
|
62
|
+
- Review plan critically first
|
|
63
|
+
- Follow plan steps exactly
|
|
64
|
+
- Don't skip verifications
|
|
65
|
+
- Reference skills when plan says to
|
|
66
|
+
- Stop when blocked, don't guess
|
|
67
|
+
- Never start implementation on main/master branch without explicit user consent
|
|
68
|
+
|
|
69
|
+
## Integration
|
|
70
|
+
|
|
71
|
+
**Required workflow skills:**
|
|
72
|
+
- **code-worktree** - Set up an isolated workspace before starting when the work should not happen in the current tree.
|
|
73
|
+
- **code-plan** - Creates the plan this skill executes
|
|
74
|
+
- **code-finish** - Complete development after all tasks
|