Token-Efficient Workflow
Goal
Complete the task correctly while minimizing unnecessary context growth. Save tokens by reading less irrelevant data, not by skipping necessary reasoning, validation, or user-facing functionality.
Default Operating Rules
- Start with the narrowest useful evidence.
- Prefer targeted reads over project-wide scans.
- Summarize large outputs before continuing analysis.
- Expand scope only when the current evidence is insufficient.
- Preserve quality: do not omit required verification just to save tokens.
Task Intake
Before using tools, identify:
- The exact artifact or behavior being investigated.
- The likely high-signal files, routes, logs, configs, or UI elements.
- The smallest command or read that can confirm the next fact.
If the request is broad, translate it into a narrow first pass. For example, treat "fully understand this project" as "identify framework, entrypoints, config, routes, and the files most likely relevant to the requested task."
Codebase Search
Use rg first when searching text or files, but constrain it:
- Prefer
rg -n "specific term" path\to\likely\dir over repository-wide search.
- Prefer
rg --files path\to\likely\dir over rg --files at project root.
- Use focused keywords from errors, route names, table names, function names, class names, config keys, or visible UI labels.
- Avoid recursive broad searches for generic words like
token, config, admin, index, error, or install unless paired with a narrow path or additional terms.
- If a command may produce many lines, limit output with a focused path, stricter pattern, or a small post-filter.
When a broad scan is necessary, explain why and run it once. Do not repeat full scans after every user message.
File Reading
Read files in this order when applicable:
- Small metadata files: package manifests, composer files, framework config, route definitions.
- Entrypoints and bootstrapping files.
- The specific controller, model, service, view, migration, or script implicated by the task.
- Logs around the relevant timestamp or error.
- Broader project structure only if the above do not explain the issue.
For large files, read headers, schemas, specific sections, or sampled rows first. Do not load complete Excel, Word, SQL dump, JSON export, logs, or generated files into context unless the task requires full-file analysis.
Tool Output Discipline
After any large tool output:
- Extract the key facts, paths, line numbers, and next action.
- Do not paste or restate long raw output to the user.
- Do not base the next step on the entire raw output when a concise working summary is enough.
If output is truncated, treat truncation as a signal to narrow the next command rather than rerun the same broad command.
Browser Debugging
When using the in-app browser or browser automation:
- Inspect only the current task's relevant page state, element, console error, network request, or form value.
- Avoid repeated full-page captures when the URL and target area have not changed.
- For UI bugs, capture the minimum evidence: current URL, visible error text, relevant element state, console/network error, and reproduction step.
- After browser inspection, write a short state summary and continue from that summary.
Long Conversation Handling
In long tasks, periodically maintain a compact working summary:
- Current goal.
- Confirmed facts.
- Files changed or inspected.
- Decisions made.
- Remaining unknowns.
- Next command or edit.
When the user says "continue", resume from this summary. Do not rescan the entire project unless the summary is stale or contradicted.
PHP/ThinkPHP and Deployment Tasks
For the user's common PHP/ThinkPHP and deployment work:
- Check framework version, entrypoint, route config, environment config, database config, runtime logs, and web server config before broad source searches.
- For 404/install/admin/login issues, inspect routing, public document root, rewrite rules, controller paths, and recent logs first.
- For deployment issues, inspect required env vars, database connectivity, runtime version, build/start commands, and one relevant failing log excerpt.
- Avoid dumping all routes, all controllers, all database rows, or all logs unless needed.
Large Documents and Data Files
For Excel, Word, PDF, SQL, JSON, CSV, and log-heavy tasks:
- First inspect file size, sheet names, headings, schema, row count, or document structure.
- Read only the relevant sheet, range, section, or error window.
- Use scripts or structured parsers when available.
- Keep extracted data summaries compact and task-specific.
User Communication
Use concise Chinese by default. Keep updates useful:
- Say what narrow evidence is being gathered.
- Say when scope is being expanded and why.
- In the final response, include the cause, what changed or was checked, verification result, and any next step.
Do not make the user choose between quality and token savings. The workflow should save tokens by avoiding irrelevant work while still completing and validating the task.
1---2name: token-efficient-workflow3description: Always-on token-efficient Codex workflow for every project, conversation, and request. Use for all Codex tasks to save context and quota without reducing model quality or task completion, especially codebase investigation, PHP/ThinkPHP debugging, deployment, logs, browser inspection, long conversations, and large files such as Excel, Word, exports, and command outputs.4---56# Token-Efficient Workflow78## Goal910Complete the task correctly while minimizing unnecessary context growth. Save tokens by reading less irrelevant data, not by skipping necessary reasoning, validation, or user-facing functionality.1112## Default Operating Rules13141. Start with the narrowest useful evidence.152. Prefer targeted reads over project-wide scans.163. Summarize large outputs before continuing analysis.174. Expand scope only when the current evidence is insufficient.185. Preserve quality: do not omit required verification just to save tokens.1920## Task Intake2122Before using tools, identify:2324- The exact artifact or behavior being investigated.25- The likely high-signal files, routes, logs, configs, or UI elements.26- The smallest command or read that can confirm the next fact.2728If the request is broad, translate it into a narrow first pass. For example, treat "fully understand this project" as "identify framework, entrypoints, config, routes, and the files most likely relevant to the requested task."2930## Codebase Search3132Use `rg` first when searching text or files, but constrain it:3334- Prefer `rg -n "specific term" path\to\likely\dir` over repository-wide search.35- Prefer `rg --files path\to\likely\dir` over `rg --files` at project root.36- Use focused keywords from errors, route names, table names, function names, class names, config keys, or visible UI labels.37- Avoid recursive broad searches for generic words like `token`, `config`, `admin`, `index`, `error`, or `install` unless paired with a narrow path or additional terms.38- If a command may produce many lines, limit output with a focused path, stricter pattern, or a small post-filter.3940When a broad scan is necessary, explain why and run it once. Do not repeat full scans after every user message.4142## File Reading4344Read files in this order when applicable:45461. Small metadata files: package manifests, composer files, framework config, route definitions.472. Entrypoints and bootstrapping files.483. The specific controller, model, service, view, migration, or script implicated by the task.494. Logs around the relevant timestamp or error.505. Broader project structure only if the above do not explain the issue.5152For large files, read headers, schemas, specific sections, or sampled rows first. Do not load complete Excel, Word, SQL dump, JSON export, logs, or generated files into context unless the task requires full-file analysis.5354## Tool Output Discipline5556After any large tool output:5758- Extract the key facts, paths, line numbers, and next action.59- Do not paste or restate long raw output to the user.60- Do not base the next step on the entire raw output when a concise working summary is enough.6162If output is truncated, treat truncation as a signal to narrow the next command rather than rerun the same broad command.6364## Browser Debugging6566When using the in-app browser or browser automation:6768- Inspect only the current task's relevant page state, element, console error, network request, or form value.69- Avoid repeated full-page captures when the URL and target area have not changed.70- For UI bugs, capture the minimum evidence: current URL, visible error text, relevant element state, console/network error, and reproduction step.71- After browser inspection, write a short state summary and continue from that summary.7273## Long Conversation Handling7475In long tasks, periodically maintain a compact working summary:7677- Current goal.78- Confirmed facts.79- Files changed or inspected.80- Decisions made.81- Remaining unknowns.82- Next command or edit.8384When the user says "continue", resume from this summary. Do not rescan the entire project unless the summary is stale or contradicted.8586## PHP/ThinkPHP and Deployment Tasks8788For the user's common PHP/ThinkPHP and deployment work:8990- Check framework version, entrypoint, route config, environment config, database config, runtime logs, and web server config before broad source searches.91- For 404/install/admin/login issues, inspect routing, public document root, rewrite rules, controller paths, and recent logs first.92- For deployment issues, inspect required env vars, database connectivity, runtime version, build/start commands, and one relevant failing log excerpt.93- Avoid dumping all routes, all controllers, all database rows, or all logs unless needed.9495## Large Documents and Data Files9697For Excel, Word, PDF, SQL, JSON, CSV, and log-heavy tasks:9899- First inspect file size, sheet names, headings, schema, row count, or document structure.100- Read only the relevant sheet, range, section, or error window.101- Use scripts or structured parsers when available.102- Keep extracted data summaries compact and task-specific.103104## User Communication105106Use concise Chinese by default. Keep updates useful:107108- Say what narrow evidence is being gathered.109- Say when scope is being expanded and why.110- In the final response, include the cause, what changed or was checked, verification result, and any next step.111112Do not make the user choose between quality and token savings. The workflow should save tokens by avoiding irrelevant work while still completing and validating the task.