Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env zsh
- set -euo pipefail
- if (( $# < 1 )); then
- print -u2 "usage: claude-slash <command> [args…]"
- exit 2
- fi
- CMD="$1"; shift || true
- ARGS="${*:-}"
- # project first, then global
- if [[ -f ".claude/commands/${CMD}.md" ]]; then
- FILE=".claude/commands/${CMD}.md"
- elif [[ -f "$HOME/.claude/commands/${CMD}.md" ]]; then
- FILE="$HOME/.claude/commands/${CMD}.md"
- else
- print -u2 "Command '${CMD}' not found in .claude/commands or ~/.claude/commands"
- exit 1
- fi
- # strip YAML frontmatter (--- … ---)
- CONTENT="$(awk 'BEGIN{p=1} /^---$/{c++} c==1{next} c>1{p=1} {if(p) print}' "$FILE")"
- # inject $ARGUMENTS placeholder
- PROMPT="${CONTENT//\$ARGUMENTS/$ARGS}"
- # run in print mode; allow Bash snippets if your command uses !`…`
- claude -p --output-format text \
- --allowedTools "Bash(*:*)" \
- --dangerously-skip-permissions \
- "$PROMPT"
Advertisement
Add Comment
Please, Sign In to add comment