@torka/claude-qol 0.1.2 → 0.2.1
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/.claude-plugin/plugin.json +14 -3
- package/hooks/auto_approve_safe.rules.json +34 -6
- package/install.js +33 -3
- package/package.json +2 -1
- package/skills/nash/OPUS-ANALYSIS-PROMPT.md +204 -0
- package/skills/nash/SKILL.md +400 -0
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@torka/claude-qol",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Claude Code quality-of-life improvements: auto-approve hooks and
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Claude Code quality-of-life improvements: auto-approve hooks, context monitoring, and workflow optimization",
|
|
5
|
+
"commands": [
|
|
6
|
+
{
|
|
7
|
+
"name": "optimize-auto-approve-hook",
|
|
8
|
+
"description": "Analyze auto-approve decisions to identify safe patterns for auto-allowing and validate existing rules"
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"skills": [
|
|
12
|
+
{
|
|
13
|
+
"name": "nash",
|
|
14
|
+
"description": "Workflow optimization loop that reviews Claude Code session transcripts to extract learnings and improve workflows"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
6
17
|
}
|
|
@@ -27,12 +27,21 @@
|
|
|
27
27
|
"^uv\\s+--version$",
|
|
28
28
|
|
|
29
29
|
"^git\\s+(status|diff|log|show|branch|remote|stash\\s+list)(\\s+.*)?$",
|
|
30
|
+
"^git\\s+-C\\s+[^|;&]+\\s+(status|diff|log|show|branch)(\\s+.*)?$",
|
|
31
|
+
"^git\\s+-C\\s+[^|;&]+\\s+(add|commit|checkout|fetch|pull|push)(\\s+.*)?$",
|
|
32
|
+
"^git\\s+rm\\s+[^|;&]+$",
|
|
30
33
|
|
|
31
34
|
"^pnpm\\s+(test|run\\s+(test|lint|typecheck|type-check|check|build|dev|start)|install|i|add|remove)(\\s+.*)?$",
|
|
32
|
-
"^npm\\s+(test|run\\s+(test|lint|typecheck|type-check|check|build|dev|start)|install|i|ci)(\\s+.*)?$",
|
|
35
|
+
"^npm\\s+(test|run\\s+(test|lint|lint:fix|typecheck|type-check|check|check-types|build|dev|dev:next|start)|install|i|ci)(\\s+.*)?$",
|
|
36
|
+
"^npm\\s+whoami$",
|
|
37
|
+
"^npm\\s+list(\\s+(-g|--global))?(\\s+[\\w@/-]+)?$",
|
|
38
|
+
"^npm\\s+ls(\\s+[\\w@/-]+)*$",
|
|
39
|
+
"^npm\\s+view\\s+[\\w@/-]+(\\s+.*)?$",
|
|
40
|
+
"^npm\\s+pack\\s+[\\w@/-]+\\s+--dry-run",
|
|
33
41
|
"^yarn\\s+(test|lint|typecheck|type-check|check|build|dev|start|install|add|remove)(\\s+.*)?$",
|
|
34
42
|
"^npx\\s+(tsc|eslint|prettier|vitest|jest)(\\s+.*)?$",
|
|
35
43
|
"^npx\\s+tsx\\s+[^|;&]+$",
|
|
44
|
+
"^npx\\s+shadcn@latest\\s+(add|init)(\\s+[\\w@/-]+)*(\\s+--yes)?$",
|
|
36
45
|
|
|
37
46
|
"^pytest(\\s+.*)?$",
|
|
38
47
|
"^python(3)?\\s+-m\\s+pytest(\\s+.*)?$",
|
|
@@ -73,19 +82,38 @@
|
|
|
73
82
|
"^touch\\s+",
|
|
74
83
|
"^cp\\s+",
|
|
75
84
|
"^mv\\s+",
|
|
85
|
+
"^rmdir\\s+[^|;&]+$",
|
|
76
86
|
|
|
77
87
|
"^git\\s+(add|commit|checkout|fetch|pull|push|worktree|merge|rebase|stash\\s+(push|pop|drop|apply)|tag|switch|restore)(\\s+.*)?$",
|
|
78
88
|
|
|
79
|
-
"^gh\\s+(pr|issue|repo|release|workflow|run|api)(\\s+.*)?$",
|
|
89
|
+
"^gh\\s+(pr|issue|repo|release|workflow|run|api|auth)(\\s+.*)?$",
|
|
80
90
|
|
|
81
|
-
"^
|
|
91
|
+
"^git\\s+rev-parse(\\s+.*)?$",
|
|
92
|
+
"^git\\s+stash(\\s+--include-untracked|\\s+--all|\\s+-u|\\s+-a)?(\\s+-m\\s+.*)?$",
|
|
93
|
+
"^git\\s+rev-list\\s+[^|;&]+$",
|
|
94
|
+
"^git\\s+ls-files(\\s+.*)?$",
|
|
95
|
+
"^git\\s+check-ignore(\\s+.*)?$",
|
|
96
|
+
"^git\\s+update-index(\\s+.*)?$",
|
|
97
|
+
|
|
98
|
+
"^test\\s+(-[dfeL])\\s+[^|;&]+\\s+(&&|\\|\\|)\\s+echo\\s+",
|
|
99
|
+
"^npm\\s+update\\s+[@\\w/-]+$",
|
|
100
|
+
|
|
101
|
+
"^sleep\\s+\\d+$",
|
|
102
|
+
|
|
103
|
+
"^chmod\\s+[0-6][0-7][0-7]\\s+",
|
|
104
|
+
|
|
105
|
+
"^lsof\\s+(-[a-zA-Z]+\\s+)*-?i\\s*[:\\d]+",
|
|
106
|
+
"^npm\\s+run\\s+clean(\\s+.*)?$",
|
|
107
|
+
"^npm\\s+(dedupe|cache\\s+clean)(\\s+.*)?$",
|
|
108
|
+
"^curl\\s+(-[sIo]+\\s+)*https?://localhost[:/][^|;&]*$",
|
|
109
|
+
"^pgrep\\s+"
|
|
82
110
|
],
|
|
83
111
|
|
|
84
112
|
"deny_patterns": [
|
|
85
113
|
"^sudo\\b",
|
|
86
114
|
"^doas\\b",
|
|
87
|
-
"\\brm\\s+.*(-r|-rf|-fr|--recursive)",
|
|
88
|
-
"\\brm\\s+-[^\\s]*r",
|
|
115
|
+
"(?<!git\\s)\\brm\\s+.*(-r|-rf|-fr|--recursive)",
|
|
116
|
+
"(?<!git\\s)\\brm\\s+-[^\\s]*r",
|
|
89
117
|
"^rm\\s+/",
|
|
90
118
|
"\\bmkfs\\.",
|
|
91
119
|
"\\bdd\\b.*\\bof=",
|
|
@@ -129,7 +157,7 @@
|
|
|
129
157
|
"\\.pypirc$",
|
|
130
158
|
"\\.netrc$",
|
|
131
159
|
"\\bsecrets?\\b",
|
|
132
|
-
"\\bpassw",
|
|
160
|
+
"\\bpassw(?:ord)?s?\\.(txt|json|env|yaml|yml|ini|conf|cfg)$",
|
|
133
161
|
"\\btoken"
|
|
134
162
|
]
|
|
135
163
|
}
|
package/install.js
CHANGED
|
@@ -34,6 +34,23 @@ function logError(message) {
|
|
|
34
34
|
log(` ✗ ${message}`, 'red');
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
function logUpdated(message) {
|
|
38
|
+
log(` ↻ ${message}`, 'blue');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Check if two files have identical content
|
|
43
|
+
*/
|
|
44
|
+
function filesAreIdentical(file1, file2) {
|
|
45
|
+
try {
|
|
46
|
+
const content1 = fs.readFileSync(file1);
|
|
47
|
+
const content2 = fs.readFileSync(file2);
|
|
48
|
+
return content1.equals(content2);
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
37
54
|
/**
|
|
38
55
|
* Determine the target .claude directory based on installation context
|
|
39
56
|
*/
|
|
@@ -93,8 +110,18 @@ function copyDirRecursive(src, dest, stats) {
|
|
|
93
110
|
copyDirRecursive(srcPath, destPath, stats);
|
|
94
111
|
} else {
|
|
95
112
|
if (fs.existsSync(destPath)) {
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
// Check if files are identical
|
|
114
|
+
if (filesAreIdentical(srcPath, destPath)) {
|
|
115
|
+
stats.skipped.push(destPath);
|
|
116
|
+
logSkip(`Unchanged: ${path.relative(stats.targetBase, destPath)}`);
|
|
117
|
+
} else {
|
|
118
|
+
// Backup existing file, then replace
|
|
119
|
+
const backupPath = destPath + '.bak';
|
|
120
|
+
fs.copyFileSync(destPath, backupPath);
|
|
121
|
+
fs.copyFileSync(srcPath, destPath);
|
|
122
|
+
stats.updated.push(destPath);
|
|
123
|
+
logUpdated(`Updated (backup: .bak): ${path.relative(stats.targetBase, destPath)}`);
|
|
124
|
+
}
|
|
98
125
|
} else {
|
|
99
126
|
fs.copyFileSync(srcPath, destPath);
|
|
100
127
|
stats.copied.push(destPath);
|
|
@@ -123,6 +150,7 @@ function install() {
|
|
|
123
150
|
|
|
124
151
|
const stats = {
|
|
125
152
|
copied: [],
|
|
153
|
+
updated: [],
|
|
126
154
|
skipped: [],
|
|
127
155
|
targetBase,
|
|
128
156
|
};
|
|
@@ -132,6 +160,7 @@ function install() {
|
|
|
132
160
|
{ src: 'hooks', dest: 'scripts' }, // Hooks go to scripts directory
|
|
133
161
|
{ src: 'scripts', dest: 'scripts' },
|
|
134
162
|
{ src: 'commands', dest: 'commands' },
|
|
163
|
+
{ src: 'skills', dest: 'skills' },
|
|
135
164
|
];
|
|
136
165
|
|
|
137
166
|
for (const { src, dest } of mappings) {
|
|
@@ -147,7 +176,8 @@ function install() {
|
|
|
147
176
|
// Summary
|
|
148
177
|
log('\n' + colors.bold + '📊 Installation Summary' + colors.reset);
|
|
149
178
|
log(` Files copied: ${stats.copied.length}`, 'green');
|
|
150
|
-
log(` Files
|
|
179
|
+
log(` Files updated (backups created): ${stats.updated.length}`, 'blue');
|
|
180
|
+
log(` Files unchanged: ${stats.skipped.length}`, 'yellow');
|
|
151
181
|
|
|
152
182
|
// Post-install instructions
|
|
153
183
|
log('\n' + colors.bold + '📝 Configuration Required' + colors.reset);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@torka/claude-qol",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Claude Code quality-of-life improvements: auto-approve hooks, context monitoring, and status line enhancements",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"hooks",
|
|
23
23
|
"scripts",
|
|
24
24
|
"commands",
|
|
25
|
+
"skills",
|
|
25
26
|
"examples",
|
|
26
27
|
".claude-plugin",
|
|
27
28
|
"install.js",
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Opus Analysis Prompt Template
|
|
2
|
+
|
|
3
|
+
> **Usage:** Fill in the placeholders below and provide to an Opus subagent via the Task tool.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Your Task
|
|
8
|
+
|
|
9
|
+
You are an expert workflow analyst reviewing a Claude Code session transcript. Your goal is to identify improvements that will make the workflow more efficient, clear, and effective for future runs.
|
|
10
|
+
|
|
11
|
+
## Context
|
|
12
|
+
|
|
13
|
+
### Project Information
|
|
14
|
+
```
|
|
15
|
+
{PROJECT_CLAUDE_MD}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Workflow Being Analyzed
|
|
19
|
+
**Name:** `{WORKFLOW_NAME}`
|
|
20
|
+
**Type:** {WORKFLOW_TYPE} (command | skill | agent)
|
|
21
|
+
**Source:** {WORKFLOW_SOURCE} (project-specific | npm-package)
|
|
22
|
+
|
|
23
|
+
### Workflow Definition
|
|
24
|
+
```markdown
|
|
25
|
+
{WORKFLOW_CONTENT}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
{ADDITIONAL_WORKFLOW_FILES}
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Session Transcript
|
|
33
|
+
|
|
34
|
+
The following is the session transcript in JSONL format. Each line is a JSON object representing an event (user message, assistant response, tool call, tool result, etc.).
|
|
35
|
+
|
|
36
|
+
```jsonl
|
|
37
|
+
{SESSION_TRANSCRIPT}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Analysis Instructions
|
|
43
|
+
|
|
44
|
+
Analyze this session transcript against the workflow definition. Focus on practical, actionable improvements.
|
|
45
|
+
|
|
46
|
+
### 1. What Went Well
|
|
47
|
+
|
|
48
|
+
Identify aspects that worked smoothly:
|
|
49
|
+
- Steps that executed without confusion
|
|
50
|
+
- User satisfaction signals (thanks, approval, moving on quickly)
|
|
51
|
+
- Efficient tool usage (parallel calls, minimal retries)
|
|
52
|
+
- Good error recovery
|
|
53
|
+
- Clear communication
|
|
54
|
+
|
|
55
|
+
For each positive finding, note:
|
|
56
|
+
- What worked
|
|
57
|
+
- Evidence from transcript (quote or reference)
|
|
58
|
+
- Why it's worth preserving
|
|
59
|
+
|
|
60
|
+
### 2. What Could Be Better
|
|
61
|
+
|
|
62
|
+
Identify friction points and inefficiencies:
|
|
63
|
+
|
|
64
|
+
**Friction Indicators to Look For:**
|
|
65
|
+
- User corrections ("no, I meant...", "actually...", "wait...")
|
|
66
|
+
- Repeated attempts at the same operation
|
|
67
|
+
- Requests for clarification ("what do you mean by...", "can you explain...")
|
|
68
|
+
- Workflow restarts or backtracking
|
|
69
|
+
- Long pauses followed by clarifying questions
|
|
70
|
+
- Error messages and recovery attempts
|
|
71
|
+
- Unnecessary file reads or tool calls
|
|
72
|
+
- Sequential operations that could be parallel
|
|
73
|
+
|
|
74
|
+
**For each issue found, note:**
|
|
75
|
+
- What went wrong or was inefficient
|
|
76
|
+
- Direct quote or event reference from transcript
|
|
77
|
+
- Impact (time lost, confusion caused, goal blocked)
|
|
78
|
+
- Root cause in workflow definition (if identifiable)
|
|
79
|
+
|
|
80
|
+
### 3. Specific Improvement Suggestions
|
|
81
|
+
|
|
82
|
+
For each identified issue, propose a concrete improvement:
|
|
83
|
+
|
|
84
|
+
**Format:**
|
|
85
|
+
```
|
|
86
|
+
## [PRIORITY] Brief Title
|
|
87
|
+
|
|
88
|
+
**Evidence:**
|
|
89
|
+
> [Quote or description of the problematic event]
|
|
90
|
+
|
|
91
|
+
**Root Cause:**
|
|
92
|
+
[Why this happened - workflow instruction unclear, missing step, etc.]
|
|
93
|
+
|
|
94
|
+
**Proposed Change:**
|
|
95
|
+
- File: `{path-to-file}`
|
|
96
|
+
- Location: {section or line reference}
|
|
97
|
+
- Change:
|
|
98
|
+
```markdown
|
|
99
|
+
[Specific edit - show before/after if possible]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Expected Benefit:**
|
|
103
|
+
[What will improve after this change]
|
|
104
|
+
|
|
105
|
+
**Effort:** Simple | Moderate | Complex
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Priority Levels:**
|
|
109
|
+
- **HIGH**: Caused workflow failure, significant time loss, or required multiple retries
|
|
110
|
+
- **MEDIUM**: Caused confusion, required clarification, or added unnecessary steps
|
|
111
|
+
- **LOW**: Optimization opportunity - would make workflow faster or clearer but didn't cause problems
|
|
112
|
+
|
|
113
|
+
### 4. Patterns to Watch
|
|
114
|
+
|
|
115
|
+
Note any patterns that might indicate systemic issues:
|
|
116
|
+
- Same type of error appearing multiple times
|
|
117
|
+
- Consistent unclear instructions in certain step types
|
|
118
|
+
- Tool usage anti-patterns
|
|
119
|
+
- Communication style issues
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Output Format
|
|
124
|
+
|
|
125
|
+
Structure your response exactly as follows:
|
|
126
|
+
|
|
127
|
+
```markdown
|
|
128
|
+
# Workflow Analysis: {WORKFLOW_NAME}
|
|
129
|
+
|
|
130
|
+
## Session Summary
|
|
131
|
+
- **Duration:** [estimate from timestamps]
|
|
132
|
+
- **Workflow completed:** Yes/No/Partial
|
|
133
|
+
- **Overall smoothness:** [1-10 scale]
|
|
134
|
+
|
|
135
|
+
## What Went Well
|
|
136
|
+
|
|
137
|
+
### 1. [Title]
|
|
138
|
+
- **Evidence:** [quote/reference]
|
|
139
|
+
- **Why it works:** [explanation]
|
|
140
|
+
|
|
141
|
+
### 2. [Title]
|
|
142
|
+
...
|
|
143
|
+
|
|
144
|
+
## What Could Be Better
|
|
145
|
+
|
|
146
|
+
### 1. [Title]
|
|
147
|
+
- **Evidence:** [quote/reference]
|
|
148
|
+
- **Impact:** [description]
|
|
149
|
+
- **Root cause:** [if known]
|
|
150
|
+
|
|
151
|
+
### 2. [Title]
|
|
152
|
+
...
|
|
153
|
+
|
|
154
|
+
## Improvement Suggestions
|
|
155
|
+
|
|
156
|
+
### 1. [HIGH] [Title]
|
|
157
|
+
- **Evidence:** [quote]
|
|
158
|
+
- **Root Cause:** [explanation]
|
|
159
|
+
- **Proposed Change:**
|
|
160
|
+
- File: [path]
|
|
161
|
+
- Edit: [before → after]
|
|
162
|
+
- **Expected Benefit:** [description]
|
|
163
|
+
- **Effort:** [Simple/Moderate/Complex]
|
|
164
|
+
|
|
165
|
+
### 2. [MEDIUM] [Title]
|
|
166
|
+
...
|
|
167
|
+
|
|
168
|
+
### 3. [LOW] [Title]
|
|
169
|
+
...
|
|
170
|
+
|
|
171
|
+
## Patterns Observed
|
|
172
|
+
|
|
173
|
+
### Recurring Issues
|
|
174
|
+
- [pattern 1]
|
|
175
|
+
- [pattern 2]
|
|
176
|
+
|
|
177
|
+
### Success Patterns Worth Preserving
|
|
178
|
+
- [pattern 1]
|
|
179
|
+
- [pattern 2]
|
|
180
|
+
|
|
181
|
+
## Recommendations Summary
|
|
182
|
+
|
|
183
|
+
| Priority | Improvement | File | Effort |
|
|
184
|
+
|----------|-------------|------|--------|
|
|
185
|
+
| HIGH | [title] | [file] | [effort] |
|
|
186
|
+
| MEDIUM | [title] | [file] | [effort] |
|
|
187
|
+
| LOW | [title] | [file] | [effort] |
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Important Notes
|
|
193
|
+
|
|
194
|
+
1. **Be specific.** Vague suggestions like "improve clarity" are not actionable. Show exactly what text to change.
|
|
195
|
+
|
|
196
|
+
2. **Be evidence-based.** Every suggestion must reference specific events in the transcript.
|
|
197
|
+
|
|
198
|
+
3. **Be practical.** Focus on changes that will have real impact, not theoretical improvements.
|
|
199
|
+
|
|
200
|
+
4. **Preserve what works.** Don't suggest changing things that are working well.
|
|
201
|
+
|
|
202
|
+
5. **Consider the user.** This workflow is used by a solo developer who values efficiency. Optimize for their workflow, not for edge cases.
|
|
203
|
+
|
|
204
|
+
6. **Scope appropriately.** Suggest changes to the workflow files, not to Claude's core behavior or the user's project code.
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nash
|
|
3
|
+
description: Workflow optimization loop that reviews Claude Code session transcripts to extract learnings and improve workflows. Run at end of sessions to create a continuous improvement cycle.
|
|
4
|
+
tools: Read, Write, Edit, Glob, Grep, Bash, Task, AskUserQuestion
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Nash: Workflow Optimization Loop
|
|
8
|
+
|
|
9
|
+
**Goal:** Review Claude Code session transcripts to extract learnings and improve workflows, creating a continuous improvement cycle.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Configuration
|
|
14
|
+
|
|
15
|
+
### NPM Package Sources
|
|
16
|
+
|
|
17
|
+
When a workflow is from an NPM package, edits are made to the source directory:
|
|
18
|
+
|
|
19
|
+
| Package | Local Path |
|
|
20
|
+
|---------|------------|
|
|
21
|
+
| `@torka/claude-workflows` | `~/Coding/npm-torka/vt-claude-workflows/` |
|
|
22
|
+
| `@torka/claude-qol` | `~/Coding/npm-torka/vt-claude-qol/` |
|
|
23
|
+
|
|
24
|
+
### Workflow File Locations
|
|
25
|
+
|
|
26
|
+
| Type | Pattern |
|
|
27
|
+
|------|---------|
|
|
28
|
+
| Commands | `.claude/commands/{name}.md` |
|
|
29
|
+
| Skills | `.claude/skills/{name}/SKILL.md` |
|
|
30
|
+
| Agents | `.claude/agents/{name}.md` |
|
|
31
|
+
| BMAD | `.claude/commands/bmad/{module}/...` |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## How It Works
|
|
36
|
+
|
|
37
|
+
1. **Discovery** - Find the current session and detect which workflows were used
|
|
38
|
+
2. **Selection** - Choose which session/workflow to optimize
|
|
39
|
+
3. **Analysis** - Use Opus to deeply analyze the session transcript
|
|
40
|
+
4. **Review** - Present findings and prioritize improvements
|
|
41
|
+
5. **Execute** - Apply approved changes to workflow sources
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## STEP 1: Discovery & Selection
|
|
46
|
+
|
|
47
|
+
### 1.1 Identify Current Context
|
|
48
|
+
|
|
49
|
+
Detect the current project and find recent sessions:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Get current project path
|
|
53
|
+
PROJECT_PATH=$(pwd)
|
|
54
|
+
|
|
55
|
+
# Claude session files location
|
|
56
|
+
SESSIONS_DIR=~/.claude/projects
|
|
57
|
+
|
|
58
|
+
# List recent sessions (most recent first)
|
|
59
|
+
ls -lt "$SESSIONS_DIR"/*/*.jsonl 2>/dev/null | head -10
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 1.2 Parse Session for Workflows
|
|
63
|
+
|
|
64
|
+
Read the session JSONL file and extract workflow invocations. Look for:
|
|
65
|
+
- `/command-name` patterns in user messages
|
|
66
|
+
- `Skill` tool invocations
|
|
67
|
+
- `Task` tool invocations with workflow-related prompts
|
|
68
|
+
|
|
69
|
+
**Detection approach:**
|
|
70
|
+
```
|
|
71
|
+
For each line in session JSONL:
|
|
72
|
+
- If user message: Look for /[\w:-]+ patterns (slash commands)
|
|
73
|
+
- If assistant message with tool calls:
|
|
74
|
+
- If Skill tool: Extract skill name from parameters
|
|
75
|
+
- If Task tool: Note if it references a workflow
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 1.3 Present Options to User
|
|
79
|
+
|
|
80
|
+
Display discovered options:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
=== NASH: Workflow Optimization ===
|
|
84
|
+
|
|
85
|
+
Current Session Analysis:
|
|
86
|
+
- Session: [session-uuid]
|
|
87
|
+
- Duration: [calculated from timestamps]
|
|
88
|
+
- Workflows detected: /dev-story, /code-review
|
|
89
|
+
|
|
90
|
+
Options:
|
|
91
|
+
1. [Default] Optimize from current session
|
|
92
|
+
- Workflow: [first detected workflow]
|
|
93
|
+
- Session: [current]
|
|
94
|
+
|
|
95
|
+
2. Recent sessions:
|
|
96
|
+
a) [time ago] /create-story on vt-saas-template
|
|
97
|
+
b) [time ago] /implement-epic on vt-saas-template
|
|
98
|
+
|
|
99
|
+
3. Manual selection
|
|
100
|
+
- Specify workflow + session path
|
|
101
|
+
|
|
102
|
+
Select option [1-3]:
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### CHECKPOINT 1
|
|
106
|
+
|
|
107
|
+
**Present to user:**
|
|
108
|
+
- Session identified (ID, duration, size)
|
|
109
|
+
- Workflows detected in session
|
|
110
|
+
- Options for what to optimize
|
|
111
|
+
|
|
112
|
+
**Use AskUserQuestion to get user selection before proceeding.**
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## STEP 2: Load Context & Determine Source
|
|
117
|
+
|
|
118
|
+
### 2.1 Resolve Workflow Files
|
|
119
|
+
|
|
120
|
+
Based on user selection, locate all relevant workflow files:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# For commands
|
|
124
|
+
WORKFLOW_FILE=".claude/commands/{name}.md"
|
|
125
|
+
|
|
126
|
+
# For skills
|
|
127
|
+
WORKFLOW_FILE=".claude/skills/{name}/SKILL.md"
|
|
128
|
+
# Also check for additional files in the skill directory
|
|
129
|
+
|
|
130
|
+
# For agents
|
|
131
|
+
WORKFLOW_FILE=".claude/agents/{name}.md"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 2.2 Dynamic NPM Package Detection
|
|
135
|
+
|
|
136
|
+
Determine if the workflow comes from an NPM package by reading `plugin.json` files:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Known NPM package directories
|
|
140
|
+
NPM_PACKAGES=(
|
|
141
|
+
"$HOME/Coding/npm-torka/vt-claude-workflows"
|
|
142
|
+
"$HOME/Coding/npm-torka/vt-claude-qol"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# For each package, read plugin.json to find workflow sources
|
|
146
|
+
for pkg in "${NPM_PACKAGES[@]}"; do
|
|
147
|
+
if [ -f "$pkg/.claude-plugin/plugin.json" ]; then
|
|
148
|
+
cat "$pkg/.claude-plugin/plugin.json"
|
|
149
|
+
# Parse the commands, agents, skills arrays
|
|
150
|
+
# If workflow name matches, this is the source
|
|
151
|
+
fi
|
|
152
|
+
done
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Detection logic:**
|
|
156
|
+
1. Read each package's `plugin.json`
|
|
157
|
+
2. Check if workflow name appears in `commands`, `agents`, or `skills` arrays
|
|
158
|
+
3. If match found → NPM package source (record package path)
|
|
159
|
+
4. If no match → Project-specific
|
|
160
|
+
|
|
161
|
+
### 2.3 Gather All Context Files
|
|
162
|
+
|
|
163
|
+
Collect:
|
|
164
|
+
1. **Session transcript** - The full JSONL file
|
|
165
|
+
2. **Primary workflow file** - The main workflow/command/skill definition
|
|
166
|
+
3. **Step files** - Any included steps (for skills)
|
|
167
|
+
4. **Template files** - Referenced templates
|
|
168
|
+
5. **Project CLAUDE.md** - For project context
|
|
169
|
+
|
|
170
|
+
### CHECKPOINT 2
|
|
171
|
+
|
|
172
|
+
**Confirm with user:**
|
|
173
|
+
- Workflow file path(s) to analyze
|
|
174
|
+
- Session file path
|
|
175
|
+
- Workflow source: `project-specific` or `npm-package: @torka/{name}`
|
|
176
|
+
- Context files that will be included
|
|
177
|
+
|
|
178
|
+
**Use AskUserQuestion for explicit confirmation before proceeding to analysis.**
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## STEP 3: Analysis (Opus Subagent)
|
|
183
|
+
|
|
184
|
+
### 3.1 Prepare Analysis Context
|
|
185
|
+
|
|
186
|
+
Read the Opus prompt template:
|
|
187
|
+
```bash
|
|
188
|
+
cat .claude/skills/nash/OPUS-ANALYSIS-PROMPT.md
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Populate the template with:
|
|
192
|
+
- `{PROJECT_CLAUDE_MD}` - Contents of project's CLAUDE.md
|
|
193
|
+
- `{WORKFLOW_NAME}` - Name of the workflow being analyzed
|
|
194
|
+
- `{WORKFLOW_TYPE}` - command | skill | agent
|
|
195
|
+
- `{WORKFLOW_SOURCE}` - project-specific | npm-package
|
|
196
|
+
- `{WORKFLOW_CONTENT}` - Full workflow file content
|
|
197
|
+
- `{ADDITIONAL_WORKFLOW_FILES}` - Step files, templates, etc.
|
|
198
|
+
- `{SESSION_TRANSCRIPT}` - Full JSONL content
|
|
199
|
+
|
|
200
|
+
### 3.2 Launch Opus Subagent
|
|
201
|
+
|
|
202
|
+
Use the Task tool to spawn an Opus subagent:
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
Task(
|
|
206
|
+
subagent_type="general-purpose",
|
|
207
|
+
model="opus",
|
|
208
|
+
prompt=<populated OPUS-ANALYSIS-PROMPT>
|
|
209
|
+
)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### 3.3 Receive Structured Analysis
|
|
213
|
+
|
|
214
|
+
The Opus subagent returns findings in structured markdown:
|
|
215
|
+
- What Went Well (with evidence)
|
|
216
|
+
- What Could Be Better (with evidence)
|
|
217
|
+
- Specific Improvement Suggestions (prioritized)
|
|
218
|
+
|
|
219
|
+
### CHECKPOINT 3
|
|
220
|
+
|
|
221
|
+
**Analysis complete.** Opus findings received. Proceed to review.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## STEP 4: Review & Prioritize
|
|
226
|
+
|
|
227
|
+
### 4.1 Present Findings
|
|
228
|
+
|
|
229
|
+
Display the analysis results in an actionable format:
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
=== ANALYSIS COMPLETE ===
|
|
233
|
+
|
|
234
|
+
What Went Well:
|
|
235
|
+
- [finding 1]
|
|
236
|
+
- [finding 2]
|
|
237
|
+
|
|
238
|
+
Improvement Opportunities:
|
|
239
|
+
1. [HIGH] Add pre-validation step before X
|
|
240
|
+
- Evidence: User had to restart 3 times due to missing file
|
|
241
|
+
- Effort: Simple
|
|
242
|
+
|
|
243
|
+
2. [MEDIUM] Clarify step 3 instructions
|
|
244
|
+
- Evidence: User asked clarifying question
|
|
245
|
+
- Effort: Simple
|
|
246
|
+
|
|
247
|
+
3. [LOW] Add parallel tool calls for search operations
|
|
248
|
+
- Evidence: Sequential searches added latency
|
|
249
|
+
- Effort: Moderate
|
|
250
|
+
|
|
251
|
+
Select items to action [1,2,3 or 'all' or 'none']:
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### 4.2 Gather User Feedback
|
|
255
|
+
|
|
256
|
+
Using AskUserQuestion:
|
|
257
|
+
- Which improvements to implement
|
|
258
|
+
- Any custom improvements to add
|
|
259
|
+
- Any modifications to suggestions
|
|
260
|
+
- Final confirmation of action list
|
|
261
|
+
|
|
262
|
+
### CHECKPOINT 4
|
|
263
|
+
|
|
264
|
+
**Action list confirmed:**
|
|
265
|
+
- [X] Improvement 1
|
|
266
|
+
- [X] Improvement 3
|
|
267
|
+
- [ ] Improvement 2 (skipped)
|
|
268
|
+
|
|
269
|
+
**Wait for user approval of final action list before executing.**
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## STEP 5: Execute Changes
|
|
274
|
+
|
|
275
|
+
### 5.1 Generate Edit Plan
|
|
276
|
+
|
|
277
|
+
For each approved improvement:
|
|
278
|
+
1. Identify exact file(s) to modify
|
|
279
|
+
2. Draft specific edits (old_string → new_string)
|
|
280
|
+
3. Note dependencies between edits
|
|
281
|
+
|
|
282
|
+
Present edit plan:
|
|
283
|
+
```
|
|
284
|
+
File: .claude/commands/dev-story.md
|
|
285
|
+
Edit 1: Add validation step
|
|
286
|
+
- Location: After step 1
|
|
287
|
+
- Change: [before → after preview]
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 5.2 Execute Based on Source Type
|
|
291
|
+
|
|
292
|
+
#### Path (a) - Project-Specific Workflow
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Make edits directly to project's .claude/ directory
|
|
296
|
+
Edit(
|
|
297
|
+
file_path=".claude/commands/{name}.md",
|
|
298
|
+
old_string="...",
|
|
299
|
+
new_string="..."
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
# Validate changes
|
|
303
|
+
cat .claude/commands/{name}.md | head -50
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Done after validation.**
|
|
307
|
+
|
|
308
|
+
#### Path (b) - NPM-Packaged Workflow
|
|
309
|
+
|
|
310
|
+
**Step 1:** Read NPM package CLAUDE.md for package-specific instructions:
|
|
311
|
+
```bash
|
|
312
|
+
cat ~/Coding/npm-torka/{package-name}/CLAUDE.md
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Step 2:** Make edits to NPM package source:
|
|
316
|
+
```bash
|
|
317
|
+
Edit(
|
|
318
|
+
file_path="~/Coding/npm-torka/{package-name}/{source-path}",
|
|
319
|
+
old_string="...",
|
|
320
|
+
new_string="..."
|
|
321
|
+
)
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Step 3:** Bump version (patch for fixes, minor for features):
|
|
325
|
+
```bash
|
|
326
|
+
cd ~/Coding/npm-torka/{package-name}
|
|
327
|
+
npm version patch --no-git-tag-version
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
**Step 4:** Commit changes:
|
|
331
|
+
```bash
|
|
332
|
+
cd ~/Coding/npm-torka/{package-name}
|
|
333
|
+
git add -A
|
|
334
|
+
git commit -m "fix({workflow-name}): {brief description}"
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Step 5:** Push if configured:
|
|
338
|
+
```bash
|
|
339
|
+
cd ~/Coding/npm-torka/{package-name}
|
|
340
|
+
git push origin main 2>/dev/null || echo "Push manually if needed"
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**Step 6:** Prompt for publish:
|
|
344
|
+
```
|
|
345
|
+
Ready to publish @torka/{package-name}@{new-version}
|
|
346
|
+
|
|
347
|
+
If you have 2FA enabled on npmjs.com, run manually:
|
|
348
|
+
cd ~/Coding/npm-torka/{package-name} && npm publish
|
|
349
|
+
|
|
350
|
+
Otherwise, I can run `npm publish` for you.
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Step 7:** Update project dependency:
|
|
354
|
+
```bash
|
|
355
|
+
npm update @torka/{package-name}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### 5.3 Validate Changes
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
# Verify file was modified correctly
|
|
362
|
+
cat {modified-file-path}
|
|
363
|
+
|
|
364
|
+
# For NPM packages, verify version bump
|
|
365
|
+
cat ~/Coding/npm-torka/{package-name}/package.json | grep version
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### CHECKPOINT 5 (Final)
|
|
369
|
+
|
|
370
|
+
**Summary:**
|
|
371
|
+
- Files modified: [list]
|
|
372
|
+
- Changes made: [summary]
|
|
373
|
+
- Workflow source: [project-specific or npm-package]
|
|
374
|
+
- Next steps: [if any, e.g., "run npm publish manually"]
|
|
375
|
+
|
|
376
|
+
**Confirm completion with user.**
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Quick Reference
|
|
381
|
+
|
|
382
|
+
### Session File Location
|
|
383
|
+
```
|
|
384
|
+
~/.claude/projects/{encoded-project-path}/{session-uuid}.jsonl
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Priority Levels
|
|
388
|
+
- **HIGH**: Caused workflow failures or significant friction
|
|
389
|
+
- **MEDIUM**: Caused confusion or required clarification
|
|
390
|
+
- **LOW**: Optimization opportunities (speed, clarity)
|
|
391
|
+
|
|
392
|
+
### Effort Levels
|
|
393
|
+
- **Simple**: Single file edit, clear change
|
|
394
|
+
- **Moderate**: Multiple files or requires careful consideration
|
|
395
|
+
- **Complex**: Architectural change or significant rewrite
|
|
396
|
+
|
|
397
|
+
### JSONL Event Types (for parsing)
|
|
398
|
+
- `user` - User message (look for /commands here)
|
|
399
|
+
- `assistant` - Assistant response with tool_calls
|
|
400
|
+
- `tool_result` - Result of a tool call
|