Feature request: clear_context tool for programmatic context reset
Use case
When Claude Code is driven from an external interface (e.g., Discord via MCP plugin), the user can't easily type /clear in the terminal. The agent itself has no way to reset its context window programmatically.
This also applies to autonomous loops and long-running sessions where the agent recognizes its context is stale and wants to start fresh without user intervention.
Proposal
Add a built-in clear_context tool (similar to Read, Bash, etc.) that the agent can invoke to reset the conversation context. Same behavior as the /clear slash command but callable from within the conversation.
Current workaround
None — /clear is UI-only. The user must physically type it in the terminal or restart the session.
Context
Discovered while running a pipeline test session driven entirely from Discord. The user asked the agent to clear context after completing a task, and there was no way to do it without switching to the terminal.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗