Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
},
"metadata": {
"description": "Toolkit of skills, hooks, templates, and guides for bootstrapping AI-agent-friendly projects.",
"version": "0.4.3"
"version": "0.4.4"
},
"plugins": [
{
"name": "agent-starter",
"source": "./",
"description": "Skills, hooks, templates, and engineering guides for bootstrapping AI-agent-friendly projects, with a per-project self-improvement loop. Bundles the /new-project and /adopt-project scaffolding skills plus commit, simplify, reflect, remember, and dream.",
"version": "0.4.3",
"version": "0.4.4",
"author": {
"name": "Nick Sawinyh"
},
Expand Down
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/claude-code-plugin.json",
"name": "agent-starter",
"version": "0.4.3",
"version": "0.4.4",
"description": "Skills, hooks, templates, and engineering guides for bootstrapping AI-agent-friendly projects, with a per-project self-improvement loop.",
"author": {
"name": "Nick Sawinyh"
Expand Down
1 change: 1 addition & 0 deletions AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Hooks wired by default:
- `lint-on-edit.sh` - Biome + ESLint on save; ruff check + format for Python (PostToolUse:Write|Edit)
- `check-silent-errors.sh` - block swallowed exceptions (PostToolUse:Write|Edit)
- `block-dangerous-commands.sh` - block force-push, `reset --hard`, recursive rm on `/`/`~` (PreToolUse:Bash)
- `suggest-loop-improvements.sh` - on `/loop`, offer tighter drop-in rewrites via an interactive picker before it runs (UserPromptSubmit)

Optional: add `--with-read-guard` to also wire `track-reads.sh` +
`require-read-before-edit.sh` (force Read before Edit). Recent Claude Code
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Install everything at once as a **Claude Code plugin** - this repo doubles as a
/plugin install agent-starter@agent-starter
```

That loads all the skills (`/new-project`, `/adopt-project`, `/commit`, `/commit-push-pr`, `/simplify`, `/reflect`, `/remember`, `/dream`) **and** wires the enforcement hooks (file-size, lint-on-edit, silent-error, dangerous-command, codebase-health) from `hooks/hooks.json`. This is the simplest path and the one to recommend.
That loads all the skills (`/new-project`, `/adopt-project`, `/commit`, `/commit-push-pr`, `/simplify`, `/reflect`, `/remember`, `/dream`) **and** wires the enforcement hooks (file-size, lint-on-edit, silent-error, dangerous-command, codebase-health) plus a `/loop` instruction-review hook from `hooks/hooks.json`. This is the simplest path and the one to recommend.

The read-before-edit guard pair is left out of the plugin on purpose (recent Claude Code enforces read-before-edit natively); opt into it via `install.sh --with-read-guard` below.

Expand Down
3 changes: 2 additions & 1 deletion TEAM.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Instead:
{ "matcher": "Write|Edit", "hooks": [{ "type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/check-silent-errors.sh", "timeout": 5, "statusMessage": "Checking error handling..." }] }
],
"PreToolUse": [{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/block-dangerous-commands.sh", "timeout": 3, "statusMessage": "Checking command safety..." }] }],
"SessionStart":[{ "hooks": [{ "type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/check-codebase-health.sh .", "timeout": 15, "statusMessage": "Checking codebase health..." }] }]
"SessionStart":[{ "hooks": [{ "type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/check-codebase-health.sh .", "timeout": 15, "statusMessage": "Checking codebase health..." }] }],
"UserPromptSubmit":[{ "hooks": [{ "type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/suggest-loop-improvements.sh", "timeout": 10, "statusMessage": "Reviewing loop instructions..." }] }]
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.3
0.4.4
25 changes: 25 additions & 0 deletions hooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,31 @@ Add to `settings.json`:
}
```

### suggest-loop-improvements.sh
**Event:** UserPromptSubmit
**What it does:** When you run `/loop`, injects an instruction that has Claude propose 2-3 improved, drop-in replacements for the command before it runs, then present them with the `AskUserQuestion` tool so you pick one interactively (A / B / C, plus "Run original unchanged") - no copy-paste. Claude runs only the option you select.

- The hook does **no LLM work and spawns no nested session** - it only injects context, so the already-running model generates the variants. Fast (<50ms), needs no API key.
- Filters by prompt text (`UserPromptSubmit` has no matcher), so it is a silent no-op for every other prompt.
- Each replacement adds only the missing precision - explicit success criteria, a stop condition, bounded scope, a verification step - while preserving your interval and args.
- Non-blocking (exit 0): if the command is already solid, or the session is headless (no interactive prompt), the original runs unchanged.

**Scoped to `/loop` only, on purpose.** `/loop` hands control to Claude to interpret and act, so the injected "ask first" instruction lands *before* any action and the picker can render. Client-side local commands like `/goal` execute their effect at submit time (the CLI sets the goal and arms its Stop hook before Claude's turn even starts), so an advisory (exit 0) injection cannot intercept them, and `/goal` also explicitly tells Claude not to pause and ask. The hook therefore matches only `/loop*` and ignores `/goal`. Interactive gating like this works only for commands whose effect Claude performs on its turn, not for client-side commands.

Add to `settings.json`:

```json
{
"UserPromptSubmit": [
{
"hooks": [
{ "type": "command", "command": "~/.claude/hooks/suggest-loop-improvements.sh", "timeout": 10, "statusMessage": "Reviewing loop instructions..." }
]
}
]
}
```

## Exit Code Behavior
- **Exit 0** - success, proceed normally
- **Exit 2** - BLOCK the action, stderr shown to Claude as error
Expand Down
12 changes: 12 additions & 0 deletions hooks/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/suggest-loop-improvements.sh",
"timeout": 10,
"statusMessage": "Reviewing loop instructions..."
}
]
}
]
}
}
47 changes: 47 additions & 0 deletions hooks/suggest-loop-improvements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# UserPromptSubmit hook: when the user runs /loop, inject an instruction telling
# Claude to first propose improved, drop-in replacements for the command and let
# the user pick one interactively via AskUserQuestion (no copy-paste), then run
# only the chosen command.
#
# The hook itself does no LLM work and spawns no nested session - it only injects
# context, so the already-running model generates the variants. That keeps it
# fast (<50ms), needs no API key, and no matcher (UserPromptSubmit has none), so
# it filters to /loop by prompt text. Scoped to /loop only: client-side local
# commands like /goal execute their effect at submit time, before Claude's turn,
# so an advisory injection cannot gate them. Non-blocking: every other prompt,
# and any parse failure, passes through untouched (exit 0).
set -euo pipefail

input="$(cat)"
prompt="$(printf '%s' "$input" | jq -r '.prompt // empty')"

# Only act on /loop invocations; everything else passes through.
case "$prompt" in
/loop*) ;;
*) exit 0 ;;
esac

cat <<EOF
<loop-review>
The user is about to run this command: $prompt

Before executing it, do this first:
1. Generate 2-3 improved, drop-in replacements for the command. Keep each faithful
to the original intent (preserve the interval and args); only add the missing
precision - explicit success criteria, an explicit stop condition, bounded
scope, and a verification step.
2. Call the AskUserQuestion tool (header "Improve loop?") with:
- one option per replacement, lettered in order: label "A - <short label>",
"B - <short label>", ... and put the full rewritten command plus a one-line
"Why:" in each option's description.
- a final option: label "Run original unchanged", description = the original command.
3. Run ONLY the command the user selects, verbatim. For the last option, run the
original command as-is.

If the command already has clear success criteria, a stop condition, bounded scope,
and a verification step, skip the question and run it unchanged. If you cannot show
an interactive prompt (headless/non-interactive session), run the original unchanged.
</loop-review>
EOF
exit 0
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jq --arg h "$H" --argjson guard "$READ_GUARD" '
| add("PostToolUse"; entry("Write|Edit"; $h + "/check-silent-errors.sh"; 5; "Checking error handling..."))
| add("PreToolUse"; entry("Bash"; $h + "/block-dangerous-commands.sh"; 3; "Checking command safety..."))
| add("SessionStart"; {hooks: [{type: "command", command: ($h + "/check-codebase-health.sh ."), timeout: 15, statusMessage: "Checking codebase health..."}]})
| add("UserPromptSubmit"; {hooks: [{type: "command", command: ($h + "/suggest-loop-improvements.sh"), timeout: 10, statusMessage: "Reviewing loop instructions..."}]})
| (if $guard == 1 then
add("PostToolUse"; entry("Read"; $h + "/track-reads.sh"; 3; "Tracking reads..."))
| add("PreToolUse"; entry("Edit|Write"; $h + "/require-read-before-edit.sh"; 3; "Checking read log..."))
Expand Down
1 change: 1 addition & 0 deletions skills/new-project/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ Hook behavior (wired by default):
- `check-silent-errors.sh` - blocks writes that introduce swallowed exceptions.
- `block-dangerous-commands.sh` - blocks force-push, `git reset --hard`, recursive rm on `/`/`~`, before they run.
- `check-codebase-health.sh` - runs at session start. Reports files over 500 lines that need splitting. Silent when healthy.
- `suggest-loop-improvements.sh` - when you run `/loop`, proposes 2-3 tighter drop-in rewrites (explicit success criteria, stop condition, scope, verification) and lets you pick one via an interactive menu. Scoped to `/loop` only (client-side commands like `/goal` run before Claude's turn, so they can't be gated).

Optional: `--with-read-guard` also wires `track-reads.sh` + `require-read-before-edit.sh`. Recent Claude Code versions enforce read-before-edit natively, so only add it for older versions.

Expand Down
Loading