CTX

作者 Alegau03已验证

CTX - Context Runtime Engine for Coding Agents

140
Stars
12
Forks
Rust
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/Alegau03/CTX

快速入门

使用 CTX 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

CTX

The context layer for AI coding agents

Reduce token waste in OpenCode and AI coding workflows with graph memory, compact task packs, read-cache compression, command pruning, and a live right-sidebar dashboard.

OpenCode-first runtime · Local MCP tools · Read cache + delta-aware indexing · Single Rust binary

CI ready Local first Telemetry local MIT license

Install · OpenCode Usage · Dashboard · Benchmarks · Docs · Security

CTX is a local context runtime for OpenCode and AI coding agents. It keeps repository knowledge, reusable rules, shell output, diffs, and file rereads compact before they ever bloat the model context.

See It In Action

Install + BootstrapPlanning + PackingRead Cache + Dashboard
Install + BootstrapPlanning + PackingRead Cache + Dashboard
Install ctx, run ctx init, ctx index, ctx opencode install, then open OpenCode.Build a plan, pack the smallest useful context, and compare broad vs packed token cost.Re-read files through digest mode and watch live savings in the right sidebar.

Contents

What CTX Is

CTX is a local runtime layer for OpenCode. It indexes the repository, stores reusable guidance as graph memory, exposes local MCP tools, generates OpenCode slash commands, and keeps local telemetry about token savings, cache reuse, and compact context packs.

CTX is not another agent launcher.

  • OpenCode keeps the selected model, provider, and normal workflow.
  • CTX sits underneath as the context layer.
  • The product surface is the OpenCode-native /ctx-* experience, not wrapper-first shell workflows.

Why It Exists

Coding agents usually waste tokens on things that are useful once but expensive forever.

ProblemTraditional flowCTX flow
Project rulesReload a full AGENTS.md every turnImport rules into graph memory and retrieve only the relevant directives
File rereadsPay full price for the same file againRe-read unchanged files through digest / outline modes with local read-cache compression
Noisy logsPaste thousands of repeated linesRun /ctx-run or prune logs into root-cause signal
Broad diffsFeed huge patchesKeep only task-relevant hunks and changed symbols
Repo navigationManual file spelunkingQuery local graph, snippets, symbols, and semantic ranking
Host integrationWrapper commands outside the agentOpenCode-native /ctx-* commands plus local MCP tools

Install CTX

Install CTX with the channel that fits your workflow best:

  • cargo install ctx-cli
  • one-line installer script
  • GitHub Release archives
  • npm i -g @alegau/ctx-bin
  • brew tap Alegau03/ctx && brew install ctx

Update paths:

  • ctx update
  • ctx update --check
  • cargo install ctx-cli --force
  • rerun the installer script
  • npm update -g @alegau/ctx-bin
  • brew upgrade ctx

Cargo

cargo install ctx-cli

One-Line Installer

curl -fsSL https://raw.githubusercontent.com/Alegau03/CTX/main/scripts/install.sh | sh

npm

npm i -g @alegau/ctx-bin

Homebrew

brew tap Alegau03/ctx
brew install ctx

Source Install

git clone https://github.com/Alegau03/CTX.git
cd CTX
cargo install --locked --path crates/ctx-cli

Verify:

ctx help
ctx doctor
ctx update --check

Native update command:

ctx update

How ctx update behaves:

  • installer-based installs: reruns the official installer path
  • Cargo installs: prints cargo install ctx-cli --force
  • npm installs: prints npm update -g @alegau/ctx-bin
  • Homebrew installs: prints brew upgrade ctx
  • ambiguous installs: prints all supported update commands without guessing

GitHub Release Archive

Download the latest assets from GitHub Releases, then run:

shasum -a 256 -c SHA256SUMS
tar -xzf ctx-0.2.5-aarch64-apple-darwin.tar.gz
mkdir -p "$HOME/.local/bin"
install -m 0755 ctx-0.2.5-aarch64-apple-darwin/ctx "$HOME/.local/bin/ctx"
export PATH="$HOME/.local/bin:$PATH"

If you prefer a system-wide install:

sudo install -m 0755 ctx-0.2.5-aarch64-apple-darwin/ctx /usr/local/bin/ctx

For the full install matrix, release verification notes, native update behavior, and distribution details, see docs/install.md.

OpenCode-First Usage

Once ctx is installed, enable it in any project:

cd /path/to/your/project
ctx init
ctx index
ctx opencode install
opencode

If you want the leanest possible OpenCode surface first:

ctx opencode install --profile core

Profile summary:

  • full (default): full CTX slash-command surface plus the live right-sidebar CTX Dashboard
  • core: lean daily workflow with /ctx, /ctx-doctor, /ctx-plan, /ctx-retrieve, /ctx-pack, /ctx-run, /ctx-prune-logs, /ctx-stats, and /ctx-gain

Inside OpenCode, start with:

/ctx

From there, the main workflow is:

/ctx-doctor
/ctx-memory-bootstrap
/ctx-plan <task>
/ctx-retrieve <query>
/ctx-read <file> [mode]
/ctx-pack <task>
/ctx-compare <task>
/ctx-run <shell command>
/ctx-gain
/ctx-dashboard

Toolbooks and reusable lessons are also first-class:

/ctx-toolbook-import <name> <file>
/ctx-toolbook-search <name> "<query>"
/ctx-toolbook-pack <name> "<task>"
/ctx-learn <key> "<body>"

For full usage, expected outputs, and CLI equivalents, see guide.md and docs/commands.md.

What Works Today

AreaCurrent state
OpenCode integrationctx opencode install writes opencode.json, .opencode/commands/*.md, .opencode/instructions/ctx-host-first.md, and in full profile also provisions .opencode/tui.json plus a live sidebar plugin
Install profiles`ctx opencode install --profile full
Command center/ctx shows a categorized CTX menu and best next command
Planning/ctx-plan <task> combines retrieval, graph, memory, and pack signals into an implementation plan
Context packing/ctx-pack <task> builds compact task packs with graph, memory, failure, diff, and attachment signals
Density check/ctx-compare <task> shows before-vs-CTX token density for one task
Read cache/ctx-read <file> [mode] supports full, outline, and digest with session re-read compression
Delta-aware indexingrepeated ctx index runs reuse unchanged files and write index-cache summaries
Command compression/ctx-run <shell command> keeps the root cause and stores the raw log
Gain reporting/ctx-gain summarizes recent token savings and top repeated queries
Dashboardthe full profile adds a live right-sidebar CTX Dashboard, while /ctx-dashboard prints a local snapshot in-thread
Graph memorybootstrap/import/search/list/get/set/delete/export project directives seeded from AGENTS.md, CLAUDE.md, CODEX.md, and Copilot instructions
ToolbooksOpenCode-only /ctx-toolbook-* commands keep large CLI manuals out of AGENTS.md
Learning/ctx-learn <key> "<body>" stores reusable project lessons in graph memory
Retrievalhybrid graph, snippets, FTS, symbols, and semantic ranking with local fallback
Pruningdeterministic log and diff pruning with parser-aware diagnostics
MCPlocal stdio MCP plus localhost HTTP JSON-RPC runtime
File coverageRust, Python, TypeScript, JavaScript, Markdown runbooks, and common config/script files
Privacylocal-only defaults, sensitive attachment blocking, local audit log

Graph Memory

Graph Memory is CTX's structured replacement for repeatedly loading whole instruction markdown files. It keeps directives local, queryable, editable, and exportable when markdown compatibility is still needed.

Instead of this:

  • one giant AGENTS.md
  • every host turn re-reading it
  • unclear relevance to the active task

CTX lets you do this:

  • import rules once with /ctx-memory-bootstrap
  • retrieve only task-relevant directives with /ctx-memory-search
  • fold those directives into /ctx-plan and /ctx-pack
  • store new lessons with /ctx-learn

CTX Dashboard

When CTX is installed with the default full profile, OpenCode gets a live CTX Dashboard in the right sidebar.

The sidebar is meant to be a lightweight control tower for the current repo, not another verbose chat response. It auto-refreshes local runtime metrics such as:

  • total estimated tokens saved
  • average tokens saved per run
  • average and latest reduction percentages
  • read-cache hit rate
  • index-cache reuse rate
  • top current win
  • latest pack artifact

The right-sidebar view is intentionally compact. It focuses on the live metrics that matter most instead of repeating verbose activity logs or warning blocks that are already available in the main CTX outputs.

Use the core profile when you want the smallest possible slash-command surface and do not need the sidebar yet.

Proof From The Demo Fixture

The committed demo benchmark compares a traditional markdown-rule flow against CTX graph memory on demo/fixtures/opencode-auth-lab.

MetricResult
Markdown rule tokens744
Graph memory tokens322
Token reduction56.72%
Query coveragemarkdown=1.00, graph=1.00
Markdown answer success33.33%
Graph memory answer success100.00%
Quality winsmarkdown=0, graph=1, ties=0

Reproduce it with:

scripts/demo/opencode-auth-lab-benchmark.sh ./target/debug/ctx

Evidence files:

External validation is also committed in docs/external-benchmark-agentsmd.md, including a public-repo snapshot with:

  • token reduction 72.62%
  • query coverage markdown=1.00, graph=0.89
  • success rate markdown=0.50, graph=1.00
  • quality wins markdown=0, graph=1, ties=0

Demo And Screenshots

Media SlotSuggested Asset
Hero GIFfull install -> ctx init -> ctx index -> ctx opencode install -> /ctx
Sidebar GIFlive right-sidebar CTX Dashboard refreshing after /ctx-pack and /ctx-read
Command GIF/ctx-plan, /ctx-pack, /ctx-compare, /ctx-run
Static ScreenshotCTX Dashboard in OpenCode right sidebar
AssetStatus
Fixture projectdemo/fixtures/opencode-auth-lab is committed
Automated smokescripts/demo/opencode-auth-lab-smoke.sh
MCP smokescripts/demo/opencode-auth-lab-mcp-smoke.sh
Benchmark smokescripts/demo/opencode-auth-lab-benchmark.sh
Demo walkthroughdocs/demo-walkthrough.md
Recording scriptdocs/demo-script.md
Demo videoWatch the OpenCode demo video

Security

CTX is local-first by default:

  • local_only = true
  • remote_upload_enabled = false
  • no mandatory network calls
  • .ctx/graph.db, .ctx/packs/, .ctx/stats/, and .ctx/audit.log stay local
  • sensitive-looking attachments such as .env, private keys, credentials, and secret files are blocked by default

See docs/security.md.

Documentation

FilePurpose
guide.mdOperational OpenCode workflow, examples, expected outputs
docs/commands.mdComplete CTX command syntax and explanations
docs/install.mdInstall paths, PATH notes, release archive verification
docs/opencode-integration.mdOpenCode integration architecture and install profiles
docs/demo-script.mdRecording sequence for demos and walkthroughs
docs/demo-walkthrough.mdEnd-to-end fixture validation
docs/architecture.mdRuntime architecture
docs/security.mdPrivacy and trust model
docs/release-playbook.mdRelease messaging and checklist
docs/final-qa.mdFinal QA gate
docs/external-benchmark-agentsmd.mdPublic external benchmark evidence

Repository Layout

PathPurpose
crates/ctx-clictx binary, OpenCode bootstrap, user-facing CLI commands
crates/ctx-coreRuntime orchestration for indexing, packing, memory, retrieval, benchmarks
crates/ctx-graphSQLite graph, FTS, memory directives, run metadata
crates/ctx-mcpLocal MCP runtime over stdio and localhost HTTP JSON-RPC
crates/ctx-packBudget-aware context packing and rewriting
crates/ctx-pruneLog and diff pruning
crates/ctx-astSymbol extraction and code slicing
crates/ctx-semanticSemantic ranking and local fallback embedding backend
crates/ctx-telemetryLocal stats, audit lines, benchmark summaries
demo/fixtures/opencode-auth-labRealistic fixture project for smoke tests and benchmark proof
scripts/demoDemo smoke, MCP smoke, and benchmark scripts
scripts/install.shOfficial user-local installer script
scripts/releaseBuild, package, verify, and final QA scripts
packages/ctx-binnpm binary package that downloads prebuilt release assets
Formula/ctx.rbHomebrew formula source used for local tap preparation

常见问题

What is CTX?

CTX is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by Alegau03. CTX - Context Runtime Engine for Coding Agents. It has 140 GitHub stars.

Is CTX safe to use?

Yes. CTX passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install CTX?

Clone the repository with "git clone https://github.com/Alegau03/CTX" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is CTX written in?

CTX is primarily written in Rust. It is open-source under Alegau03 on GitHub, so you can review or fork the full source.

Are there alternatives to CTX?

Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh CTX against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI 智能体
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情