@heart-of-gold/toolkit 0.1.11 → 0.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heart-of-gold/toolkit",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "description": "Cross-platform installer for Heart of Gold skills — works with Codex, OpenCode, Pi, Claude Code, and more",
6
6
  "bin": {
@@ -1,91 +1,165 @@
1
1
  ---
2
2
  name: claude-code
3
- description: Use when the user asks to run Claude Code CLI (`claude`, `claude resume`) or asks for a second opinion, review, analysis, refactor, or follow-up specifically from Claude Code.
3
+ description: Use when the user asks to run Claude Code CLI (`claude`, `claude resume`) for review, analysis, implementation, refactoring, debugging, or follow-up specifically through Claude Code.
4
4
  ---
5
5
 
6
6
  # Claude Code CLI Skill Guide
7
7
 
8
+ Use this skill to hand a bounded task to Claude Code from the current harness, capture the result, and summarize it back to the user.
9
+
10
+ This skill is task-based, not review-only. Use `plan` for safe read-only analysis, but use other permission modes when the task requires command execution or edits.
11
+
8
12
  ## Available Models
9
13
 
10
14
  | Model | Best for |
11
15
  | --- | --- |
16
+ | `default` | Anthropic's recommended default for the current account and environment |
12
17
  | `sonnet` | Default recommendation for most coding, review, and analysis tasks |
13
- | `opus` | Stronger reasoning for ambiguous or high-stakes reviews |
14
- | `haiku` | Faster and cheaper for lightweight follow-ups |
18
+ | `opus` | Stronger reasoning for ambiguous, high-stakes, or architecture-heavy work |
19
+ | `haiku` | Fast, lightweight follow-ups and narrow questions |
20
+ | `opusplan` | Hybrid mode that uses `opus` for planning and `sonnet` for execution |
21
+
22
+ Prefer aliases over hardcoded snapshot names in this skill, because Anthropic documents aliases as the stable Claude Code interface and moves them forward as newer snapshots ship.
23
+
24
+ Default recommendation: `sonnet` for most tasks, `opus` when depth matters more than speed, and `opusplan` when the task naturally alternates between planning and execution.
25
+
26
+ ## Permission Modes
27
+
28
+ Choose the permission mode based on what Claude Code needs to do:
29
+
30
+ | Mode | Use when | Notes |
31
+ | --- | --- | --- |
32
+ | `plan` | The task is read-only and Claude does not need to execute commands or edit files | Safest option for reviewing provided diffs, logs, file contents, or design docs |
33
+ | `default` | Claude may need to inspect the repo more freely and you can tolerate permission prompts | Good interactive default; less reliable in headless automation unless permissions are pre-arranged |
34
+ | `acceptEdits` | Claude should be able to make local code changes | Strong default for implementation, refactors, and fixes |
35
+ | `bypassPermissions` | Full automation is required in a trusted sandbox and the user explicitly approves it | High risk; do not default to this |
15
36
 
16
- Default recommendation: `sonnet` for most tasks, `opus` when depth matters more than speed.
37
+ `plan` is not the general default for this skill. It is only the safe default for bounded read-only tasks.
17
38
 
18
39
  ## Running a Task
19
- 1. Ask the user which model to use (default: `sonnet`) AND which permission mode to use (`plan`, `acceptEdits`, `default`, `auto`, or `bypassPermissions`) in a single prompt when both matter.
20
- 2. Default to `--permission-mode plan` for reviews, read-only analysis, and second opinions.
40
+ 1. Ask the user which model alias to use (default: `sonnet`) and which permission mode to use when that choice materially affects behavior.
41
+ 2. Decide whether Claude should receive the artifact directly or discover it itself:
42
+ - Pass diffs, logs, or file contents via stdin for safe read-only review
43
+ - Let Claude inspect the working tree when the task requires tool use
21
44
  3. Assemble the command with the appropriate options:
22
45
  - `-p, --print` for non-interactive output
23
46
  - `--output-format <text|json|stream-json>`
24
47
  - `--model <MODEL>`
25
48
  - `--permission-mode <MODE>`
26
49
  - `--effort <low|medium|high|max>`
27
- - `--add-dir <DIR>` when Claude Code must read outside the current working directory
50
+ - `--max-turns <N>` to bound cost and runtime
51
+ - `--allowedTools` / `--disallowedTools` to constrain tool access
52
+ - `--add-dir <DIR>` when Claude must read outside the current working directory
53
+ - `--name <NAME>` when you want a stable, human-readable session
28
54
  - `"your prompt here"` as the final positional argument
29
- 4. Prefer `--output-format text` unless the caller explicitly needs JSON.
30
- 5. Run the command, capture stdout/stderr, and summarize the outcome for the user.
31
- 6. After Claude Code completes, tell the user they can resume by asking for `claude resume` or another Claude Code follow-up.
55
+ 4. Prefer `--output-format text` for human-readable summaries and `--output-format json` for automation or machine parsing.
56
+ 5. In headless automation, prefer explicit permissions:
57
+ - `plan` for provided artifacts
58
+ - `acceptEdits` for edit-capable runs
59
+ - `default` only when prompts are acceptable or when permissions are constrained with `--allowedTools`
60
+ 6. Run the command, capture stdout/stderr, and summarize the outcome for the user.
32
61
 
33
- ### Quick Reference
34
- | Use case | Permission mode | Key flags |
35
- | --- | --- | --- |
36
- | Read-only review or analysis | `plan` | `-p --output-format text --permission-mode plan` |
37
- | Apply local edits | `acceptEdits` | `-p --output-format text --permission-mode acceptEdits` |
38
- | Stronger review pass | `plan` | `--model opus --effort high` |
39
- | Resume recent session | Inherited | `-r latest -p "new prompt" --output-format text` |
62
+ ## Best Practices
63
+
64
+ - Use `--max-turns` for automation. It keeps review and implementation runs bounded.
65
+ - Use `--output-format json` when another agent or script needs structured output.
66
+ - Use `--allowedTools` to make headless runs more reliable and safer.
67
+ - Pipe diffs or logs into Claude for read-only analysis instead of asking Claude to execute shell commands just to fetch them.
68
+ - Use `acceptEdits` for real implementation work; do not force read-only `plan` mode onto edit tasks.
69
+ - Use `bypassPermissions` only in a trusted sandbox and only with explicit user approval.
70
+ - Use `-r latest -p` for follow-up instead of re-explaining the entire task.
40
71
 
41
- ## Recommended Commands
72
+ ## Recommended Patterns
42
73
 
43
- ### Review the current diff
74
+ ### 1. Review a provided diff safely
75
+
76
+ Pass the diff via stdin and keep Claude in `plan` mode:
44
77
 
45
78
  ```bash
46
- claude -p \
79
+ git diff --staged | claude -p \
47
80
  --output-format text \
48
81
  --model sonnet \
49
82
  --permission-mode plan \
50
- --effort medium \
51
- "Review the current git diff. Return findings ordered by severity with file paths and concise explanations."
83
+ --max-turns 1 \
84
+ "Review this diff. Return findings ordered by severity with file paths and concise explanations."
52
85
  ```
53
86
 
54
- ### Review a specific file
87
+ ### 2. Ask Claude to inspect the repo and analyze
88
+
89
+ Use `default` or a constrained tool set when Claude needs to discover context itself:
55
90
 
56
91
  ```bash
57
92
  claude -p \
58
93
  --output-format text \
59
94
  --model sonnet \
60
- --permission-mode plan \
95
+ --permission-mode default \
96
+ --max-turns 4 \
97
+ --allowedTools "Read,Grep,Glob,Bash(git diff:*),Bash(git status:*)" \
98
+ "Analyze the current changes and explain the main design risks."
99
+ ```
100
+
101
+ ### 3. Ask Claude to implement or refactor
102
+
103
+ Use `acceptEdits` when Claude should change files:
104
+
105
+ ```bash
106
+ claude -p \
107
+ --output-format text \
108
+ --model sonnet \
109
+ --permission-mode acceptEdits \
61
110
  --effort high \
62
- "Review src/server.ts for correctness, regressions, and missing tests. Keep the response concise."
111
+ --max-turns 8 \
112
+ "Implement the requested change in the current repo, keep the diff minimal, and summarize what changed."
63
113
  ```
64
114
 
65
- ### Continue the latest Claude Code session
115
+ ### 4. Resume the latest Claude Code session
66
116
 
67
117
  ```bash
68
118
  claude -r latest -p \
69
119
  --output-format text \
70
- "Focus only on the migration risk you mentioned. What is the safest rollout plan?"
120
+ "Focus only on the migration risk you mentioned earlier. What is the safest rollout plan?"
71
121
  ```
72
122
 
73
- ## Optional Wrapper
123
+ ### 5. Request structured output for automation
74
124
 
75
- This skill also ships a convenience wrapper at `scripts/run-claude-code.sh`.
125
+ ```bash
126
+ claude -p \
127
+ --output-format json \
128
+ --model sonnet \
129
+ --permission-mode plan \
130
+ --max-turns 1 \
131
+ "Summarize the provided diff as JSON with keys: verdict, findings, risks."
132
+ ```
76
133
 
77
- Use it only as a thin helper around the direct `claude` commands above:
134
+ ## Optional Wrapper
78
135
 
79
- - `scripts/run-claude-code.sh --check` verifies that Claude Code is installed
80
- - `scripts/run-claude-code.sh --prompt "..." --permission-mode plan` mirrors the direct CLI usage
136
+ This skill also ships a convenience wrapper at `scripts/run-claude-code.sh`.
81
137
 
82
- Prefer the direct `claude` commands in this document when debugging, because they are easier to inspect and adapt.
138
+ Use it as a thin helper around the documented CLI patterns above. It supports:
139
+
140
+ - `--check`
141
+ - `--prompt`
142
+ - `--model`
143
+ - `--permission-mode`
144
+ - `--effort`
145
+ - `--max-turns`
146
+ - `--output-format`
147
+ - `--allowed-tools`
148
+ - `--disallowed-tools`
149
+ - `--add-dir`
150
+ - `--resume`
151
+ - `--continue`
152
+ - `--name`
153
+ - `--no-session-persistence`
154
+ - `--verbose`
155
+
156
+ Prefer the direct `claude` commands in this document when debugging or when you need to reason about permissions precisely.
83
157
 
84
158
  ## Following Up
85
159
 
86
160
  - After every Claude Code command, confirm whether the user wants a follow-up, a resume, or a different model / permission mode.
87
- - When resuming, keep the new prompt narrow instead of restating the whole task.
88
161
  - Restate the chosen model, effort, and permission mode when proposing a retry.
162
+ - Keep resume prompts narrow. Avoid restating the whole task unless context was lost.
89
163
 
90
164
  ## Critical Evaluation of Claude Code Output
91
165
 
@@ -95,7 +169,7 @@ Claude Code is a colleague, not an authority.
95
169
  - Trust your own knowledge when confident.
96
170
  - Push back if Claude Code makes a claim that conflicts with the code or docs in front of you.
97
171
  - Research disagreements before accepting them for high-impact decisions.
98
- - Do not defer blindly on models, tool flags, or fast-moving best practices.
172
+ - Do not defer blindly on models, permissions, or fast-moving best practices.
99
173
 
100
174
  ### When Claude Code Seems Wrong
101
175
  1. State the disagreement clearly to the user.
@@ -113,6 +187,7 @@ claude -r latest -p \
113
187
  ## Error Handling
114
188
 
115
189
  - Stop and report failures whenever `claude --version` or a `claude -p` command exits non-zero.
116
- - If Claude Code reports permission issues, retry only after choosing the correct `--permission-mode`.
190
+ - If Claude Code reports permission issues, choose the correct permission mode or constrain tools explicitly.
191
+ - If a headless run gets stuck on permissions, either switch to `plan`, use `acceptEdits`, or provide `--allowedTools` / a permission prompt tool.
117
192
  - Do not use `bypassPermissions` unless the user explicitly approves it.
118
193
  - If debugging a failing wrapper invocation, fall back to the direct `claude` command first.
@@ -13,11 +13,18 @@ Options:
13
13
  --model MODEL Claude model or alias (default: sonnet)
14
14
  --permission-mode MODE plan, acceptEdits, default, auto, dontAsk, bypassPermissions
15
15
  --effort LEVEL low, medium, high, max
16
+ --max-turns N Bound the number of Claude turns
16
17
  --output-format FORMAT text, json, stream-json (default: text)
17
18
  --resume VALUE Resume a session, for example: latest
18
19
  --continue Continue the most recent session in the current directory
19
20
  --add-dir PATH Additional directory to allow tool access to; repeatable
21
+ --allowed-tools SPEC Allowed tools spec; repeatable
22
+ --disallowed-tools SPEC Disallowed tools spec; repeatable
20
23
  --cwd PATH Working directory to run Claude Code from
24
+ --name NAME Human-readable session name
25
+ --permission-prompt-tool CMD External permission handler for headless runs
26
+ --no-session-persistence Do not persist the session on disk
27
+ --verbose Enable verbose Claude Code output
21
28
  --help Show this help text
22
29
  EOF
23
30
  }
@@ -27,11 +34,18 @@ prompt=""
27
34
  model="sonnet"
28
35
  permission_mode=""
29
36
  effort=""
37
+ max_turns=""
30
38
  output_format="text"
31
39
  resume_value=""
32
40
  continue_mode=0
33
41
  cwd=""
42
+ name=""
43
+ verbose=0
44
+ no_session_persistence=0
45
+ permission_prompt_tool=""
34
46
  declare -a add_dirs=()
47
+ declare -a allowed_tools=()
48
+ declare -a disallowed_tools=()
35
49
 
36
50
  while [[ $# -gt 0 ]]; do
37
51
  case "$1" in
@@ -59,6 +73,11 @@ while [[ $# -gt 0 ]]; do
59
73
  effort="$2"
60
74
  shift 2
61
75
  ;;
76
+ --max-turns)
77
+ [[ $# -ge 2 ]] || { echo "Missing value for --max-turns" >&2; exit 2; }
78
+ max_turns="$2"
79
+ shift 2
80
+ ;;
62
81
  --output-format)
63
82
  [[ $# -ge 2 ]] || { echo "Missing value for --output-format" >&2; exit 2; }
64
83
  output_format="$2"
@@ -78,11 +97,39 @@ while [[ $# -gt 0 ]]; do
78
97
  add_dirs+=("$2")
79
98
  shift 2
80
99
  ;;
100
+ --allowed-tools|--allowedTools)
101
+ [[ $# -ge 2 ]] || { echo "Missing value for --allowed-tools" >&2; exit 2; }
102
+ allowed_tools+=("$2")
103
+ shift 2
104
+ ;;
105
+ --disallowed-tools|--disallowedTools)
106
+ [[ $# -ge 2 ]] || { echo "Missing value for --disallowed-tools" >&2; exit 2; }
107
+ disallowed_tools+=("$2")
108
+ shift 2
109
+ ;;
81
110
  --cwd)
82
111
  [[ $# -ge 2 ]] || { echo "Missing value for --cwd" >&2; exit 2; }
83
112
  cwd="$2"
84
113
  shift 2
85
114
  ;;
115
+ --name)
116
+ [[ $# -ge 2 ]] || { echo "Missing value for --name" >&2; exit 2; }
117
+ name="$2"
118
+ shift 2
119
+ ;;
120
+ --permission-prompt-tool)
121
+ [[ $# -ge 2 ]] || { echo "Missing value for --permission-prompt-tool" >&2; exit 2; }
122
+ permission_prompt_tool="$2"
123
+ shift 2
124
+ ;;
125
+ --no-session-persistence)
126
+ no_session_persistence=1
127
+ shift
128
+ ;;
129
+ --verbose)
130
+ verbose=1
131
+ shift
132
+ ;;
86
133
  --help|-h)
87
134
  usage
88
135
  exit 0
@@ -127,12 +174,44 @@ if [[ -n "$effort" ]]; then
127
174
  cmd+=(--effort "$effort")
128
175
  fi
129
176
 
177
+ if [[ -n "$max_turns" ]]; then
178
+ cmd+=(--max-turns "$max_turns")
179
+ fi
180
+
181
+ if [[ -n "$name" ]]; then
182
+ cmd+=(--name "$name")
183
+ fi
184
+
185
+ if [[ -n "$permission_prompt_tool" ]]; then
186
+ cmd+=(--permission-prompt-tool "$permission_prompt_tool")
187
+ fi
188
+
189
+ if [[ "$no_session_persistence" -eq 1 ]]; then
190
+ cmd+=(--no-session-persistence)
191
+ fi
192
+
193
+ if [[ "$verbose" -eq 1 ]]; then
194
+ cmd+=(--verbose)
195
+ fi
196
+
130
197
  if ((${#add_dirs[@]} > 0)); then
131
198
  for dir in "${add_dirs[@]}"; do
132
199
  cmd+=(--add-dir "$dir")
133
200
  done
134
201
  fi
135
202
 
203
+ if ((${#allowed_tools[@]} > 0)); then
204
+ for tool in "${allowed_tools[@]}"; do
205
+ cmd+=(--allowedTools "$tool")
206
+ done
207
+ fi
208
+
209
+ if ((${#disallowed_tools[@]} > 0)); then
210
+ for tool in "${disallowed_tools[@]}"; do
211
+ cmd+=(--disallowedTools "$tool")
212
+ done
213
+ fi
214
+
136
215
  cmd+=("$prompt")
137
216
 
138
217
  if [[ -n "$cwd" ]]; then
package/src/index.ts CHANGED
@@ -7,7 +7,7 @@ import { targetsCommand } from "./commands/targets";
7
7
  const main = defineCommand({
8
8
  meta: {
9
9
  name: "heart-of-gold",
10
- version: "0.1.11",
10
+ version: "0.1.13",
11
11
  description:
12
12
  "Cross-platform installer for Heart of Gold skills — Codex, OpenCode, Pi, Claude Code, and more",
13
13
  },