refactor: pilot /cnc-logs as a skill with inline !block - #6
Merged
Conversation
The original /cnc-logs implementation was a two-piece trick: register a
UserPromptSubmit hook that fires on every prompt, guard it inside the
script with a prompt-prefix check, and use commands/cnc-logs.md to tell
Claude "the output is above." That shape spawned several of the bugs
this session has been untangling:
- UserPromptSubmit matchers are silently ignored, so the hook fired on
every prompt and filtering had to happen inside the script.
- The script's substring guard didn't match the plugin-namespaced
/cnc: form and needed a second fix.
- The "rendered above" framing relied on an ordering contract between
hook stdout and command-markdown expansion that isn't documented.
Per slash-commands.md lines 26 and 378-406, the correct shape is a skill
that runs the log script at prompt-expansion time via an inline !block.
Each `!<command>` executes before Claude sees anything, and its stdout
is substituted into the skill content, so the fully-rendered prompt
contains the actual log dashboard plus the summary instruction together.
No matcher, no guard, no ordering assumption.
Pilot the pattern on /cnc-logs only; /cncflip stays on the old
UserPromptSubmit pattern until this shape is proven in anger.
Changes:
- Add skills/cnc-logs/SKILL.md with disable-model-invocation,
argument-hint for autocomplete, allowed-tools: Bash, and an inline
```! block that calls ${CLAUDE_SKILL_DIR}/../../hooks/cnc-logs.sh
$ARGUMENTS.
- Strip hooks/cnc-logs.sh of its stdin+jq prompt parsing and
prompt-prefix guard. It now accepts positional args directly via
args="$*", which works both from the skill's !block and from any
direct invocation for debugging.
- Remove the cnc-logs.sh UserPromptSubmit registration from
hooks/hooks.json. The toggle-hook.sh registration stays.
- Delete commands/cnc-logs.md. The skill supersedes it under the same
/cnc-logs name and the docs explicitly say skills take precedence
over commands of the same name.
Verification: bash hooks/cnc-logs.sh (summary) and hooks/cnc-logs.sh
rustfmt (drill-down) both render correctly from a direct call with no
stdin piping. hooks.json parses clean. shellspec full suite still at
46/46 — toggle_hook_spec coverage unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The original /cnc-logs implementation was a two-piece trick: register a
UserPromptSubmit hook that fires on every prompt, guard it inside the
script with a prompt-prefix check, and use commands/cnc-logs.md to tell
Claude "the output is above." That shape spawned several of the bugs
this session has been untangling:
every prompt and filtering had to happen inside the script.
/cnc: form and needed a second fix.
hook stdout and command-markdown expansion that isn't documented.
Per slash-commands.md lines 26 and 378-406, the correct shape is a skill
that runs the log script at prompt-expansion time via an inline !block.
Each
!<command>executes before Claude sees anything, and its stdoutis substituted into the skill content, so the fully-rendered prompt
contains the actual log dashboard plus the summary instruction together.
No matcher, no guard, no ordering assumption.
Pilot the pattern on /cnc-logs only; /cncflip stays on the old
UserPromptSubmit pattern until this shape is proven in anger.
Changes:
argument-hint for autocomplete, allowed-tools: Bash, and an inline
prompt-prefix guard. It now accepts positional args directly via
args="$*", which works both from the skill's !block and from any
direct invocation for debugging.
hooks/hooks.json. The toggle-hook.sh registration stays.
/cnc-logs name and the docs explicitly say skills take precedence
over commands of the same name.
Verification: bash hooks/cnc-logs.sh (summary) and hooks/cnc-logs.sh
rustfmt (drill-down) both render correctly from a direct call with no
stdin piping. hooks.json parses clean. shellspec full suite still at
46/46 — toggle_hook_spec coverage unchanged.