一键导入
context-optimizer-token-management
จัดการ context window ให้ไม่เต็ม — auto-compact เมื่อใกล้ limit, ลบ tool result เก่า, สรุป conversation history, รักษาข้อมูลสำคัญ
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
จัดการ context window ให้ไม่เต็ม — auto-compact เมื่อใกล้ limit, ลบ tool result เก่า, สรุป conversation history, รักษาข้อมูลสำคัญ
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Pre/Post execution validation + Phase Gate enforcement — ป้องกันการข้าม step, auto-validate output, ให้คะแนน quality score
สแกน code ใน Scaffold/ ด้วย 53 security rules (6 หมวด) — secrets, permissions, injection, AI-specific, config, dependencies — ก่อน deploy หรือหลัง Dev report
Coordinate PM/Dev/QA agents แบบ Pipeline Pattern — auto-route งานตาม role, ส่งต่ออัตโนมัติเมื่อ status เปลี่ยน, track progress ทุก handoff
Create color-coded teaching scripts / presenter talking-point documents (.md) that serve as a "live reading book" for speakers. The output is a markdown file where each color tells the presenter what to do: blue = speak this line, red = pronunciation guide, dark blue = slide header, black = stage direction & audience engagement, yellow box = terminology. Use this skill whenever the user mentions: teaching script, talking points, presenter script, key talking point, speaker notes, lecture script, training script, presentation script, สคริปต์การสอน, สคริปต์วิทยากร, คำพูดที่ต้องอ่าน, หนังสือสำหรับพูด, or any request to create a document that guides a speaker through a slide deck with exact words to say, pronunciation help, and stage directions. Also trigger when the user uploads a PowerPoint (.pptx) and asks to write a script, narration, or talking points for it.
Use for QA evidence, release readiness, rollback review, and close-out decisions.
Use for build completion evidence, code review readiness, and ready-for-QA checks.
| name | Context Optimizer — Token Management |
| description | จัดการ context window ให้ไม่เต็ม — auto-compact เมื่อใกล้ limit, ลบ tool result เก่า, สรุป conversation history, รักษาข้อมูลสำคัญ |
ป้องกัน context window เต็มก่อนงานจะเสร็จ — auto-detect, compact, และ prioritize ข้อมูลสำคัญ
เมื่ออ่าน file ไปแล้ว ผลลัพธ์ tool_result จะกิน context — compact ได้:
Compactable tool results (ลบได้หลังใช้):
Read — เนื้อหาไฟล์ที่อ่านไปแล้ว (เก็บแค่ path + สรุป)Bash — output ของ command (เก็บแค่ exit code + สรุป)Grep — ผลค้นหา (เก็บแค่จำนวน match + key findings)Glob — รายชื่อไฟล์ (เก็บแค่จำนวน + pattern)Non-compactable (ห้ามลบ):
วิธี compact:
[เดิม] Read /path/to/large-file.md → {2000 lines of content}
[compact] Read /path/to/large-file.md → [File read: 2000 lines, key: {3-line summary}]
เมื่อ conversation ยาว — สรุปส่วนเก่า:
ก่อน read file — ประเมินว่าจำเป็นแค่ไหน:
| Situation | Action |
|---|---|
| ต้องการแค่ structure | อ่าน 50 บรรทัดแรก |
| ต้องการ specific section | ใช้ Grep หา แล้ว Read เฉพาะ offset |
| ไฟล์ใหญ่ (>500 lines) | อ่านเป็น chunk, สรุปแต่ละ chunk |
| ไฟล์ที่อ่านแล้วใน session นี้ | ใช้ summary จากครั้งก่อน |
เมื่อต้อง compact — เรียงลำดับความสำคัญ:
Priority 1 (ห้ามลบ):
- Current task instructions
- User decisions (ทุก decision ที่ user ตัดสินใจ)
- Active error context
- Project state (phase, status)
Priority 2 (สรุปได้):
- Completed task details → summary
- File contents read → path + key findings
- Command outputs → exit code + summary
Priority 3 (ลบได้):
- Exploration results ที่ไม่เกี่ยวกับ task ปัจจุบัน
- Duplicate reads (อ่านไฟล์เดิมซ้ำ)
- Verbose command output (ls, git log ยาวๆ)
| Context Usage | Action |
|---|---|
| <60% | ทำงานปกติ |
| 60-75% | เริ่ม compact tool results เก่า |
| 75-85% | Summarize completed tasks + compact aggressively |
| 85-95% | แนะนำ /compact + เก็บเฉพาะ Priority 1 |
| >95% | Emergency: สรุปทุกอย่างเป็น summary, แจ้ง user |
ก่อนเริ่มงานใหญ่ — ประเมิน token budget:
## Token Budget Estimate
- Current usage: ~{X}% of context window
- Available for this task: ~{Y} tokens
- Estimated task cost:
- File reads: {N} files × ~{avg} tokens = {total}
- Tool calls: {N} calls × ~{avg} tokens = {total}
- Output generation: ~{X} tokens
- **Verdict:** {sufficient / tight / insufficient — need compact first}
เมื่อ system ตรวจพบ context ใกล้เต็ม:
/compact เมื่อถึง 85%