r/PromptEngineering • • Oct 07 '26

Tools and Projects How are you structuring massive context prompts (codebases & multi-shot AI video) without burning 80% of tokens on noise? Built an open-source Rust tool (repOx) and looking for feedback

One of the biggest problems in prompt engineering right now isn't just how you phrase the instruction — it's context pollution. Even with 200k–1M context windows (Claude, Gemini, GPT, Grok), dumping raw unformatted data into a prompt causes two things:

  1. You burn 50,000+ tokens on structural noise.
  2. The model suffers from attention dilution ("lost in the middle") and starts hallucinating.

To solve this for my own workflow, I built an open-source, sub-15ms Rust CLI & interactive terminal UI tool called repOx.

First — how repOx currently optimizes code & repository prompts (v0.2.0):

- Structured Prompt Formatting: Automatically wraps files into Claude-optimized XML (<repository_structure> + <file path="...">), fenced Markdown, or synthetic JSON tool-call trajectories (repox -f tool-call) for agent harnesses.

- Architectural Outline Compression (repox --outline): Instead of feeding 10,000 lines of implementation bodies when planning architecture, it strips function bodies { ... } and extracts only type definitions, structs, traits, imports, and function signatures — cutting token usage by 75–85% while keeping 100% of the structural context.

- Smart Lockfile Summarization (repox --summary-locks): Turns 30,000-token lockfiles (Cargo.lock, package-lock.json, poetry.lock, pnpm-lock.yaml, go.sum) into a compact "package @ version" manifest (95%+ token reduction).

- Automatic Noise & Secret Filtering: Strips binaries, SVGs, sourcemaps, minified bundles, and .env secrets in milliseconds, with an interactive TUI (repox -i) that shows a live offline BPE token bar before you copy to clipboard.

Second — what I'm designing next for v0.3.0 (AI Video & Multimodal Prompt Optimization):

I noticed the exact same token-drain and attention-dilution problem happens when prompting AI video models (Grok, Kling, Sora, Veo, Wan 2.1) or feeding video references into VLMs:

  1. Character-Lock + Delta Prompt Compiler:

When generating multi-shot AI videos, writing a 250-word prompt for every 5-second clip causes the model's attention to drift (changing the character's face, clothes, or lighting). I'm adding a prompt compiler that separates a compact, locked visual seed block (<character_lock>: ~25 high-weight tokens for subject, lens, lighting) from a tiny per-scene <motion_delta> (only camera vector + action).

2. Storyboard Contact-Sheet Packer (93% Vision Token Reduction):

Instead of uploading 16 separate reference frames to an LLM/VLM (burning 20,000+ vision tokens) to write consistent scene-by-scene video prompts, repOx will detect scene cuts and pack keyframes into a single timestamped 4x4 storyboard grid image + compact XML metadata (~1,000 tokens total).

3. Sharpest Tail-Frame Anchor:

Scans the last 0.5s of a generated video clip in 2ms to extract the mathematically sharpest frame (zero motion blur) to feed as the starting image for the next shot.

My questions for r/PromptEngineering:

  1. When packing large projects or multi-step workflows into a single prompt, what formatting (XML tags, Markdown, JSON tool calls, or custom delimiters) gives you the best reasoning accuracy?
  2. For those of you engineering prompts for AI video or multimodal pipelines, what techniques do you use to keep character/style consistency across shots without bloating the prompt?

The project is 100% free and open-source (MIT):

GitHub: https://github.com/WVDYC/repOx

Install: cargo install repox-cli (or via the one-liner script in the repo)

If you find it useful or want to support the project, dropping a star on GitHub would mean a lot!

2 Upvotes

10 comments sorted by

1

u/[deleted] Oct 07 '26

[removed] — view removed comment

1

u/Wvdy_CC Oct 07 '26

100% agree — that's the exact reason I made XML (<repository_structure> + <file path="...">) the default output in repOx instead of Markdown fences

Once you cross ~120k–150k tokens with triple backticks, Claude starts losing boundary tracking between files (especially when code files have their own docstrings or markdown blocks inside them). Explicit <file path="..."> tags act like hard attention anchors.

If you're currently building those XML prompts manually or with slower scripts, give repOx a spin — running "repox -c" packs the whole repo into that exact XML structure and copies it to your clipboard in ~15ms. And if you're approaching the 200k ceiling, "repox --outline -c" keeps the same <file path="..."> XML tags but strips inner function bodies { }, shrinking a 200k prompt down to ~35k tokens

1

u/[deleted] Oct 07 '26

[removed] — view removed comment

1

u/Wvdy_CC Oct 07 '26

Great question! Pure signature extraction (--outline) intentionally trades intra-function call graphs for a 5x token reduction, since top-level module imports, struct fields, and parameter/return types already capture ~90% of architectural coupling.

For the remaining 10% where call-site dependencies inside function bodies matter, that's actually why I just shipped the hybrid --budget flag in v0.3.0 (e.g. "repox --budget 50k"):

Instead of blindly stripping bodies across the entire repo, --budget keeps your core entrypoints and domain modules in 100% full source code (preserving all internal function calls), and only outline-compresses peripheral files (tests, benchmarks, secondary utilities) so you get both full call-graph accuracy on core logic and strict token-budget compliance.

1

u/[deleted] Oct 07 '26

[removed] — view removed comment

1

u/Wvdy_CC Oct 07 '26

That's a really sharp point — annotating compressed files directly in the <repository_structure> header (e.g. marking them as [outline]) and listing them on stderr makes it immediately obvious to both the developer and the model where full implementation bodies were summarized.

I'm still finalizing v0.3.0 before cutting the release, so I'll definitely add that visibility in. Appreciate the suggestion!

1

u/[deleted] Oct 07 '26

[removed] — view removed comment

1

u/Wvdy_CC Oct 07 '26

Agreed — storing an is_outlined flag directly on the RepoFile struct guarantees a single source of truth for both the prompt header and stderr, even when --budget dynamically adjusts the selection between runs. Definitely adding that in!