codex-quota-optimizer
Optimize Codex Plus/Pro usage before and during coding tasks. Use when the user wants to save Codex quota/credits, reduce token or context waste, choose a cheaper model/reasoning level, avoid unnecessary repo scans/tests/subagents, or plan an implementation with the smallest reliable execution footprint. Do not use when the user explicitly prioritizes maximum quality regardless of usage.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 490
01 前言 Front Matter
- name
- codex-quota-optimizer
- description
- Optimize Codex Plus/Pro usage before and during coding tasks. Use when the user wants to save Codex quota/credits, reduce token or context waste, choose a cheaper model/reasoning level, avoid unnecessary repo scans/tests/subagents, or plan an implementation with the smallest reliable execution footprint. Do not use when the user explicitly prioritizes maximum quality regardless of usage.
02 资源文件 11
- 参考文档agents/openai.yaml521 B
- 资产文件assets/icon.svg571 B
- 参考文档references/anti-patterns.md838 B
- 参考文档references/context-policy.md971 B
- 参考文档references/current-openai-notes.md1.2 KB
- 参考文档references/model-routing.md1.1 KB
- 参考文档references/test-policy.md815 B
- 参考文档references/zero-friction.md2.6 KB
- 脚本scripts/change_scope.py1.6 KB
- 脚本scripts/cqo.py17.9 KB
- 脚本scripts/repo_snapshot.py3.1 KB
03 SKILL.md 正文
Codex Quota Optimizer
Optimize for useful work per unit of Codex allowance, not for the shortest answer.
0. Operating principle
Use the cheapest execution path that can still meet the acceptance criteria. Escalate only when evidence shows the cheaper path is insufficient.
Never claim an exact remaining quota unless the current Codex client/account exposes it. If quota state matters, tell the user to check /status or the usage dashboard, then continue with the best available strategy.
Zero-friction invariant
The optimizer must not become the overhead.
- Do not make an additional model call just to classify or budget a task.
- Do not add network requests for CQO classification, journaling, or auditing.
- Do not put a blocking budget gate in front of normal Codex execution.
- Do not ask the user for confirmation merely because a soft budget was exceeded.
- Do not spawn subagents on CQO's behalf.
- The Skill must remain fully useful when the optional
cqoCLI is never installed or run.
See references/zero-friction.md.
1. Read only what you need
Before broad exploration:
- Inspect the task request, current diff, and repository instructions (
AGENTS.md). - Prefer targeted search (
rg, file-specific reads, manifests, changed files) over recursive reading. - If the repository is unfamiliar, run
scripts/repo_snapshot.py --compactonce before opening many files. - Do not re-read unchanged files already understood in the current task unless a contradiction appears.
- Read generated/vendor/build directories only when directly relevant.
See references/context-policy.md for detailed rules.
2. Classify the task before execution
Assign one class internally as part of the existing reasoning turn. Do not call another model solely to perform classification.
- XS — one-file, mechanical, obvious acceptance criteria.
- S — narrow feature/fix, 1–3 files, known pattern.
- M — several files, modest design judgment or integration.
- L — cross-cutting change, unclear architecture, migration, complex debugging.
- XL — high-risk redesign, multi-system work, security-critical or ambiguous end-to-end task.
Then choose the lowest adequate model/reasoning path:
- XS/S: prefer Luna or the fastest/cheapest available setting, low reasoning.
- M: prefer Terra, low/medium reasoning.
- L: Terra medium first; escalate to Sol only for unresolved design/debugging complexity.
- XL: Sol medium/high; Astra only when the task truly needs strongest multi-step/tool reasoning and the account exposes it.
Availability varies by plan/client. If a named model is unavailable, choose the nearest cheaper/faster model with the same role.
Do not use Max/Ultra by default. Do not spawn subagents merely because they are available.
See references/model-routing.md.
3. Use an execution budget
For every non-trivial task, maintain this internal budget:
- Discovery budget: enough reads/searches to locate the change surface.
- Edit budget: minimum files required to satisfy acceptance criteria.
- Verification budget: targeted checks first; broad checks only at the final gate or when evidence demands them.
These are soft budgets, never execution gates:
- Stop discovery once the relevant dependency path is understood.
- Stop editing once acceptance criteria are met; avoid opportunistic refactors.
- Stop verification after relevant tests/type/lint checks pass unless the change is high risk.
- If another file, test, or reasoning step is required for correctness, continue without interrupting the user.
- If scope expands, reclassify internally and keep moving; do not request permission just because the initial budget was too small.
4. Plan economically
For S/M/L/XL tasks, state or maintain a compact plan with:
- target behavior,
- likely files,
- minimal verification,
- escalation trigger.
Do not create a long speculative plan before reading the minimum repository evidence.
Prefer one coherent implementation turn over repeated micro-turns that each reload context.
5. Edit minimally
- Change the smallest coherent surface.
- Reuse existing helpers, patterns, components, and tests.
- Avoid formatting unrelated files.
- Avoid dependency upgrades unless required.
- Avoid generated-file churn unless generation is part of the task.
- Batch logically related edits rather than repeatedly opening/editing the same file.
When a task can be solved by configuration or a small local patch, do not introduce a framework or abstraction layer.
6. Verify in layers
Run checks in this order:
- syntax/format check for touched files,
- focused unit/component test for touched behavior,
- focused type/lint check,
- broader package/app test only if needed,
- full suite only for cross-cutting/high-risk changes or before a release gate.
Do not repeatedly run the same expensive full suite after tiny edits. If a broad test fails for an unrelated pre-existing reason, record it and continue with focused verification.
See references/test-policy.md.
7. Control context growth
At natural checkpoints, compress working state into a short handoff note:
- goal,
- decisions,
- files changed,
- tests run/results,
- remaining issue.
Use the checkpoint instead of restating the entire conversation or repository history.
For long tasks, create/update a small local scratch note only if it prevents repeated exploration. Remove it before finalizing unless the project wants it committed.
8. Avoid expensive anti-patterns
Never do these by default:
- scan the entire repository when a targeted search can locate the feature,
- open large lockfiles, minified bundles, generated output, or vendor trees without need,
- run full test suites before identifying the change surface,
- use high/xhigh/max/ultra reasoning for routine edits,
- use multiple subagents for a task one agent can do cheaply,
- ask Codex to rewrite whole files when a patch is sufficient,
- repeatedly summarize information already present in the current context,
- refactor adjacent code “while here” without user value,
- browse the web when repository/local docs are enough,
- perform duplicate searches with equivalent queries.
See references/anti-patterns.md.
9. Escalate deliberately
Escalate model/reasoning/tool breadth only when at least one trigger is present:
- two focused attempts fail for reasons not explained by local evidence,
- architecture is ambiguous and wrong choice would cause broad rework,
- failure spans multiple subsystems,
- security/data-loss/migration risk is meaningful,
- acceptance criteria conflict,
- targeted verification exposes hidden coupling.
Before escalation, summarize what is known so the stronger model does not need to rediscover it.
10. Plus vs Pro behavior
Do not hardcode plan quotas into decisions. Use the same efficiency policy for both plans, with different default aggressiveness:
- Plus: default to
economybehavior — Luna/Terra first, focused checks, strict scope control. - Pro: default to
balancedbehavior — Terra first, Sol when complexity justifies it; still avoid waste because Pro allowance is finite and may be shared with other agentic features.
If the user says quota is nearly exhausted, enter emergency mode:
- no broad exploration,
- no optional refactors,
- no subagents,
- cheapest adequate model,
- one implementation path,
- focused verification only,
- produce a concise continuation note if completion is impossible in the current turn.
11. User-facing output
When useful, end with a compact Usage choices note containing only actionable items such as:
- “This is an S task; Luna/low is sufficient.”
- “Use Terra/medium for implementation; reserve Sol for the migration edge case.”
- “Run the focused test now; defer the full suite until final review.”
Do not clutter every answer with quota commentary if the skill is operating successfully in the background.
12. Optional local observability
The cqo CLI is optional. It provides task-level classification, soft budgets, a local journal, and a local audit:
cqo start <task>cqo statuscqo auditcqo history
The journal is local-only under ~/.cqo (or CQO_HOME). It does not inspect private account pages or estimate hidden quota.
Never run cqo automatically just to collect analytics. The CLI is an inspection layer, not a runtime dependency. If the user did not opt into a CQO session, normal Skill behavior continues with zero CLI overhead.
13. Optional helper scripts
scripts/repo_snapshot.py --compact— compact project map without reading the whole repo.scripts/change_scope.py— summarize current Git change surface and suggest verification scope.scripts/cqo.py— optional zero-network local CLI for task-level budgeting and auditing.
Use scripts only when they save model context/tool calls or the user explicitly wants observability; do not run them ritualistically.
04 同仓库更多 Skills
migrate-to-e2e
Moves an existing Playwright, Cypress, Selenium, Appium, Detox, Maestro, or TesterArmy suite to e2e one slice at a time, with the old suite running beside the new one until each ported test is proven. Keeps a MIGRATION.md progress file so any later session resumes where the last stopped. Optionally plants a defect to show both suites catch it. Use for /migrate-to-e2e, "migrate our tests to e2e", "port these Maestro flows", "move our TesterArmy tests", or when a project has an e2e config and an older suite still running.
e2e
Writes, runs, and debugs end-to-end tests for web and mobile apps with e2e, the agentic test runner, which mixes agent.act goals with exact locator assertions on a Playwright browser or an iOS or Android device. Also drives a project's running app live over the e2e MCP server to look at a screen, check a UI change, take a screenshot or record a video, and try a locator; and runs bug bashes, parallel e2e explore runs with each bug proven by a repro test. Use when a project depends on e2e or has an e2e.config.ts, when asked for end-to-end, browser, mobile, or agentic UI tests, to check a change in the running app, to QA or bug bash an app or branch, or when an e2e run fails.
create-verification-skill
Generate a project-local verify-<app> skill on top of e2e, so any coding agent can launch the app, check it is worth driving, exercise a feature the way a user does, keep evidence, and bug bash it. Writes the skill, a feature map with one explore charter per feature, and proves it once. Use for /create-verification-skill, "make a verification skill for this repo", or when a project has no scripted way to prove UI behavior.
deja-search
deja-vu memory — search the user's past AI coding sessions with the deja CLI. Holds what they already settled and never wrote into the repo (naming rules, banned or already-tried tools, required checks before merge, preferred values, who owns what). Use before your first edit in a task, before you call a change done or ready to merge, before you recommend a tool, library, design or reviewer, before re-debugging an error that may already be solved, when they say 'didn't we fix this before', 'what did we decide about X' or 'I already have that', and before telling them something on this machine does not exist.
deja-reflect
End-of-session reflection and memory curation with deja-vu. Review what was decided, what commands broke and what repaired them, and record durable project rules or decisions with deja remember so the next session starts with them.
revid
Make, edit, export and post AI videos with Revid (revid.ai) through the Revid MCP server. Use whenever the user wants a short-form or long-form video made (from an idea, a script, a URL, an article, a PDF, a tweet, a product page, their own clips, or a song), wants to find what is going viral on TikTok, YouTube, Instagram or X before making something, wants to edit or re-export an existing Revid project, generate a standalone AI image or clip, make a series episode, or publish and schedule a finished video to connected social accounts. Covers setup (hosted MCP with OAuth, or an API key), the 36 tools, credits, polling and the rules for publishing. Routes to the more specific revid-* skills when one fits.