Last active
December 21, 2025 18:43
-
-
Save superjax/5e4b9c78d42458d0c6b1d5a05aa66288 to your computer and use it in GitHub Desktop.
Run a claude code command without it showing up in claude history
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
| #!/bin/bash | |
| # Run claude and capture both the message and session ID | |
| all_args="$@" | |
| OUTPUT=$(claude -p "$all_args" --output-format json) | |
| # Extract the response and session ID | |
| RESULT=$(echo "$OUTPUT" | jq -r '.result') | |
| SESSION_ID=$(echo "$OUTPUT" | jq -r '.session_id') | |
| # Clean up session files so it doesn't appear in /resume | |
| if [[ -n "$SESSION_ID" ]]; then | |
| rm -f ~/.claude/projects/*/"$SESSION_ID".jsonl 2>/dev/null | |
| rm -f ~/.claude/todos/"$SESSION_ID"-*.json 2>/dev/null | |
| rm -f ~/.claude/debug/"$SESSION_ID".txt 2>/dev/null | |
| fi | |
| echo "$RESULT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
appreciate it