cco-templates

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Context Templates

上下文模板

Context templates are pre-defined sets of files to read for common task types, saving time and tokens by loading only what's needed.
Templates are stored in
~/.claude-context-optimizer/templates/
.
Parse $ARGUMENTS:
上下文模板是针对常见任务类型预定义的待读取文件集合,通过仅加载所需内容来节省时间和tokens。
模板存储在
~/.claude-context-optimizer/templates/
目录下。
解析$ARGUMENTS:

list
(or no arguments)

list
(或无参数)

Show all available templates:
bash
ls ~/.claude-context-optimizer/templates/*.json 2>/dev/null
For each template, show its name, description, and file list.
显示所有可用模板:
bash
ls ~/.claude-context-optimizer/templates/*.json 2>/dev/null
针对每个模板,显示其名称、描述和文件列表。

create <name>

create <name>

Help the user create a new template. Ask them:
  1. What type of task is this for? (e.g., "bug-fix", "new-feature", "refactor", "review")
  2. Which files/patterns should be pre-loaded?
Also suggest files based on historical tracking data:
bash
node ${CLAUDE_PLUGIN_ROOT}/src/tracker.js suggest "$(pwd)"
Save the template as
~/.claude-context-optimizer/templates/<name>.json
with format:
json
{
  "name": "template-name",
  "description": "What this template is for",
  "files": ["relative/path/to/file1", "relative/path/to/file2"],
  "patterns": ["**/*.config.*", "src/core/**"],
  "preCommands": ["git status", "git log --oneline -5"]
}
帮助用户创建新模板。询问用户:
  1. 此模板适用于哪种任务类型?(例如:"bug-fix"、"new-feature"、"refactor"、"review")
  2. 应预加载哪些文件/模式?
同时可基于历史跟踪数据建议文件:
bash
node ${CLAUDE_PLUGIN_ROOT}/src/tracker.js suggest "$(pwd)"
将模板保存为
~/.claude-context-optimizer/templates/<name>.json
,格式如下:
json
{
  "name": "template-name",
  "description": "What this template is for",
  "files": ["relative/path/to/file1", "relative/path/to/file2"],
  "patterns": ["**/*.config.*", "src/core/**"],
  "preCommands": ["git status", "git log --oneline -5"]
}

apply <name>

apply <name>

Read the template and execute:
  1. Run any
    preCommands
  2. Read the listed files
  3. Search for the listed patterns using Glob
This gives Claude exactly the right context for the task type.
读取模板并执行以下操作:
  1. 运行所有
    preCommands
    命令
  2. 读取列出的文件
  3. 使用Glob搜索列出的模式
这将为Claude提供与任务类型完全匹配的合适上下文。

delete <name>

delete <name>

Delete the template file and confirm.
删除模板文件并确认操作。