[FEATURE] Allow skills/slash commands to exit the session after completion
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Custom skills can perform cleanup work via tools (saving state, updating files, printing summaries), but they cannot signal Claude Code to exit the session afterward. This means a /bye or /handover skill that does end-of-session housekeeping still requires the user to manually type exit or Ctrl+D to actually quit.
The current workflow requires me to: run my cleanup skill, wait for it to finish, then separately type exit. The skill and the exit are logically one action but I have to perform them as two.
Proposed Solution
Provide a mechanism for skills to signal "exit after this response." A few options:
- Skill frontmatter flag — e.g.,
exits: truein the YAML frontmatter tells Claude Code to terminate the session after the skill completes - A
SessionExittool — a tool that skills can invoke as their final action to trigger session exit - A post-skill hook event — a
PostSkillhook that fires after a skill finishes, which could be configured to exit
Option 1 (frontmatter flag) feels like the simplest and most intuitive approach. The skill author declares intent upfront, and Claude Code handles the lifecycle.
Alternative Solutions
Current workaround: the skill prints "Type exit to quit." at the end of its output. This works but feels like usability friction. The user invoked a "goodbye" command but is still in the session.
Another option would be wrapping Claude Code in a shell function that detects skill completion and sends exit, but that's fragile and external to the tool.
Priority
Medium - Would be very helpful
Feature Category
Interactive mode (TUI)
Use Case Example
- I have a
/byeskill that saves pending memories, updates project status files, and prints a session summary - I type
/byewhen I'm done for the day - The skill runs, does its cleanup, prints the summary
- Today: I then have to separately type
exitto actually quit - With this feature: The session exits automatically after the skill completes, landing me back on my terminal
Additional Context
This was previously requested in #23649, which was closed by the stale bot as inactive. The use case is still very much relevant, so I'm resubmitting as a fresh issue.
The pattern of "cleanup then exit" is common. Anyone building session-ending workflows (handover docs, state persistence, git cleanup) hits this gap.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗