codecontext-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodecontext Setup
Codecontext设置
Set up so agents can use it without guessing.
codecontextThe point of this skill is not just package installation. The real job is to
make the repo's agent contract coherent:
- the toolchain is installed where it belongs
- tells agents when and how to use it
AGENTS.md - inline is treated as the required structured layer
@context - supporting refs stay unconstrained and user-owned
Do not invent required sidecar document schemas. Do not require .
Refs can point to Markdown, HTML, text, diagrams, exported docs, or any other
resolvable file the repo uses.
.ctx.md设置,让Agent无需猜测即可直接使用。
codecontext本技能的核心目标不只是完成软件包安装,真正的工作是让代码仓库的Agent契约清晰一致:
- 工具链安装到了正确的位置
- 明确告知Agent何时以及如何使用codecontext
AGENTS.md - 行内被视为必填的结构化信息层
@context - 支持引用保持无约束,完全由用户自主掌控
不要自行发明必填的附属文档schema,不要强制要求使用。引用可以指向Markdown、HTML、文本、流程图、导出文档,或是代码仓库使用的其他任何可解析文件。
.ctx.mdWhen to use
何时使用
Use this skill when the user asks to:
- install or adopt
codecontext - update a repo's or agent guidance around
AGENTS.md@context - audit a project's current setup
codecontext - reconcile a mismatch between codecontext tooling and repo instructions
- improve how agents discover decisions, risks, assumptions, and history
当用户提出以下需求时使用本技能:
- 安装或落地使用
codecontext - 更新代码仓库的或关于
AGENTS.md的Agent使用指引@context - 审计项目当前的配置情况
codecontext - 协调解决codecontext工具和代码仓库说明不一致的问题
- 优化Agent发现决策、风险、假设和开发历史的方式
Outcome
预期结果
By the end of this workflow, the repo should have:
- a clear section for
AGENTS.mdcodecontext - a sane CLI workflow for agents
- the right enforcement surface for the repo's languages and toolchain
- no misleading guidance about structured sidecar docs
完成本工作流后,代码仓库应当具备:
- 中清晰的
AGENTS.md使用说明板块codecontext - 合理的Agent CLI使用工作流
- 适配代码仓库语言和工具链的正确校验规则
- 不存在关于结构化附属文档的误导性指引
Workflow
工作流
1. Audit the current state
1. 审计当前状态
Inspect:
- package manager and workspace layout
- whether the repo already depends on
@recallnet/codecontext-cli - whether the repo already depends on
@recallnet/codecontext-eslint-plugin - whether the repo already has Python, Go, Rust, or other language-native
- whether the repo already has Python, Go, Ruby, Rust, or other language-native
checkers where enforcement belongs
codecontext - whether ESLint is present and where its shared config lives
- whether exists at repo root and in subtrees/worktrees
AGENTS.md - whether existing agent docs already mention ,
@context, ADRs,codecontext, or decision logscontexts/
Look for the two common failure modes:
- tool installed, but no agent workflow or guidance
- guidance exists, but it is stale, contradictory, or points to a policy that does not exist
检查以下内容:
- 包管理器和工作区结构
- 代码仓库是否已经依赖
@recallnet/codecontext-cli - 代码仓库是否已经依赖
@recallnet/codecontext-eslint-plugin - 代码仓库是否已经有Python、Go、Rust或其他语言原生的校验工具
- 代码仓库是否已经有Python、Go、Ruby、Rust或其他语言原生的、应当集成校验能力的检查工具
codecontext - 是否存在ESLint,以及其共享配置的存放位置
- 代码仓库根目录和子树/工作树中是否存在
AGENTS.md - 现有Agent文档是否已经提及、
@context、ADR、codecontext或决策日志contexts/
排查两种常见的故障模式:
- 工具已安装,但没有对应的Agent工作流或使用指引
- 存在使用指引,但内容过时、相互矛盾,或是指向不存在的规则
2. Decide the installation surface
2. 确定安装范围
Install the minimum useful surface:
- when agents should run
@recallnet/codecontext-cli,--scope, or--diff--report - when the repo uses ESLint and wants comment validation
@recallnet/codecontext-eslint-plugin - a language-native checker or analyzer when the repo's main enforcement surface is Python, Go, Rust, or something else outside ESLint
- only if the repo has custom code that imports parser APIs directly
@recallnet/codecontext-parser
Do not add packages the repo is not going to use.
安装最小可用的工具集:
- 当Agent需要运行、
--scope或--diff命令时,安装--report@recallnet/codecontext-cli - 当代码仓库使用ESLint且需要注释校验能力时,安装
@recallnet/codecontext-eslint-plugin - 当代码仓库的主要校验层是Python、Go、Rust或其他ESLint之外的技术栈时,安装对应语言原生的检查器或分析器
- 仅当代码仓库有直接导入解析器API的自定义代码时,才安装
@recallnet/codecontext-parser
不要添加代码仓库不会用到的依赖包。
3. Fix AGENTS.md
before or alongside package changes
AGENTS.md3. 在修改依赖包之前或同时修复AGENTS.md
AGENTS.mdcodecontextEvery repo-level section should cover:
AGENTS.md- what is for
@context - when annotations are required
- a small preferred taxonomy
- the pre-edit and post-edit workflow
- what refs are and are not
- anti-patterns
If subtree files point to a repo-level policy, make sure that
policy actually exists.
AGENTS.md如果没有Agent使用说明,的配置就是不完整的。
codecontext每个代码仓库级别的相关板块都应当涵盖:
AGENTS.md- 的用途
@context - 何时必须添加注解
- 推荐的小规模分类体系
- 编辑前和编辑后的工作流
- 引用的定义和使用规范
- 反模式说明
如果子树的文件指向了仓库级别的规则,请确保该规则真实存在。
AGENTS.mdRecommended AGENTS.md
contract
AGENTS.md推荐的AGENTS.md
契约
AGENTS.mdKeep it short. A good section usually fits in 8-14 bullets.
Use something close to this:
md
- **codecontext**: Use inline `@context` annotations for non-obvious,
high-value reasoning that future edits could easily erase.
- Required for:
- critical decision logic and invariants
- security-sensitive behavior and hard-won lessons
- external integration quirks and contract mismatches
- regression guards explaining why a simpler change would be wrong
- Preferred forms: `@context decision`, `@context risk`,
`@context requirement`, `@context history`
- Keep notes short and specific: what is true, why it matters, and what
would break if changed
- Use `{@link ...}` for supporting material when helpful, but refs are just pointers
to repo files or docs. Do not require any special doc schema.
- Before editing critical files, run:
`npx @recallnet/codecontext-cli --scope <file>`
- After editing, run:
`npx @recallnet/codecontext-cli --diff HEAD <file>`
- For broader orientation in larger repos, run:
`npx @recallnet/codecontext-cli --report`
- Do not use `@context` for obvious narration, duplicated ADR prose, or
generic comments.Adjust the taxonomy only if the repo clearly needs more than the baseline
(, , , ). Add extra categories sparingly.
decisionriskrequirementhistory保持内容简洁,一个好的说明板块通常只需要8-14条要点。
可以参考以下模板:
md
- **codecontext**:对非显而易见的、高价值的逻辑添加行内`@context`注解,避免后续编辑误删相关信息。
- 必须添加注解的场景:
- 关键决策逻辑和不变量
- 安全相关的行为和来之不易的经验教训
- 外部集成的特殊情况和契约不匹配问题
- 回归防护说明,解释为什么更简单的改动不可行
- 推荐的注解类型:`@context decision`、`@context risk`、`@context requirement`、`@context history`
- 注解内容要简短明确:说明当前的事实、重要性,以及改动后会出现什么问题
- 必要时使用`{@link ...}`指向支持材料,但引用仅作为指向仓库文件或文档的指针,不要要求使用任何特殊的文档schema。
- 编辑关键文件前运行:
`npx @recallnet/codecontext-cli --scope <file>`
- 编辑完成后运行:
`npx @recallnet/codecontext-cli --diff HEAD <file>`
- 在大型仓库中进行整体概览时运行:
`npx @recallnet/codecontext-cli --report`
- 不要将`@context`用于显而易见的说明、重复的ADR内容或是通用注释。仅当代码仓库明确需要超出基线(、、、)的分类时,再调整分类体系,谨慎添加额外类别。
decisionriskrequirementhistoryGuidance for repos with ADRs or large docs trees
对使用ADR或大型文档树的仓库的指引
If the repo already uses ADRs, plans, runbooks, or architecture docs:
- keep as the inline agent-facing layer
@context - treat refs as optional expansion targets
- do not tell agents to browse the entire docs tree by default
- do not mirror whole ADRs inline
The correct model is:
- carries the structured local signal
@context - refs point to arbitrary supporting material
- agents expand refs only when needed
如果代码仓库已经在使用ADR、计划、运行手册或架构文档:
- 保留作为面向Agent的行内信息层
@context - 将引用视为可选的扩展信息入口
- 不要默认要求Agent浏览整个文档树
- 不要将完整的ADR内容复制到行内注解中
正确的使用模式是:
- 承载结构化的局部信号
@context - 引用指向任意的支持材料
- Agent仅在需要时展开查看引用内容
Refs policy
引用规则
Be explicit:
- refs are allowed to point to ,
.md,.html, diagrams, exports, or other repo artifacts.txt - refs are not required on every annotation
- refs should not impose a schema on the target file
Do not write guidance that implies:
- is required
.ctx.md - frontmatter is required
- the linked file must be machine-parseable
明确说明以下规则:
- 允许引用指向、
.md、.html、流程图、导出文件或其他仓库产物.txt - 不是每个注解都必须添加引用
- 引用不应对目标文件施加schema要求
不要编写暗示以下要求的指引:
- 必须使用
.ctx.md - 必须有frontmatter
- 链接的文件必须是机器可解析的
CLI workflow guidance
CLI工作流指引
Recommend these commands in agent docs when the CLI is installed:
bash
npx @recallnet/codecontext-cli --scope path/to/file.ts
npx @recallnet/codecontext-cli --diff HEAD path/to/file.ts
npx @recallnet/codecontext-cli --reportUse for repo orientation and decision review. Use and
around concrete edits.
--report--scope--diff当安装了CLI后,在Agent文档中推荐以下命令:
bash
npx @recallnet/codecontext-cli --scope path/to/file.ts
npx @recallnet/codecontext-cli --diff HEAD path/to/file.ts
npx @recallnet/codecontext-cli --report--report--scope--diffEnforcement guidance
校验规则指引
If the repo already has a shared ESLint config, integrate the plugin there.
Prefer enforcing syntax and stale/invalid ref checks centrally rather than
telling agents to self-police.
If the repo does not use ESLint, do not force it just for .
Prefer the native enforcement surface for the repo's actual stack:
codecontext- Python repo: native checker or PyPI-distributed tool
- Go repo: analyzer / integration
golangci-lint - Ruby repo: native checker gem or RuboCop-style integration
- Rust repo: crate / Clippy-style integration
- mixed or tool-agnostic repo: CLI workflow may be enough initially
The important question is not "did we install the ESLint plugin?"
It is "what actually enforces correctness in this ecosystem?"
@context如果代码仓库已经有共享的ESLint配置,将插件集成到该配置中。优先在中心层面统一校验语法和过时/无效引用,而非要求Agent自行检查。
如果代码仓库不使用ESLint,不要仅为了强制引入ESLint。优先适配代码仓库实际技术栈的原生校验层:
codecontext- Python仓库:原生检查器或PyPI分发的工具
- Go仓库:分析器/集成
golangci-lint - Ruby仓库:原生检查器gem或RuboCop风格的集成
- Rust仓库:crate/Clippy风格的集成
- 混合技术栈或工具无关的仓库:初期仅使用CLI工作流可能就足够
核心问题不是“我们有没有安装ESLint插件”,而是“在当前技术栈中,什么工具能真正校验的正确性?”
@contextWhat to look for in a review
审查要点
Flag these as setup defects:
- child files pointing to a missing repo policy
AGENTS.md - instructions that mention but give no workflow
@context - workflow guidance that ignores in large repos
--report - guidance that treats linked docs as required structured sidecars
- package installs without corresponding agent documentation
- documentation that tells agents to read giant ADR/doc trees by default
将以下情况标记为配置缺陷:
- 子目录的文件指向不存在的仓库级规则
AGENTS.md - 说明中提到了但没有给出对应的工作流
@context - 大型仓库的工作流指引中没有提及
--report - 指引中将链接的文档视为必填的结构化附属文件
- 安装了依赖包但没有对应的Agent使用文档
- 文档默认要求Agent阅读庞大的ADR/文档树
Delivery
交付要求
When you finish setup or audit work:
- state what was installed or changed
- call out any stale or contradictory guidance you fixed
AGENTS.md - mention any remaining gaps
- if you did not install an enforcement surface, explain why
完成配置或审计工作后:
- 说明安装或修改的内容
- 指出你修复的所有过时或矛盾的指引
AGENTS.md - 说明仍存在的待完善缺口
- 如果你没有安装校验层,解释原因
Default recommendation
默认推荐
If the repo has no existing guidance, prefer creating a
section in the root rather than scattering
instructions across multiple child docs first.
codecontextcodecontext-setupAGENTS.md如果代码仓库没有现有的指引,优先在根目录的中创建一个板块,而不是一开始就把说明分散到多个子文档中。
codecontextAGENTS.mdcodecontext-setup