我是如何将 Codex 每日 Token 消耗从 2.45 亿降至 2800 万且保持速度不变的(完全免费)

@TimJayas
ENGLISH1 month ago · Jun 08, 2026
172K
434
29
6
1.3K

TL;DR

本指南详细介绍了如何通过数据预压缩、命令输出限制以及结构化移交文件,在保持速度的同时大幅降低成本,将每日 LLM Token 消耗从 2.45 亿减少至 2800 万。

After the Codex promo ended and the real quotas kicked in I stared at my daily Codex burn limits faster.

So I found a system to reduce the amount of tokens I spend without effecting the speed.

One day: 245 million tokens

The next day after locking down my system: 28 million

Here’s exactly what I changed:

Step 1: Never Feed Raw Data, Always Pre-Compact It First

Codex doesn’t need your 40MB trade log massive JSON market dump or full repo every single turn. I now make it generate one-time helper scripts that create “needle maps”:

  • compact_logs.py → filters by timestamp/symbol/keyword and spits out only top N anomalies
  • summarize_data.py → extracts relevant columns, row counts, samples, and key stats
  • repo_map.py → builds a clean overview of entry points, config, core flows (skipping venv, node_modules, builds, etc.)

Feed it 200-500 tokens of distilled insight instead of 10k+ of noise.

Build once, reuse forever.

Step 2: Aggressively Limit Every Command Output

Default output is lethal:

  • git status
  • ls -la
  • cat file
  • python script. py

can explode context instantly.

I now bake limits into every instruction:

text
1head -n 50, tail -n 50, grep "ERROR" | head -n 30
2
3Write full results to temp files and only inspect ranges
4
5Add --limit 100 flags everywhere

Step 3: Build a Living Handoff File (Your Project Brain)

Stop letting agents rediscover everything every session.

I keep a tight HANDOFF.md (under 1k tokens) that holds:

  • Current goal + success metrics
  • Key files & recent decisions
  • Commands already run + outcomes
  • Known issues and “do not re-read” list
  • Next steps

End every session with: “Compact current findings into HANDOFF.md strip dead ends, keep only actionable facts.”

Step 4: Explicit “Do Not” Instructions Save Massive Tokens

Agents love to wander so I set hard walls:

  • “Skip node_modules, .venv, dist, logs/archive, generated files and any cache dir”
  • “Summarize before opening any new file”
  • “Never paste full source unless I explicitly say so”
  • “Only inspect files needed for this exact task”

Drop these into your AGENTS.md once and watch re-reads collapse.

Step 5: Demand Summaries, Diffs and Snippets

Bad prompt:

text
1Read this file and explain it.

Good prompt:

text
1Locate the risk engine’s position sizing logic. Show only that function + 3 lines above/below. Explain the edge case in one paragraph.

Or

text
1Build a 1-page repo map: entry points, config, main data flows and backtest commands. Skip vendor dirs.

Targeted asks = tiny context windows

Step 6: Make Codex Compact Its Own Context Periodically

Every 4-5 turns I drop:

text
1Summarize our progress into a tight handoff note. Remove repetitions and failed paths. Keep only what’s needed to continue.

Conversation stays lean even as it grows.

Step 7: Kill Verbosity by Default

text
1Be concise. Output only the patch + one-sentence reason. No restating the plan unless it changed. No fluff.

This one rule alone slashes output tokens hard.

Useful Commands & Helper Scripts I Deploy Daily

These are the exact one-liners and scripts I copy-paste or have Codex generate on day one of any project.

Core limiting commands I force on every tool call:

text
1# Safe file inspection
2head -n 80 somefile.py | cat
3tail -n 80 somefile.py | cat
4grep -n "KEYWORD" file.py | head -n 40
5
6# Git without the firehose
7git status --porcelain | head -n 30
8git log --oneline -15
9git diff --name-only | head -n 20
10
11# Data & logs (trading-specific)
12tail -n 200 market_log.json | jq '.[-50:]' | head -n 100
13python -c "import pandas as pd; df = pd.read_csv('trades.csv'); print(df.head(20).to_string())" | head -n 150
14
15# Write-then-inspect pattern
16python analyze_backtest.py > temp_results.txt 2>&1
17head -c 8000 temp_results.txt # byte cap for safety

**

Helper scripts I always ask Codex to create first (then run them myself):**

  • compact_logs.py → python compact_logs.py --symbol BTC --hours 24 > summary.txt
  • repo_map.py → python repo_map.py > HANDOFF.md (updates the brain file)
  • scan_errors.py → python scan_errors.py --limit 30 > errors.txt
  • summarize_json.py → python summarize_json.py market_snapshot.json > needle.txt

One killer AGENTS.md rule I live by (byte-cap everything unknown):

text
1## Command Output Protection
2Any command with unknown or potentially large output MUST be byte-capped.
3Default: COMMAND 2>&1 | head -c 6000
4If more is needed, write to temp file and I will inspect ranges only.

Prompt template I reuse for data-heavy tasks:

text
1First run compact_logs.py or summarize_data.py to create a <500-token needle map. Then analyze only that. Never read the raw file directly.

These commands and scripts alone cut my daily burn by another 30-40% on top of the big workflow changes.

**My New Rule of Thumb

Don’t let Codex read raw data if a 50-line summary would suffice**

The helpers I built in the first week pay for themselves every single hour.

Token efficiency wasn't a model problem instead It’s a systems problem, just nail the context discipline and you’ll get 8-10x more done inside the same quota.

I also build www.RedLeads.app so I find users for the things I ship faster. Join me in speedrunning to $10k MRR by vibecoding cool systems and tools.

Thank You :)

One-click save

Use YouMind for AI deep reading of viral articles

Save the source, ask focused questions, summarize the argument, and turn a viral article into reusable notes in one AI workspace.

Explore YouMind
For creators

Turn your Markdown into a clean 𝕏 article

When you publish your own long-form writing, images, tables, and code blocks make 𝕏 formatting painful. YouMind turns a full Markdown draft into a clean, ready-to-post 𝕏 article.

Try Markdown to 𝕏

More patterns to decode

Recent viral articles

Explore more viral articles