How to see which AI coding agents are still running
List your processes and look for the agent commands (claude, codex, gemini, aider and others), note which have no terminal attached and how long they have been up, then check which local ports are still listening. npx skillhawk agents does all of this in one read-only command and also finds Claude Code sessions still working with no human message for hours.
Where agents keep running
- Headless runs (
claude -p,codex exec) started by a script, cron, launchd or a CI schedule. They have no terminal, so closing a window does not stop them. - Interactive sessions left open. Claude Code can start new turns while a session sits idle, for example scheduled tasks, messages from your other sessions and goal check-ins; each one sends the full context again.
- Child processes an agent started: test watchers, dev servers and sub-agents that outlive the session that started them.
- Scheduled agents you set up once and forgot: crontab entries, launchd or systemd user jobs, and GitHub Actions workflows with a
schedule:trigger.
Doing it by hand
ps -Ao pid,ppid,etime,tty,command | grep -E "claude|codex|gemini|aider"lists agent processes with how long each has run (etime) and whether it has a terminal (ttyis??when it has none).lsof -nP -iTCP -sTCP:LISTENlists processes listening on a port, which is how you find a dev server nobody is using.crontab -landls ~/Library/LaunchAgents(macOS) or~/.config/systemd/user(Linux) show what is scheduled.
A worked example
Output from example data, in the real output format:
$ npx skillhawk agents
skillhawk agents: 2 need a look (running over 12h, or working with no human input for 2h)
Agent processes (2)
! 100 claude up 3d 4h no terminal cpu 0.1% 200 MB 1 child process
200 claude up 1h 10m tty ttys003 cpu 2% 300 MB 0 child processes
Dev servers left running (1)
! 300 up 26d 1h port 4400 13 MB node /home/me/studio/server.cjs
Nothing was stopped. To stop the flagged processes yourself: kill 100 300
The Skillhawk command that helps
One command, read-only; it never stops anything and nothing leaves your machine:
npx skillhawk agents
npx skillhawk agents --running 6 --idle 1 # stricter thresholds
npx skillhawk agents --notify desktop # a desktop alert with counts only
It reads ps, lsof, your crontab, launchd or systemd user jobs, the current repo's GitHub workflows and Claude Code's local session logs.
Questions
Does closing the terminal stop a Claude Code agent?
Closing the terminal ends an interactive session attached to it, but headless runs started by a script or scheduler have no terminal and keep running, as do servers and watchers they started.
Is it safe to run skillhawk agents?
It only reads. It lists processes, ports, schedules and session activity, prints the command to stop each flagged process, and stops nothing itself.
Sources
- Claude Code docs: Manage costs effectively (what uses tokens while a session is idle)
- Claude Code docs: Run Claude Code programmatically (headless)
- ps(1) manual page
- lsof on macOS (SS64)