[FEATURE] There should be a CLI (way, likely flag) to invoke a skill `/<cmd>` as in interactive mode..
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
From claude itself suggesting how to non-interactively invoke a /<skill-cmd> as in normal interactive usage. The main use case is to avoid entering the full TUI just to type a single /-command which say generates output that can be pipelined further into the calling code (shell script wrapper, prog-lang subproc invocation, etc).
my original prompt,
how to i make you run a skill cmd like /pr-msg if i want to trigger is
when invoking you from the CLI, like i'd imagine some kinda claude -c '/pr-msg' if you
had a CLI similar to a posix shell?
Proposed Solution
(from claude-y's analysis)
Unfortunately slash commands/skills are interactive-mode only — there's no claude -c '/pr-msg'
equivalent. In -p (prompt) mode, skills aren't loaded.
Your options:
1. Just describe the task in -p mode:
claude -p "generate a PR description for this branch vs main"
2. Pipe the skill content as a system prompt (hackier but gets the skill instructions loaded):
claude -p "generate a PR description" \
--append-system-prompt-file .claude/skills/pr-msg/SKILL.md
3. Use --allowedTools to pre-approve git reads so it runs unattended:
claude -p "generate a PR description" \
--append-system-prompt-file .claude/skills/pr-msg/SKILL.md \
--allowedTools 'Bash(git *),Bash(date *),Read,Write,Grep,Glob'
Option 3 is probably the closest to what you want — it loads the skill instructions as system
context and pre-approves the tools so it can run headlessly. Could wrap that in a shell alias
or script pretty easily.
---
So figured i'd get clever and just pass the cmd directly as the -p <prompt>,
ok i tried 3 but with -p "/commit-msg" and ur instance is just hanging..
---
(so he responded with)
● Yeah -p "/commit-msg" won't work — in -p mode that's just a literal string prompt, not a skill
invocation. The model gets "/commit-msg" as the user message and doesn't know what to do with
it.
You need to give it an actual natural-language prompt alongside the skill file as system
context:
claude -p "generate a commit message for staged changes" \
--append-system-prompt-file .claude/skills/commit-msg/SKILL.md \
--allowedTools 'Bash(git *),Bash(date *),Read,Write,Grep,Glob'
The hanging is probably the model either confused by the bare /commit-msg string or waiting on
a tool permission prompt that can't be answered in non-interactive mode (if --allowedTools
wasn't set or didn't match).
Alternative Solutions
i then prompted with,
soo there literally isn't a way to do a skill-invocation from the CLI?
(to which he responded,
● Yeah, definitively no. Skills/slash-commands are interactive-mode only by design. The docs
explicitly state this.
Your best bet for a scriptable wrapper is the --append-system-prompt-file approach I mentioned
— basically manually loading the skill content as context:
claude -p "run the pr-msg workflow for this branch" \
--append-system-prompt-file \
.claude/skills/pr-msg/SKILL.md \
--allowedTools \
'Bash(git *),Bash(date *),Bash(mkdir *),Read,Write,Grep,Glob'
Could trivially wrap that as a shell alias or xonsh function that takes an arbitrary skill dir
as an arg. Something like a claude-skill wrapper that just does the --append-system-prompt-file
+ --allowedTools plumbing for you. Might be worth filing a feature request at
https://github.com/anthropics/claude-code/issues for native -p mode skill support though —
seems like a reasonable ask.
---
which i tried but it hung and i had to either wait for the prog to terminate on its own (i presume due to internal timeout, for which there's seemingly no toggle?) or kill with a signal (btw which, SIGINT only works if you emit it manually; ctl-c does not seem to work from console, at least in alacritty..). So i then prompted with,
i mean, this simply doesn't work. you hang and then emit "Terminated" on stdout/err.. so
(and got resp)
Fair enough — if it's hanging and getting killed even with --allowedTools, then that approach
is effectively broken too. Probably a tool permission mismatch or something in -p mode that
can't be resolved without interactive input.
So the honest answer: skills are interactive-only and there's no reliable workaround for
headless invocation right now. Worth a feature request on
https://github.com/anthropics/claude-code/issues if you want native support for something like
claude -p --skill pr-msg.
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
i want to create a shell alias that avoids having to start claude [-r] fully only to run a single /skill-cmd which generates output (via output stream or file) just to pipe/read that output into another program (like say git commit --edit --file .claude/git_commit_msg_LATEST.md) such that i can input a single "program/script alias" to my shell and then end up with a streamlined TUI-UX-flow without having to enter and exit various TUI programs manually.
for example, specifically in my case i am wrapping all this as a xonsh alias named claude.commit which chains together the various programs needed to get claude to auto-generate a git commit msg (given locally staged changes), write that content to an expected file, then read that file via git commit --edit --file .claude/git_commit_msg_LATEST.md giving me a final audit before the msg is saved.
Additional Context
It seems to me that there is no good reason not to support this feature since it is effectively the same as providing and "sub-command" plugin/ability which is offered by most (posix?) shells such as sh -c, bash -c, xonsh -c etc.
I'm actually very confused why this isn't already something offered by the core CLI since it would seem that it being missing means there are drastic differences between the -p "<prompt>" mode and std interactive use 😂
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗