Skip to content

refactor: pilot /cnc-logs as a skill with inline !block - #6

Merged
claylo merged 1 commit into
mainfrom
refactor/cnc-logs-skill-pilot
Apr 11, 2026
Merged

refactor: pilot /cnc-logs as a skill with inline !block#6
claylo merged 1 commit into
mainfrom
refactor/cnc-logs-skill-pilot

Conversation

@claylo

@claylo claylo commented Apr 11, 2026

Copy link
Copy Markdown
Owner

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
    $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.

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.
@claylo
claylo merged commit 3dd223c into main Apr 11, 2026
@claylo
claylo deleted the refactor/cnc-logs-skill-pilot branch April 11, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant