
Ai Context Kit
io.github.ofershap由 GitHub 帳號 ofershap 發布v0.1.2更新於 Oct 24, 2026
Lint, measure, and sync AI context files across Cursor, Claude Code, Copilot.
概覽
一個本機工具包,讓助理載入、測量、檢查、篩選並同步 Cursor、Claude Code、Copilot 等工具的 AI 上下文規則檔案。
- 可以做什麼
- 載入並自動辨識 Cursor、Claude Code、AGENTS.md、Copilot、Windsurf 與 Cline 等格式的上下文規則檔案,解析 frontmatter 並估算每個檔案的 token 數、預算檢查與占比。檢查規則中的衝突、重複、過大檔案、目錄清單與含糊指令,並給出 0-100 分。依任務在 token 預算內只挑選相關規則,優先 alwaysApply,其次比對任務詞與標籤。將單一規則來源同步到其他目標檔案,支援試跑預覽。依指定格式產生初始規則範本。
- 適用情境
- 適用於專案中累積多個重疊或互相矛盾的上下文檔案時,想了解其 token 成本、找出衝突與重複,或只注入與目前任務相關的規則。也適合在 CI 流程中讓規則錯誤導致建置失敗。
- 執行需求
- 以本機 stdio 程序執行;需安裝 npm 套件 ai-context-kit,透過 npx 呼叫或作為函式庫匯入。未宣告驗證、環境變數或請求標頭。作用於包含受支援上下文檔案的專案目錄。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Ai Context Kit,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
ai-context-kit
How do you measure the token cost of your context?
You spent hours writing the perfect .md context file, just to find out that your agent got worse.
That's not a bug. That's what happens when nobody measures the cost of context.
[Try It Now] [Install] [See Example Output] [Vote on Next Features]
[GitHub stars] [npm version] [npm downloads] [CI] [TypeScript] [License: MIT] [PRs Welcome]
You write a CLAUDE.md. Then someone adds .cursor/rules/. Then a teammate drops in an AGENTS.md. Then someone copies in a .cursorrules file from a blog post. Nobody removes the old ones.
Six months later your project has four context files that overlap, contradict each other, and dump 8,000 tokens of directory listings and "follow best practices" into every conversation. Your agent follows all of it. It gets slower. It gets confused. You blame the model.
An ETH Zurich study (February 2026) measured what actually happens when you give agents context files:
- Auto-generated context files reduced task success compared to providing nothing
- Human-written ones only improved accuracy by 4%
- Inference costs jumped 20%+ from wasted tokens
- Performance dropped on some models because agents got too obedient - following unnecessary instructions instead of solving the actual problem
I kept hitting this in my own projects, so I built ai-context-kit - a toolkit to treat context like a budget. Measure it, trim it, inject only what the current task needs.
Quick Start
Run the CLI on any project to see what you're actually injecting:
Then lint it:
That's the difference between guessing and knowing.
What's Different
What This Answers
- How much context am I injecting? Token count per file, percentage breakdown, budget check
- Are my rules fighting each other? Conflict detection across all files and formats
- What's wasting tokens? Directory listings, duplicate content, vague advice
- Which rules matter for this task? Task-relevant selection with token budget
How It Works
ai-context-kit reads every context file format in the ecosystem, parses frontmatter, estimates token cost, and gives you tools to analyze and manage them.
API
loadRules(rootDir?)
Returns RuleFile[] with parsed frontmatter, body, format, path, and token count.
measure(rules, budget?)
lint(rules)
What the linter catches:
select(rules, options)
The core insight from the research: don't inject everything. Pick what matters.
Scoring: alwaysApply: true in frontmatter gets highest priority. Then task words matched against file paths and content. Then tag matches. Budget is respected - highest-scored rules are included first until the budget runs out.
sync(options)
Write rules once, sync everywhere.
Supports dryRun: true to preview changes without writing.
init(options?)
CLI
All commands support --path <dir> to point at a different project root. lint exits with code 1 on errors (warnings pass).
Use with Vercel AI SDK / LangChain / Custom Agents
This isn't just for Cursor. If you're building agents with Vercel AI SDK, LangChain, or your own framework, ai-context-kit solves the same problem: how much context are you stuffing into the system prompt, and is it helping or hurting?
Any framework that takes a system prompt string. Any rules stored as markdown files.
Supported Formats
ai-context-kit detects the format from the file path. No configuration needed.
Why not just write better rules?
The ETH Zurich study tested both human-written and LLM-generated context files. Human-written ones were better, but only by 4%. The real problem isn't quality - it's volume. More context means more tokens consumed by instructions the agent doesn't need for the current task. The winning strategy is fewer, task-relevant rules, not better prose.
How accurate is the token estimation?
ai-context-kit uses a 4-character-per-token approximation. This is intentionally simple and fast. It's accurate enough for budgeting and comparison (GPT-4 averages ~4 chars/token for English text). If you need exact counts, pipe the output through tiktoken or your model's tokenizer.
Does this work in CI?
Yes. npx ai-context-kit lint returns exit code 1 on errors, 0 on pass. Add it to your CI pipeline the same way you'd add eslint. The --json flag gives machine-readable output for custom reporting.
Tech Stack
Contributing
PRs welcome. Whether it's a new lint rule, a format detector, or a bug fix - check out the contributing guide.
Author
README built with README Builder
License
Star this repo · Fork it · Report a bug · Join the discussion
來源:README.md,提交 8b1d7a5
工具
0版本歷史
1- v0.1.2最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
