Skip to content

Instantly share code, notes, and snippets.

@superjax
Last active December 21, 2025 18:43
Show Gist options
  • Select an option

  • Save superjax/5e4b9c78d42458d0c6b1d5a05aa66288 to your computer and use it in GitHub Desktop.

Select an option

Save superjax/5e4b9c78d42458d0c6b1d5a05aa66288 to your computer and use it in GitHub Desktop.
Run a claude code command without it showing up in claude history
#!/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"
@risenowrise
Copy link

appreciate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment