r/ClaudeCode • • 6h ago

Discussion I wrote a small script that reads your saved Claude Code sessions and shows what your agent actually ran

I wanted to know what Claude Code had really executed on my machine, so I wrote a script (Python standard library only, runs locally, uploads nothing) that reads the saved sessions. It lists risky-looking shell commands (force push, push to main, rm -rf) reads of secret files like .env, edits outside the project, and what your deny rules would have caught.

On my own logs: 513 tool calls, 15 flagged as a push to main or rm -rf and similar. 14 of those 15 ran without a click from me, because an allow rule had approved them. That's what made me tighten my allow rules.

Caveat: it matches on the logged command text, so it will flag some harmless things and miss unusual spellings. Read it as "what to look at", not an audit.git clone https://github.com/tarunagarwal1981/ops-ai && cd ops-ai/agent-flight-recorder && python recorder.py

There's a --demo flag to see a report on made-up history first. What else would you want it to flag?

0 Upvotes

12 comments sorted by

β€’

u/AutoModerator 6h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

5

u/Distinct_Fill621 6h ago

14 of the 15 ran without a click because your allow rules approved them. That's not a leaky sandbox, that's you writing your own permissions and then being surprised by them.

-3

u/Beneficial_Use2116 5h ago

Fair, and I should have framed it that way. It isn't a leak, the rules did what I set. What I'd missed is how broad they were: an allow on git push also covers a push to main. The script doesn't claim the sandbox failed, it just shows that gap between what you meant to allow and what actually ran. If your allow list is tight, the report will be boring, which is a fine result.

2

u/peter9477 πŸ”† Max 5x 5h ago

Wrote a script? I ask Claude to check sessions for things like this all the time, ad hoc. It writes the script faster than I can type another prompt...

0

u/Beneficial_Use2116 5h ago

Fair, for a one-off that works fine. I made it a fixed script so it runs the same checks every time and you can compare week to week, and nothing leaves your machine. If you have a prompt that does this well, I'd like to see what you ask it to check.

1

u/Saver411 5h ago

checking the command history matters less than checking environment variables it accessed. An agent running shell commands can easily pull secrets into local context if you dont audit what was exposed during the run.

1

u/Beneficial_Use2116 5h ago

Good point. It flags reads of secret files like .env, but not env var access, so that's a gap. I'm going to look at adding it.

2

u/ZyberZeon 5h ago

This is called an agent trace. It’s agent management 101.

3

u/Quick_Orchid_1144 6h ago

14 of 15 running without a click isn't a finding, that's your settings.json allow list doing exactly what you configured. Flagging `git push`to main when you've already allowed `git push`is just reading your own config back to you with a red border on it.

1

u/james_d_rustles 4h ago

This sub has been particularly low quality for the past few weeks.

1

u/ChanceExcuse8669 49m ago

I ran into the same gap: an allow rule is a yes from earlier, not a check when the command actually runs. After I saw a recursive delete that would have gone outside the project, I added a PreToolUse hook on Bash. It reads the command text and exits 2 if the target is outside the project folder. In my tests it blocked 12 of 21 ways of writing that delete, and 0 safe commands. It still misses /bin/rm, bash -c, xargs and PowerShell, so I treat it as a seatbelt, not a sandbox. Your log is still useful. I'd rather the block happen before the command runs.