What is /compact?
The /compact command is intended to reduce or summarize the current conversation context while preserving important information.
When you work with an AI agent for a long time, the conversation can become very large.
It may contain:
- Previous instructions.
- Generated code.
- Debugging discussions.
- Error messages.
- Project requirements.
- Decisions made during development.
The /compact command helps manage this accumulated context.
Why do we need /compact?
Imagine you are developing a School ERP using Laravel.
Your conversation has covered:
- Authentication system.
- Student management.
- Teacher management.
- Attendance management.
- Fee management.
- Database migrations.
- API development.
- Bug fixing.
After several hours, the conversation becomes lengthy.
You don't necessarily need every previous message in the active context. You mainly need the important project information and decisions.
This is where context compaction becomes useful.
When should you use /compact?
- When working on a large application.
- When a development session becomes very long.
- When context-window usage becomes high.
- Before continuing a lengthy multi-stage task, if supported by your agent.
Avoid using it unnecessarily during short conversations.