[FEATURE REQUEST] Add "Compact" tool for programmatic conversation compaction
Resolved 💬 4 comments Opened Aug 12, 2025 by wehriam Closed Aug 19, 2025
Problem Statement
Currently, the /compact slash command allows users to manually compact conversations with optional focus instructions. However, there's no programmatic way for Claude to trigger this functionality when needed during long conversations or when context becomes cluttered.
Proposed Solution
Add a new "Compact" tool that Claude can invoke programmatically with the following parameters:
interface CompactToolParams {
description: string; // Corresponds to the $ARGUMENTS of the "/compact" slash command
prompt?: string; // Optional message sent to Claude on behalf of the user after compaction
}
Implementation Details
The tool would:
- Accept a
descriptionparameter that provides focus instructions for the compaction (equivalent to/compact [instructions]) - Optionally accept a
promptparameter that automatically sends a follow-up message after compaction completes - Execute the same compaction logic as the
/compactslash command - Return confirmation of successful compaction
Use Cases
- Long debugging sessions: Claude could compact the conversation when working through extensive debugging, keeping only relevant findings
- Multi-step refactoring: After completing major refactoring phases, Claude could compact while preserving the current state
- Context switching: When transitioning between different parts of a codebase, Claude could compact with focus on the new area
- Memory optimization: Proactively manage context window usage in complex projects
Example Usage
// Claude invokes the tool
Compact({
description: "Focus on the authentication module implementation",
prompt: "Now let's continue with adding OAuth support"
})
Benefits
- Improved efficiency: Reduces context clutter automatically during long sessions
- Better continuity: The optional prompt parameter ensures smooth workflow continuation
- Context management: Allows Claude to intelligently manage conversation history
- User experience: Maintains conversation flow without manual intervention
Backward Compatibility
This feature would be additive and wouldn't affect existing /compact slash command functionality.
Additional Considerations
- Consider adding a user setting to enable/disable tool-based compaction
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗