上下文
](https://go.dev/)   
中文 |英语
AI编码代理的通用包管理器。
ctx install @openelf/code-review # install a skill
ctx link claude # link to your agent — done为什么是ctx?
AI编码代理(Claude Code、Cursor、Windsurf等)缺乏发现和安装扩展的共享方式。每个代理都有自己的格式、自己的配置目录和自己的链接机制。
ctx解决了这个问题。 一个安装命令。一个链接命令。在18名特工中工作。
┌─────────────────────────────┐
│ ctx registry │
│ skills · MCP · CLI tools │
└──────────┬──────────────────┘
│
ctx install
│
┌──────────────────┼──────────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Claude │ │ Cursor │ │ Windsurf │ ...
│ Code │ │ │ │ │
└──────────┘ └──────────┘ └──────────┘安装
# macOS / Linux
curl -fsSL https://getctx.org/install.sh | sh
# Homebrew
brew install ctx-hq/tap/ctx
# Go
go install github.com/ctx-hq/ctx/cmd/ctx@latest
# Windows
irm https://getctx.org/install.ps1 | iexMore options (Scoop, deb, rpm)
# Debian / Ubuntu
dpkg -i ctx_*.deb
# Windows (Scoop)
scoop bucket add ctx https://github.com/ctx-hq/homebrew-tap
scoop install ctx快速开始
# Search for packages
ctx search "code review"
# Install a skill — auto-detects your agents and links it
ctx install @openelf/code-review
# Install an MCP server with a specific version
ctx install @mcp/github@2.1.0
# Install a CLI tool (delegates to brew/cargo/binary as appropriate)
ctx install @community/ripgrep
# See what's installed
ctx list
# Check environment health
ctx doctor程序包类型
| 类型 | 它是什么 | 示例 |
|---|---|---|
| 技能 | 为代理提供提示文件和工作流 | 代码审查、重构、测试生成 |
| 主控程序 | 模型上下文协议服务器 | GitHub、数据库、文件系统访问 |
| 命令行界面 | 命令行工具 | ripgrep、jq、fzf |
支持的代理
ctx检测包并将其链接到 18名代理人:
claude · cursor · windsurf · opencode · codex · copilot · cline · continue · zed · roo · goose · amp · trae · kilo · pear · junie · aider · generic
ctx link # list detected agents on your system
ctx link claude # link all packages to Claude Code
ctx link cursor # link all packages to Cursor命令
# Discovery
ctx search # search the registry
ctx search "git" --type mcp # filter by type
ctx info
# show package details
# Install / Remove
ctx install
# install a package
ctx install github:user/repo # install from GitHub directly
ctx remove
# uninstall
ctx list # list installed packages
# Update
ctx update # update all packages
ctx update @scope/name # update one package
ctx outdated # check for updates
ctx prune # remove old versions
# Agent Linking
ctx link # list detected agents
ctx link # link packages to an agent
# Publishing
ctx login # authenticate via GitHub
ctx whoami # show current authenticated user
ctx init # interactive manifest scaffold
ctx validate # validate your manifest
ctx publish # publish to the registry (public)
ctx publish --private # publish as private package
# Organizations
ctx org create # create an organization
ctx org list # list your organizations
ctx org info # show org details
ctx org packages # list org's packages
ctx org add [--role] # add member
ctx org remove # remove member
ctx org delete # delete org (0 packages required)
# Cross-device Sync
ctx sync export # export installed state to local file
ctx sync push # upload sync profile to registry
ctx sync pull # restore packages on new device
ctx sync status # view sync status + last sync time
# Dist Tags
ctx dist-tag ls
# list distribution tags
ctx dist-tag add
# set a tag (e.g., beta → 2.0.0-beta.1)
ctx dist-tag rm
# remove a tag
# Configuration
ctx config list # show all settings
ctx config set # change a setting
ctx config get # read a setting
# System
ctx version # print version
ctx doctor # diagnose environment
ctx upgrade # self-update ctx
ctx serve # run as MCP serverMCP服务器模式
ctx可以作为MCP服务器运行,让AI代理直接管理包:
{
"mcpServers": {
"ctx": {
"command": "ctx",
"args": ["serve"]
}
}
}可用工具: ctx_search, ctx_install, ctx_info, ctx_list
包裹清单
包由 ctx.yaml 文件。跑 ctx init 脚手架一。
Skill example
name: "@scope/my-skill"
version: "1.0.0"
type: skill
description: "Code review skill for AI agents"
skill:
entry: SKILL.md
tags: [review, code-quality]
compatibility: "claude-code, cursor"MCP server example
name: "@scope/github-mcp"
version: "2.1.0"
type: mcp
description: "GitHub MCP server"
skill:
entry: "skills/github-mcp/SKILL.md"
origin: native
mcp:
transport: stdio
command: npx
args: ["-y", "@modelcontextprotocol/server-github"]
env:
- name: GITHUB_TOKEN
required: true
description: "GitHub personal access token"CLI tool example
name: "@community/ripgrep"
version: "14.1.0"
type: cli
description: "Fast regex search tool"
skill:
entry: "skills/ripgrep/SKILL.md"
origin: native
cli:
binary: rg
verify: "rg --version"
install:
brew: ripgrep
cargo: ripgrep
platforms:
darwin-arm64:
binary: "https://github.com/.../ripgrep-14.1.0-aarch64-apple-darwin.tar.gz"
linux-amd64:
binary: "https://github.com/.../ripgrep-14.1.0-x86_64-unknown-linux-musl.tar.gz"配置
文件
| 路径 | 目的 |
|---|---|
~/.ctx/config.yaml | 注册表URL、用户名、隐私设置 |
~/.ctx/packages/ | 已安装的软件包 |
~/.ctx/links.json | 代理链接注册表 |
| 系统密钥链 | 身份验证令牌(macOS密钥链/Linux秘密工具) |
设置
ctx config set update_check false # disable update checks
ctx config set network_mode offline # disable all network access
ctx config set registry https://... # use a custom registry环境变量
| 变量 | 描述 |
|---|---|
CTX_HOME | 覆盖配置目录 |
CTX_DATA_HOME | 覆盖数据目录 |
CTX_CACHE_HOME | 覆盖缓存目录 |
CTX_REGISTRY | 覆盖注册表URL |
旗帜
| 标志 | 描述 |
|---|---|
--offline | 禁用此命令的所有网络访问 |
--json | JSON输出 |
--quiet / -q | 最小输出 |
--yes / -y | 跳过确认提示 |
隐私
- 没有遥测。 ctx不收集分析或使用数据。
- 系统密钥链中的令牌。 身份验证令牌存储在macOS Keychain或Linux中
secret-tool,不在配置文件中。 - 更新检查是可选的。 禁用
ctx config set update_check false或--offline. - 所有文件0600/0700。 敏感文件仅供所有者阅读。
- 没有数据离开您的机器 除非您明确搜索、安装、发布或登录。
建筑
cmd/ctx/ CLI commands (Cobra)
internal/
├── config/ Configuration + file permissions
├── auth/ GitHub OAuth + system keychain
├── registry/ HTTP client for getctx.org API
├── resolver/ Version + source resolution
├── installer/ Download, extract, link packages
├── adapter/ Bridge to native pkg managers (brew, npm, pip, cargo)
├── agent/ Agent detection + config linking (18 agents)
├── mcpserver/ MCP server mode (ctx serve)
└── output/ Human + JSON output formatting贡献
git clone https://github.com/ctx-hq/ctx.git
cd ctx
make build # build binary
make test # run tests
make lint # run linter
make check # vet + lint + test发布过程
通过以下方式自动发布 请释放.推动传统承诺 main 并且自动创建发布PR。
管道(GoReleaser+GitHub Actions)处理交叉编译(Linux/MOSC/Windows x AMD64/ARM64)、shell补全、联合签名、SBOM、Homebrew/Scoop/deb/rpm包和构建来源证明。
