Common Context Optimization
ASecurityUse a rolling-state compaction strategy. At 30 turns, the conversation has passed the skill's recommended compaction interval, so do not keep the full dialogue as the working context. Create a compact project-state record containing: ```yaml Current_State: Goal: "the original user goal, stated precisely" Active_Task: "what the agent is doing now" Status: "current progress or blocker" Key_Decisions: ["decisions that still constrain the solution"] Current_Errors: ["unresolved errors only"] Acti...
- 584 stars
- 0 votes
- 0 copies
- 2 views
- Added September 5, 2026
Security analysis
100/100Pro scans all 11 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill common-context-optimization --agent claude-codeAre you the author of Common Context Optimization?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-common-context-optimization-91cc3d87)Use a rolling-state compaction strategy. At 30 turns, the conversation has passed the skill's recommended compaction interval, so do not keep the full dialogue as the working context.
Create a compact project-state record containing:
```yaml
Current_State:
Goal: "the original user goal, stated precisely"
Active_Task: "what the agent is doing now"
Status: "current progress or blocker"
Key_Decisions: ["decisions that still constrain the solution"]
Current_Errors: ["unresolved errors only"]
Active_Files: ["files that matter to the current task"]
Next_Steps: ["the next concrete actions"]
```
Summarize recursively instead of repeatedly appending summaries to the old transcript: summarize turns 1–5 into `State_A`, combine `State_A` with turns 6–10 into `State_B`, and continue in blocks. Discard the superseded dialogue and prior state after each successful compaction. Keep the original system prompt and the last three messages uncompressed so the governing instructions and immediate context remain exact.
The state should preserve facts and decisions, not conversation wording. Remove chit-chat, intermediate tool calls, and assumptions that were corrected. If a large tool result occurred, first extract its actionable facts and replace it with a semantic placeholder rather than carrying the raw output forward.
After compaction, continue with append-only history. Repeat compaction every 10 turns or about 8,000 tokens, and refresh the `Goal` and `Next_Steps` fields each time. This gives the agent a small, stable representation of intent and current work instead of relying on a long transcript that gradually buries the goal.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.