Code graph tools demote Opus/GPT to cannon fodder.
Hedge Coding promotes Opus/GPT to supreme commander.
Philosophy • How It Works • Architecture • Quick Start • Features • Roadmap • 🇨🇳 中文文档
Every developer who's used an AI assistant has hit this wall:
"My code worked. I asked the AI to optimize one module. It deleted critical logic it thought was redundant — because it couldn't see the other 9 modules that depended on it."
This isn't an AI being dumb. It's an architectural failure:
- The agent's context window fills with tool-call results during exploration
- By the time it edits code, the global topology has been pushed out of attention
- Local optimization runs blind to global structure
Hedge Coding fixes this at the architectural layer:
- Tree-sitter generates a Repo Map of every module's signatures — compact enough to stay resident through the entire task
- The Super Prompt is pre-assembled with full dependency context, then handed to Opus/GPT as a single block
- Opus/GPT never has to choose between "see the local code" and "see the global structure" — it has both, at all times, with zero token round-trips
Your working code stays working. Optimization doesn't mean amnesia.
Across benchmarks, prompt quality — context precision, instruction grounding, and signal-to-noise ratio — governs ~50% of output quality. The model tier contributes ~35%, the toolchain ~15%.
A frontier model starved of context degrades to below-baseline performance. A mid-tier model fed surgical, high-signal context routinely outperforms it. The ceiling is not the model's weights — it's what fills its context window.
Hedge Coding is architected around this single constraint: maximize context precision before a single inference token is spent.
Standard AI coding assistants burn ~70% of tokens on blind exploration — scanning directories, re-reading files, building context from scratch. That's not investing, that's gambling.
| Phase | Role | What Happens | Cost |
|---|---|---|---|
| ① Tactical Intel | Real-time Sync | Tree-sitter AST extracts every function signature into a surgical Repo Map (~2K–5K tokens) | Free |
| ② Scout | Budget Model | Classifies task complexity, selects relevant files, filters Skills, refines the goal | ~$0.001 |
| ③ Combat Commander | XML Assembler | Selected files + execution plan + Skills → structured Super Prompt | Free |
Paste the Super Prompt into any AI tool. Watch any model become a surgical instrument.
| Metric | Standard AI Coding | Hedge Coding | Hedge Yield |
|---|---|---|---|
| Token Cost | $1.95 (290K tokens) | $0.94 (60K tokens) | 52% Savings |
| First-Try Success | ~40% Hallucinations | ~85% Surgical | +45% Accuracy |
| Context Waste | Re-reading irrelevant files | Zero-waste targeting | Compute → Logic |
| Pro Quota | Exhausted in 3–7 days | 2× longer output | +10 days runway |
The pipeline cost per task is ~$0.002. But the real alpha isn't the savings — it's the first-try success rate.
You type a Goal
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ HEDGE CODING ENGINE (Rust) │
│ │
│ ① Scan ──→ File system walk + .gitignore filtering │
│ ② Parse ──→ Tree-sitter AST: functions, classes, exports │
│ ③ Cache ──→ Load Deep Analysis semantic summaries │
│ ④ Scout ──→ Budget model classifies task + selects files │
│ ⑤ Intel ──→ Git diff detection (MEDIUM/LARGE tasks) │
│ ⑥ Skills ─→ Filter & inject relevant skill bodies │
│ ⑦ Compile → Assemble layered XML Super Prompt │
│ ⑧ Save ──→ Persist to .hedgecoding/tasks/ with metadata │
│ │
└───────────────────────────┬─────────────────────────────────────┘
│
▼
Super Prompt (XML)
│
▼
Copy → Paste into ANY AI tool
Claude Code / Cursor / ChatGPT / Windsurf / API
The Super Prompt is not a flat context dump. It's a layered intelligence dossier — each layer serves a specific cognitive purpose:
<project_memory> <!-- Layer 0: Project rules from MEMORY.md -->
<user_goal> <!-- Layer 1: Refined goal (by budget model) -->
<repo_map> <!-- Layer 2: AST-based file + symbol map -->
<file_intelligence> <!-- Layer 3: Semantic summaries (Deep Analysis) -->
<skills_context> <!-- Layer 4: Filtered project-specific skills -->
<target_files> <!-- Layer 5: Smart-selected full source code -->
<battlefield_changes> <!-- Layer 6: Git working tree diff -->
<execution_instructions><!-- Layer 7: Task-specific guidance -->The budget model classifies every task and adapts the prompt accordingly:
| Task Size | Files Included | Git Diff | File Intel | Typical Tokens |
|---|---|---|---|---|
| Small | 1–5 (surgical) | ✗ Skip | ✗ Skip | ~5K–15K |
| Medium | 5–15 (targeted) | ✓ Inject | ✓ Inject | ~15K–45K |
| Large | 15+ (comprehensive) | ✓ Inject | ✓ Inject | ~30K–80K |
Small tasks intentionally strip context. Less noise = higher precision for simple fixes.
┌──────────────────────────────────────────────────────────────────────┐
│ HEDGE CODING │
│ │
│ ┌─────────────────────┐ ┌────────────────────────┐ │
│ │ FRONTEND (React) │ Tauri IPC │ BACKEND (Rust) │ │
│ │ │◄────────────►│ │ │
│ │ Compiler.tsx │ │ server.rs (IPC Hub) │ │
│ │ SuperPrompt.tsx │ │ scanner.rs │ │
│ │ RepoMap.tsx │ │ parser.rs (Tree-sitter│) │
│ │ Skills.tsx │ │ repo_map.rs │ │
│ │ CodeReview.tsx │ │ analyzer.rs (LLM API) │ │
│ │ DocGen.tsx │ │ compiler.rs (XML) │ │
│ │ app-state.tsx │ │ git_intel.rs │ │
│ │ tauri.ts (Bridge) │ │ watcher.rs (notify) │ │
│ │ │ │ token_counter.rs │ │
│ └─────────────────────┘ └────────────────────────┘ │
│ │
│ Tech Stack: │
│ • Tauri v2 — Native desktop shell, ~3MB binary │
│ • Tree-sitter — JS/TS/Python/Rust AST parsing │
│ • tiktoken-rs — Accurate token counting (GPT tokenizer) │
│ • git2 (libgit2) — Native Git diff without shell │
│ • notify — Real-time filesystem watching │
│ • reqwest — HTTP client for budget model API calls │
└──────────────────────────────────────────────────────────────────────┘
Step 1 User types goal in Compiler panel
↓
Step 2 Frontend sends IPC: compilePrompt(goal, files, skills, memory)
↓
Step 3 Rust re-scans filesystem + re-parses AST (always fresh)
↓
Step 4 Load Deep Analysis cache (.hedgecoding/analysis_cache.json)
↓
Step 5 ⭐ Budget model: classify_and_refine()
→ Task size (SMALL / MEDIUM / LARGE)
→ Refined goal (references specific functions)
→ Target files (smart selection, 1-20 files)
→ Execution instructions (2-4 task-specific notes)
→ Relevant skills (filtered from available set)
↓
Step 6 Git diff injection (MEDIUM/LARGE only)
↓
Step 7 Skills full-body injection (filtered by budget model)
↓
Step 8 compiler.rs assembles 8-layer XML
↓
Step 9 Save to .hedgecoding/tasks/{project}_{timestamp}.md
↓
Step 10 Frontend renders bubble card → user copies to clipboard
Every component degrades gracefully. No single failure breaks the pipeline:
| Condition | Behavior |
|---|---|
| No budget model configured | Skip classification → use all files |
| Classification returns invalid JSON | Fall back to all files |
| Smart selection returns 0 files | Fall back to all files |
| No Deep Analysis cache | Skip <file_intelligence> layer |
| No Git repository | Skip <battlefield_changes> layer |
| No Skills configured | Skip <skills_context> layer |
| No MEMORY.md | Skip <project_memory> layer |
Multi-language structural parsing — extracts every function, class, struct, interface, enum, and export into a compact symbol map. Supports JavaScript, TypeScript, Python, Rust with generic fallback for other languages.
Budget model generates one-line semantic summaries for every file. Pre-computed and cached — zero cost at compile time. Gives the receiving model a complete understanding of your codebase without reading a single file.
Budget model reads your goal + repo map and selects only the files that matter. Reduces Super Prompt size by 60–80% compared to including everything.
Mount reusable development rules as .hedgecoding/skills/*.md files. Each skill carries a when_to_use field. The budget model automatically filters relevant skills per task — zero-distortion, full-body injection into the Super Prompt.
Persistent rules in .hedgecoding/MEMORY.md are compiled inside every Super Prompt. Your project conventions travel with the prompt into any AI tool — Claude Code, Cursor, ChatGPT, or a raw API call.
Live cost projections across 7 premium models — Claude Opus 4.6, Sonnet 4.6, Gemini 3.1 Pro, GPT-5.4, and more. Know exactly what each token costs before you pull the trigger.
Full-text regex search across your entire codebase — find any symbol, pattern, or TODO instantly. Zero tokens spent.
Paste a git diff and compile a security-focused review Super Prompt. Uses the Verification Agent methodology: three-phase analysis with severity scoring and adversarial probes.
Generate comprehensive documentation by feeding full source context to any model. Supports Docusaurus, VitePress, GitBook, MkDocs, and plain Markdown.
Real-time file change detection via the notify crate. Auto-invalidates stale analysis cache entries and keeps the Repo Map fresh.
Once the first release is published, you can install Hedge Coding instantly without compiling.
irm https://raw.githubusercontent.com/edison7009/hedge-coding/main/install.ps1 | iexcurl -fsSL https://raw.githubusercontent.com/edison7009/hedge-coding/main/install.sh | bashBuild from Source (For Developers)
Prerequisites: Rust (stable) + Node.js (v18+)
git clone https://github.com/edison7009/hedge-coding.git
cd hedge-coding
cargo install tauri-cli --version "^2"
cd src-ui && npm install && npm run build && cd ..
cargo tauri build
# Installer → target\release\bundle\nsis\Hedge Coding_*.exegit clone https://github.com/edison7009/hedge-coding.git
cd hedge-coding
cargo install tauri-cli --version "^2"
cd src-ui && npm install && npm run build && cd ..
cargo tauri build
# App → target/release/bundle/dmg/Hedge Coding_*.dmgsudo apt install libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev
git clone https://github.com/edison7009/hedge-coding.git
cd hedge-coding
cargo install tauri-cli --version "^2"
cd src-ui && npm install && npm run build && cd ..
cargo tauri build
# Output → target/release/bundle/deb/hedge-coding_*.debAfter installation, launch Hedge Coding from your desktop — no terminal needed.
Create ~/.HedgeCoding/models.json:
{
"modelId": "deepseek-chat",
"baseUrl": "https://api.deepseek.com/v1",
"apiKey": "sk-your-key-here"
}Any OpenAI-compatible API works: DeepSeek, Minimax, local Ollama, vLLM, etc.
Coding like a hedge fund — precision, risk aversion, and asymmetric returns.
| # | Rule | Core Insight |
|---|---|---|
| I | Master session hygiene | Fresh session + Super Prompt = full context, zero ramp-up |
| II | Route tasks to the right tier | Don't burn $5/M tokens on boilerplate work |
| III | Lead with location, not discovery | File path + line number > "find the bug" |
| IV | Never pay twice to read the same file | Super Prompt compiles once, zero repeat exploration |
| V | Filter your knowledge library | Only relevant skills get injected per task |
| VI | Super Prompt is self-contained | Project rules travel inside the prompt to any tool |
| VII | Plan before you code | Get the plan right before generating production code |
| VIII | Engineer your goal description | Your goal is the inference quality ceiling |
| IX | Read everything. Write nothing. | Hedge Coding is read-only by design. You stay in control. |
| Capability | Claude Code | Cursor | Hedge Coding |
|---|---|---|---|
| File reading | ✓ Runtime, costs tokens | ✓ Runtime | ✓ Pre-compiled, free |
| Codebase understanding | Re-learns every session | Partial indexing | Persistent, layered |
| Token efficiency | ~70% wasted on exploration | Similar | Zero-waste targeting |
| Tool-agnostic | Claude only | Cursor only | Works everywhere |
| Cost visibility | Hidden | Hidden | Hedge Ledger |
| Git-aware context | Partial | Partial | Diff injected into prompt |
| Smart file selection | Reads everything | RAG-based | Budget model pre-selects |
| Session continuity | Context lost on new session | Similar | Super Prompt carries all |
- Phase 1 — Core Engine: Scanner, Tree-sitter Parser, Repo Map, XML Compiler, Token Counter
- Phase 2 — Desktop App: Tauri v2 native shell with React UI
- Phase 3 — Budget Model Integration: Deep Analysis, Smart File Selection, Task Classification
- Phase 4 — Skills System: Zero-distortion full-body injection with
when_to_usefiltering - Phase 5 — Project Memory: MEMORY.md compiled into every Super Prompt
- Phase 6 — Git Intelligence: Working tree diff injection, filesystem watcher
- Phase 7 — Code Review: Security-focused review prompt compiler
- Phase 8 — Super Docs: Multi-format documentation generation
MIT
Hedge Coding — The Military Strategist for AI Coding.
We read everything. We write nothing.
We compile the most precise intelligence dossier in the industry.
Paste it into any tool. Watch any model become a surgical instrument.



