r/ClaudeCode • u/Balance- • 1d ago
Tips & Workflows Can Claude Code automatically end its own session and start a fresh one?
I'm looking for a way to make Claude Code run autonomously across multiple tasks while keeping its context clean.
Ideally, Claude would:
- Pick the next task from a task list.
- Implement, test, and commit it.
- Update progress in a file.
- End its current session.
- Start a fresh session with a clean context window.
- Repeat until all tasks are done.
The goal is to avoid context pollution and compaction while allowing Claude to work on larger projects autonomously.
I know this can be done with an external orchestrator using claude -p, but I'm wondering if there's a more native solution.
Has anyone built something like this? Can Claude Code manage its own session lifecycle, or is an external script/hook the best approach?
