romangalaxys10-spec

Smart Context Delegation — AI skill for Claude Code

AI community

Cut coding-agent token usage by ~90%: a PreToolUse hook blocks large file reads; bulk-read/code-write delegate to a cheap model.

How to install Smart Context Delegation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open romangalaxys10-spec/smart-context-delegation and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Smart Context Delegation does

Cut coding-agent token usage by ~90%: a PreToolUse hook blocks large file reads; bulk-read/code-write delegate to a cheap model. Works with Claude Code, zcode, Trae, opencode, Cursor, Cline and any shell-capable agent.

Alternatives in AI

  • Repomix — 📦 Repomix is a powerful tool that packs your entire repository into a single, AI-friendly file 22.7k ★
  • Graphify — AI coding assistant skill (Claude Code, Codex, OpenCode, OpenClaw, Factory Droid, Trae) 20.9k ★
  • AI Guide — 程序员鱼皮的 AI 资源大全 + Vibe Coding 零基础教程,分享 OpenClaw 保姆级教程、大模型玩法(DeepSeek / GPT / Gemini / Claude)、最新 AI 资讯、Prompt 提 11.8k ★

README

⚡ Smart-Context Delegation (SCD)

**Stop feeding entire files to your frontier model. Cut coding-agent token usage by ~90%.**

A drop-in *skill* for Claude Code, zcode, Trae, opencode, Cursor, Windsurf, Cline, Roo, aider — or any agent that can run a shell command.

[![CI](https://github.com/romangalaxys10-spec/smart-context-delegation/actions/workflows/ci.yml/badge.svg)](https://github.com/romangalaxys10-spec/smart-context-delegation/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) [![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue.svg)](hooks/pre_tool_use.py) [![Node 18+](https://img.shields.io/badge/node-18%2B-brightgreen.svg)](hooks/pre_tool_use.js) [![Zero dependencies](https://img.shields.io/badge/deps-zero-orange.svg)](#quick-start) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg)](CONTRIBUTING.md)


The 90% stat

Naive session:  read 518-line file  →  56,400 main-context tokens   $0.169
SCD session:    delegate to cheap   →   5,100 main-context tokens   $0.013
                                              ────────────────────   ──────
                                              −91% tokens            −92% $

Why: a file read into the main context is **re-sent as input on every subsequent turn** of the session. SCD keeps the raw file out of that loop entirely. Full math with stated assumptions: [`examples/demo-transcript.md`](examples/demo-transcript.md)

Inspired by the "How Spotify cut Claude Code token usage by 90%" diagram.

How it works

Three layers, because markdown prompts alone get ignored under context pressure:

Layer What Enforcement
1 · Rules SKILL.md / CLAUDE.md / .cursor/rules advisory
2 · Scripts bulk-read · code-write · token-report operational
3 · Hooks PreToolUse gate refuses large reads hard
 Main agent tries Read(ca