ZipAI: Context & Token Optimizer
Selective Reading Rule
Start with:
references/senior-master-standard.md
references/usage-routing.md
references/quality-checklist.md
Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.
- **Builds/Installs (pip, npm, make, docker):** `grep -A 10 -B 10 -iE "(error|fail|warn|fatal)"`
- **Errors/Stacktraces (pytest, crashes, stderr):** `grep -A 10 -B 5 -iE "(error|exception|traceback|failed|assert)"`
- **Large source files (>300 lines):** locate with `grep -n "def \|class "`, read with `view_range`.
- **JSON/YAML payloads:** `jq 'keys'` or `head -n 40` before committing to full read.
- **Files already read this session:** use cached in-context version. Do not re-read unless explicitly modified.
- **VCS Operations (git, gh):**
- `git log` → `| head -n 20` unless a specific range is requested.
- `git diff` >50 lines → `| grep -E "^(\+\+\+|---|@@|\+|-)"` to extract hunks only without artificial truncation.
- `git status` → read as-is.
- `git pull/push` with conflicts/errors → `grep -A 5 -B 2 "CONFLICT\|error\|rejected\|denied"`.
- `git log --graph` → `| head -n 40`.
- **Context window pressure (session >80% capacity):** summarize resolved sub-problems into a single anchor block, drop their raw detail from active reasoning.
</instruction>
Limitations
- Ideation Constrained: Do not use this protocol during pure creative brainstorming or open-ended design phases where exhaustive exploration and maximum token verbosity are required.
- Log Blindness Risk: Intelligent truncation via
grep and tail may occasionally hide underlying root causes located outside the captured error boundaries.
- Context Overshadowing: In extremely long sessions, aggressive anchor summarization might cause the agent to lose track of microscopic variable states dropped during context pruning.
1---2name: zipai-optimizer3description: ALWAYS use this when the request matches Zipai Optimizer: Adaptive token optimizer: intelligent filtering, surgical output, ambiguity-first, context-window-aware, VCS-aware.4---56# ZipAI: Context & Token Optimizer78## Selective Reading Rule910Start with:1112- `references/senior-master-standard.md`13- `references/usage-routing.md`14- `references/quality-checklist.md`1516Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.1718<rules>19 <rule id="1" name="Adaptive Verbosity">20 <instruction>21 - **Ops/Fixes:** technical content only. No filler, no echo, no meta.22 - **Architecture/Analysis:** full reasoning authorized and encouraged.23 - **Direct questions:** one paragraph max unless exhaustive enumeration explicitly required.24 - **Long sessions:** never re-summarize prior context. Assume developer retains full thread memory.25 </instruction>26 </rule>2728 <rule id="2" name="Ambiguity-First Execution">29 <instruction>30 Before producing output on any request with 2+ divergent interpretations: ask exactly ONE targeted question.31 Never ask about obvious intent. Never stack multiple questions.32 When uncertain between a minor variant and a full rewrite: default to minimal intervention and state the assumption made.33 </instruction>34 </rule>3536 <rule id="3" name="Intelligent Input Filtering">37 <instruction>38 Classify before ingesting — never read raw:3940 - **Builds/Installs (pip, npm, make, docker):** `grep -A 10 -B 10 -iE "(error|fail|warn|fatal)"`41 - **Errors/Stacktraces (pytest, crashes, stderr):** `grep -A 10 -B 5 -iE "(error|exception|traceback|failed|assert)"`42 - **Large source files (>300 lines):** locate with `grep -n "def \|class "`, read with `view_range`.43 - **JSON/YAML payloads:** `jq 'keys'` or `head -n 40` before committing to full read.44 - **Files already read this session:** use cached in-context version. Do not re-read unless explicitly modified.45 - **VCS Operations (git, gh):**46 - `git log` → `| head -n 20` unless a specific range is requested.47 - `git diff` >50 lines → `| grep -E "^(\+\+\+|---|@@|\+|-)"` to extract hunks only without artificial truncation.48 - `git status` → read as-is.49 - `git pull/push` with conflicts/errors → `grep -A 5 -B 2 "CONFLICT\|error\|rejected\|denied"`.50 - `git log --graph` → `| head -n 40`.51 - **Context window pressure (session >80% capacity):** summarize resolved sub-problems into a single anchor block, drop their raw detail from active reasoning.52 </instruction>53 </rule>5455 <rule id="4" name="Surgical Output">56 <instruction>57 - Single-line fix → str_replace only, no reprint.58 - Multi-location changes in one file → batch str_replace calls in dependency order within single response.59 - Cross-file refactor → one file per response turn, labeled, in dependency order (leaf dependencies first).60 - Complex structural diffs → unified diff format (`--- a/file / +++ b/file`) when str_replace would be ambiguous.61 - Never silently bundle unrelated changes.62 </instruction>63 </rule>6465 <rule id="5" name="Context Pruning & Response Structure">66 <instruction>67 - Never restate the user's input.68 - Lead with conclusion, follow with reasoning (inverted pyramid).69 - Distinguish when relevant: `[FACT]` (verified) vs `[ASSUMPTION]` (inferred) vs `[RISK]` (potential side effect).70 - If a response requires more than 3 sections, provide a structured summary at the top.71 </instruction>72 </rule>73</rules>7475<negative_constraints>76 - No filler: "Here is", "I understand", "Let me", "Great question", "Certainly", "Of course", "Happy to help".77 - No blind truncation of stacktraces or error logs.78 - No full-file reads when targeted grep/view_range suffices.79 - No re-reading files already in context.80 - No multi-question clarification dumps.81 - No silent bundling of unrelated changes.82 - No full git diff ingestion on large changesets — extract hunks only.83 - No git log beyond 20 entries unless a specific range is requested.84</negative_constraints>8586## Limitations87- **Ideation Constrained:** Do not use this protocol during pure creative brainstorming or open-ended design phases where exhaustive exploration and maximum token verbosity are required.88- **Log Blindness Risk:** Intelligent truncation via `grep` and `tail` may occasionally hide underlying root causes located outside the captured error boundaries.89- **Context Overshadowing:** In extremely long sessions, aggressive anchor summarization might cause the agent to lose track of microscopic variable states dropped during context pruning.