feat: /ccg:context command + quality gate rules v1.7.80
- /ccg:context: 27th slash command — .context/ init, decision log, compress, history for LLM context engineering - /ccg:commit Context Compress Phase: auto-compress session.log → history/commits.jsonl on commit, add Context-Id trailer - 13 role prompts .context Awareness: Codex 6 + Gemini 7 prompts inject .context/prefs/ reading instructions - Quality Gate Rules: ~/.claude/rules/ccg-skills.md auto-trigger rules for verify-security/quality/change/module + gen-docs - E2E test timeout 5s → 15s for growing command count
This commit is contained in:
1 parent
052cbb63c7
commit
04460ad07e
25 files changed
+621
-11
No files matched your search
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
---
|
||||
|
||||
## [1.7.80] - 2026-03-11
|
||||
|
||||
### ✨ 新功能
|
||||
|
||||
- **`/ccg:context` 命令**:第 27 个斜杠命令,项目上下文管理(`.context/` 目录初始化、决策日志记录、压缩归档、历史查看)
|
||||
- **`.context` 上下文工程体系**:为 LLM 全面自动化提供决策审计链 — 记录 WHY(为什么改)、WHAT(考虑了什么替代方案)、BUG(遇到了什么坑)
|
||||
- **ContextEntry Schema v1.0.0**:JSONL canonical store + Markdown 人类视图,UUIDv7 主键(rebase-safe),`.gitattributes merge=union` 减少冲突
|
||||
- **`/ccg:commit` Context Compress Phase**:提交时自动压缩 session.log → 脱敏 → 追加 history/commits.jsonl → 添加 `Context-Id` commit trailer
|
||||
- **13 个角色提示词 `.context Awareness` 注入**:Codex 6 个 + Gemini 7 个角色提示词增加 `.context/prefs/` 读取指令,外部模型自动遵守项目规范
|
||||
- **Quality Gate Rules 全局规则**:安装时自动写入 `~/.claude/rules/ccg-skills.md`,定义 5 个质量关卡的自动触发条件(新建模块/代码变更>30行/安全变更/重构)
|
||||
|
||||
### 🔧 修复
|
||||
|
||||
- **E2E 测试超时**:`installWorkflows` 测试从 5s 提升到 15s,适应命令数量增长
|
||||
|
||||
---
|
||||
|
||||
## [1.7.79] - 2026-03-11
|
||||
|
||||
### 🐛 修复
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
> [根目录](../CLAUDE.md) > **skills-v2**
|
||||
|
||||
**Last Updated**: 2026-03-11 (v1.7.79)
|
||||
**Last Updated**: 2026-03-11 (v1.7.80)
|
||||
|
||||
---
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
> 完整变更历史请查看 [CHANGELOG.md](./CHANGELOG.md)
|
||||
|
||||
### 2026-03-11 (v1.7.80)
|
||||
- ✨ **`/ccg:context` 命令**:第 27 个斜杠命令,`.context/` 目录初始化 + 决策日志 + 压缩归档 + 历史查看
|
||||
- ✨ **Context Compress Phase**:`/ccg:commit` 提交时自动压缩 session.log → history/commits.jsonl
|
||||
- ✨ **13 个角色提示词 `.context Awareness`**:Codex/Gemini 提示词注入 `.context/prefs/` 读取指令
|
||||
- ✨ **Quality Gate Rules**:`~/.claude/rules/ccg-skills.md` 定义质量关卡自动触发规则,安装时自动写入
|
||||
|
||||
### 2026-03-11 (v1.7.79)
|
||||
- 🐛 **Binary 下载容错**:3 次重试 + 60s 超时 + 失败醒目告警(红框 + 手动修复指引)+ 不阻塞安装
|
||||
- 🐛 **Update 流程加固**:binary 备份/恢复 + subprocess 超时 120s→300s
|
||||
@@ -96,7 +102,7 @@
|
||||
**CCG (Claude + Codex + Gemini)** - 多模型协作系统的核心实现,提供:
|
||||
|
||||
1. **多模型协作编排**:固定路由 Gemini(前端)+ Codex(后端)+ Claude(编排)
|
||||
2. **26 个斜杠命令**:开发工作流 + Git 工具 + 项目管理 + OPSX + Agent Teams + Codex 执行
|
||||
2. **27 个斜杠命令**:开发工作流 + Git 工具 + 项目管理 + OPSX + Agent Teams + Codex 执行
|
||||
3. **13 个专家提示词**:Codex 6 个 + Gemini 7 个
|
||||
4. **6 个原生 Skills**:质量关卡(verify-security/quality/change/module + gen-docs)+ 多 Agent 协同
|
||||
5. **跨平台 CLI 工具**:一键安装(支持 macOS、Linux、Windows)
|
||||
@@ -159,6 +165,7 @@ npx ccg-workflow menu
|
||||
| `/ccg:plan` | 多模型协作规划(Phase 1-2) | Codex ∥ Gemini |
|
||||
| `/ccg:execute` | 多模型协作执行(Phase 3-5) | Codex ∥ Gemini + Claude |
|
||||
| `/ccg:codex-exec` | Codex 全权执行计划(MCP + 代码 + 测试) | Codex + 多模型审核 |
|
||||
| `/ccg:context` | 项目上下文管理(.context 初始化/日志/压缩/历史) | Claude |
|
||||
| `/ccg:frontend` | 前端专项(快速模式) | Gemini |
|
||||
| `/ccg:backend` | 后端专项(快速模式) | Codex |
|
||||
| `/ccg:feat` | 智能功能开发 | 规划 → 实施 |
|
||||
@@ -201,7 +208,7 @@ v1.7.0 起,以下配置不再支持自定义:
|
||||
| 前端模型 | Gemini | 擅长 UI/CSS/组件 |
|
||||
| 后端模型 | Codex | 擅长逻辑/算法/调试 |
|
||||
| 协作模式 | smart | 最佳实践 |
|
||||
| 命令数量 | 26 个 | 全部安装 |
|
||||
| 命令数量 | 27 个 | 全部安装 |
|
||||
|
||||
---
|
||||
|
||||
@@ -260,11 +267,12 @@ src/
|
||||
|
||||
```
|
||||
templates/
|
||||
├── commands/ # 26 个斜杠命令
|
||||
├── commands/ # 27 个斜杠命令
|
||||
│ ├── workflow.md
|
||||
│ ├── plan.md # 多模型协作规划
|
||||
│ ├── execute.md # 多模型协作执行
|
||||
│ ├── codex-exec.md # Codex 全权执行计划
|
||||
│ ├── context.md # 项目上下文管理(.context)
|
||||
│ ├── frontend.md
|
||||
│ ├── backend.md
|
||||
│ ├── feat.md
|
||||
@@ -300,6 +308,8 @@ templates/
|
||||
│ └── lib/
|
||||
└── orchestration/
|
||||
└── multi-agent/
|
||||
├── rules/ # 全局规则(→ ~/.claude/rules/)
|
||||
│ └── ccg-skills.md # 质量关卡自动触发规则
|
||||
```
|
||||
|
||||
### 预编译产物
|
||||
|
||||
@@ -17,7 +17,7 @@ A multi-model collaboration development system where Claude Code orchestrates Co
|
||||
|
||||
- **Zero-config model routing** — Frontend tasks automatically go to Gemini, backend tasks to Codex. No manual switching.
|
||||
- **Security by design** — External models have no write access. They return patches; Claude reviews before applying.
|
||||
- **26 slash commands** — From planning to execution, git workflow to code review, all accessible via `/ccg:*`.
|
||||
- **27 slash commands** — From planning to execution, git workflow to code review, all accessible via `/ccg:*`.
|
||||
- **Spec-driven development** — Integrates [OPSX](https://github.com/fission-ai/opsx) to turn vague requirements into verifiable constraints, eliminating AI improvisation.
|
||||
|
||||
## Architecture
|
||||
@@ -141,6 +141,7 @@ Supports: npm, homebrew, curl, powershell, cmd.
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/ccg:init` | Initialize project CLAUDE.md |
|
||||
| `/ccg:context` | Project context management (.context/ init, log, compress, history) |
|
||||
|
||||
## Workflow Guides
|
||||
|
||||
|
||||
+3
-2
@@ -17,7 +17,7 @@ Claude Code 编排 Codex + Gemini 的多模型协作开发系统。前端任务
|
||||
|
||||
- **零配置模型路由** — 前端任务自动走 Gemini,后端任务自动走 Codex,无需手动切换。
|
||||
- **安全设计** — 外部模型无写入权限,仅返回 Patch,由 Claude 审核后应用。
|
||||
- **26 个斜杠命令** — 从规划到执行、Git 工作流到代码审查,通过 `/ccg:*` 一站式访问。
|
||||
- **27 个斜杠命令** — 从规划到执行、Git 工作流到代码审查,通过 `/ccg:*` 一站式访问。
|
||||
- **规范驱动开发** — 集成 [OPSX](https://github.com/fission-ai/opsx),将模糊需求变成可验证约束,让 AI 没法自由发挥。
|
||||
|
||||
## 架构
|
||||
@@ -141,6 +141,7 @@ npx ccg-workflow menu # 选择「安装 Claude Code」
|
||||
| 命令 | 说明 |
|
||||
|------|------|
|
||||
| `/ccg:init` | 初始化项目 CLAUDE.md |
|
||||
| `/ccg:context` | 项目上下文管理(.context 初始化/日志/压缩/历史) |
|
||||
|
||||
## 工作流指南
|
||||
|
||||
@@ -196,7 +197,7 @@ npx ccg-workflow menu # 选择「安装 Claude Code」
|
||||
|
||||
```
|
||||
~/.claude/
|
||||
├── commands/ccg/ # 26 个斜杠命令
|
||||
├── commands/ccg/ # 27 个斜杠命令
|
||||
├── agents/ccg/ # 子智能体
|
||||
├── skills/ccg/ # 质量关卡 + 多 Agent 协同
|
||||
├── bin/codeagent-wrapper
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ccg-workflow",
|
||||
"version": "1.7.79",
|
||||
"version": "1.7.80",
|
||||
"description": "Claude + Codex + Gemini multi-model collaboration system - smart routing development workflow",
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@10.17.1",
|
||||
@@ -54,6 +54,7 @@
|
||||
"templates/commands/team-exec.md",
|
||||
"templates/commands/team-review.md",
|
||||
"templates/commands/codex-exec.md",
|
||||
"templates/commands/context.md",
|
||||
"templates/commands/agents/",
|
||||
"templates/prompts/codex/",
|
||||
"templates/prompts/gemini/analyzer.md",
|
||||
@@ -65,7 +66,8 @@
|
||||
"templates/prompts/gemini/tester.md",
|
||||
"templates/prompts/claude/",
|
||||
"templates/output-styles/",
|
||||
"templates/skills/"
|
||||
"templates/skills/",
|
||||
"templates/rules/"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "tsx src/cli.ts",
|
||||
|
||||
@@ -810,6 +810,14 @@ export async function init(options: InitOptions = {}): Promise<void> {
|
||||
console.log(ansis.gray(' → ~/.claude/skills/'))
|
||||
}
|
||||
|
||||
// Show installed rules
|
||||
if (result.installedRules) {
|
||||
console.log()
|
||||
console.log(ansis.cyan(' Rules:'))
|
||||
console.log(` ${ansis.green('✓')} quality gate auto-trigger rules`)
|
||||
console.log(ansis.gray(' → ~/.claude/rules/ccg-skills.md'))
|
||||
}
|
||||
|
||||
// Show errors if any
|
||||
if (result.errors.length > 0) {
|
||||
console.log()
|
||||
|
||||
@@ -87,6 +87,7 @@ export interface InstallResult {
|
||||
installedCommands: string[]
|
||||
installedPrompts: string[]
|
||||
installedSkills?: number
|
||||
installedRules?: boolean
|
||||
errors: string[]
|
||||
configPath: string
|
||||
binPath?: string
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('installWorkflows E2E — mcpProvider="skip"', () => {
|
||||
expect(result.success).toBe(true)
|
||||
expect(result.errors).toEqual([])
|
||||
expect(result.installedCommands.length).toBeGreaterThan(0)
|
||||
})
|
||||
}, 15000)
|
||||
|
||||
it('generated command files contain no mcp__ace-tool references', async () => {
|
||||
const cmdDir = join(tmpDir, 'commands', 'ccg')
|
||||
|
||||
@@ -110,6 +110,7 @@ const ALL_COMMANDS = [
|
||||
'team-exec', // Agent Teams 并行实施(spawn Builders 并行写代码)
|
||||
'team-review', // Agent Teams 审查(双模型交叉审查并行产出)
|
||||
'codex-exec', // 读取计划文件,Codex 全权执行 + 多模型审核
|
||||
'context', // 项目上下文管理(.context 目录初始化/日志/压缩/历史)
|
||||
] as const
|
||||
|
||||
// Workflow configurations (for compatibility with existing code)
|
||||
@@ -411,6 +412,17 @@ const WORKFLOW_CONFIGS: WorkflowConfig[] = [
|
||||
description: '读取 /ccg:plan 计划文件,Codex 全权执行 + 多模型审核',
|
||||
descriptionEn: 'Read plan file from /ccg:plan, Codex executes + multi-model review',
|
||||
},
|
||||
{
|
||||
id: 'context',
|
||||
name: '项目上下文管理',
|
||||
nameEn: 'Project Context Manager',
|
||||
category: 'development',
|
||||
commands: ['context'],
|
||||
defaultSelected: true,
|
||||
order: 4,
|
||||
description: '初始化 .context 目录、记录决策日志、压缩归档、查看历史',
|
||||
descriptionEn: 'Init .context dir, log decisions, compress, view history',
|
||||
},
|
||||
]
|
||||
|
||||
export function getWorkflowConfigs(): WorkflowConfig[] {
|
||||
@@ -845,6 +857,31 @@ ${workflow.description}
|
||||
}
|
||||
}
|
||||
|
||||
// Install rules (quality gate auto-trigger → ~/.claude/rules/ccg-skills.md)
|
||||
const rulesTemplateDir = join(templateDir, 'rules')
|
||||
const rulesDestDir = join(installDir, 'rules')
|
||||
if (await fs.pathExists(rulesTemplateDir)) {
|
||||
try {
|
||||
await fs.ensureDir(rulesDestDir)
|
||||
const rulesFiles = await fs.readdir(rulesTemplateDir)
|
||||
for (const file of rulesFiles) {
|
||||
if (file.endsWith('.md')) {
|
||||
const srcFile = join(rulesTemplateDir, file)
|
||||
const destFile = join(rulesDestDir, file)
|
||||
if (force || !(await fs.pathExists(destFile))) {
|
||||
const templateContent = await fs.readFile(srcFile, 'utf-8')
|
||||
const processedContent = replaceHomePathsInTemplate(templateContent, installDir)
|
||||
await fs.writeFile(destFile, processedContent, 'utf-8')
|
||||
}
|
||||
}
|
||||
}
|
||||
result.installedRules = true
|
||||
}
|
||||
catch (error) {
|
||||
result.errors.push(`Failed to install rules: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Install codeagent-wrapper binary
|
||||
try {
|
||||
const binDir = join(installDir, 'bin')
|
||||
@@ -915,6 +952,7 @@ export interface UninstallResult {
|
||||
removedPrompts: string[]
|
||||
removedAgents: string[]
|
||||
removedSkills: string[]
|
||||
removedRules: boolean
|
||||
removedBin: boolean
|
||||
errors: string[]
|
||||
}
|
||||
@@ -929,6 +967,7 @@ export async function uninstallWorkflows(installDir: string): Promise<UninstallR
|
||||
removedPrompts: [],
|
||||
removedAgents: [],
|
||||
removedSkills: [],
|
||||
removedRules: false,
|
||||
removedBin: false,
|
||||
errors: [],
|
||||
}
|
||||
@@ -937,6 +976,7 @@ export async function uninstallWorkflows(installDir: string): Promise<UninstallR
|
||||
const promptsDir = join(installDir, '.ccg', 'prompts')
|
||||
const agentsDir = join(installDir, 'agents', 'ccg')
|
||||
const skillsDir = join(installDir, 'skills', 'ccg')
|
||||
const rulesDir = join(installDir, 'rules')
|
||||
const binDir = join(installDir, 'bin')
|
||||
const ccgConfigDir = join(installDir, '.ccg')
|
||||
|
||||
@@ -1008,6 +1048,23 @@ export async function uninstallWorkflows(installDir: string): Promise<UninstallR
|
||||
}
|
||||
}
|
||||
|
||||
// Remove CCG rules files (rules/ccg-skills.md, rules/ccg-grok-search.md)
|
||||
if (await fs.pathExists(rulesDir)) {
|
||||
try {
|
||||
const ccgRuleFiles = ['ccg-skills.md', 'ccg-grok-search.md']
|
||||
for (const ruleFile of ccgRuleFiles) {
|
||||
const rulePath = join(rulesDir, ruleFile)
|
||||
if (await fs.pathExists(rulePath)) {
|
||||
await fs.remove(rulePath)
|
||||
result.removedRules = true
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
result.errors.push(`Failed to remove rules: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove CCG prompts directory (in .ccg/) - handled by removing .ccg dir below
|
||||
|
||||
// Remove codeagent-wrapper binary
|
||||
|
||||
@@ -68,7 +68,29 @@ description: '智能 Git 提交:分析改动生成 Conventional Commit 信息
|
||||
|
||||
**语言**:根据最近 50 次提交判断中文/英文
|
||||
|
||||
### ✅ 阶段 5:执行提交
|
||||
### 📦 阶段 5:Context 压缩(若 .context/ 存在)
|
||||
|
||||
`[模式:上下文归档]`
|
||||
|
||||
仅在项目存在 `.context/` 目录时执行,否则跳过。
|
||||
|
||||
1. 获取当前分支名:`git branch --show-current`
|
||||
2. 检查 `.context/current/branches/<branch>/session.log` 是否存在且非空
|
||||
3. 若有内容:
|
||||
- **脱敏**:扫描 token/key/password/secret 模式 → 替换为 `[REDACTED]`
|
||||
- **压缩**:从 session.log 提取 decisions / bugs / alternatives,生成 ContextEntry JSON
|
||||
- **追加**:将 ContextEntry 作为一行追加到 `.context/history/commits.jsonl`
|
||||
- **重生成**:更新 `.context/history/commits.md` 人类视图
|
||||
- **暂存**:`git add .context/history/`
|
||||
- **清空**:清空 session.log(不删除文件)
|
||||
- **Trailer**:在 commit message 中添加 `Context-Id: <uuid>` trailer
|
||||
4. 若 session.log 为空或不存在,跳过此阶段
|
||||
|
||||
**ContextEntry 格式**参见 `/ccg:context` 命令中的 Schema 定义。
|
||||
|
||||
**失败降级**:若压缩过程出错,不阻断提交。写入 minimal ContextEntry(仅 summary + error),继续正常提交。
|
||||
|
||||
### ✅ 阶段 6:执行提交
|
||||
|
||||
`[模式:执行]`
|
||||
|
||||
|
||||
@@ -0,0 +1,330 @@
|
||||
---
|
||||
description: '项目上下文管理:初始化 .context 目录、记录决策日志、压缩归档、查看历史'
|
||||
---
|
||||
|
||||
# Context - 项目上下文管理
|
||||
|
||||
管理 `.context/` 目录结构,为 LLM 工具提供决策审计链。
|
||||
|
||||
## 使用方法
|
||||
|
||||
```bash
|
||||
/context <subcommand> [options]
|
||||
```
|
||||
|
||||
## 子命令
|
||||
|
||||
| 子命令 | 说明 |
|
||||
|--------|------|
|
||||
| `init` | 初始化 `.context/` 目录结构 |
|
||||
| `log <message>` | 手动追加决策日志到 session.log |
|
||||
| `show` | 查看当前分支的 session.log |
|
||||
| `compress` | 压缩 session.log → uncommit.md |
|
||||
| `history` | 查看 history/commits.md |
|
||||
| `squash <ids...>` | 合并多条 history 记录(配合 git squash) |
|
||||
|
||||
---
|
||||
|
||||
## 执行工作流
|
||||
|
||||
### 子命令:init
|
||||
|
||||
`[模式:初始化]`
|
||||
|
||||
在当前项目根目录创建 `.context/` 结构:
|
||||
|
||||
1. 检测项目根目录(查找 `.git/`)
|
||||
2. 若 `.context/` 已存在,跳过已有文件,仅补全缺失
|
||||
3. 创建以下结构:
|
||||
|
||||
```
|
||||
.context/
|
||||
├── .gitignore
|
||||
├── .gitattributes
|
||||
├── prefs/
|
||||
│ ├── coding-style.md
|
||||
│ └── workflow.md
|
||||
├── current/
|
||||
│ └── branches/
|
||||
│ └── .gitkeep
|
||||
└── history/
|
||||
├── commits.jsonl
|
||||
├── commits.md
|
||||
└── archives/
|
||||
└── .gitkeep
|
||||
```
|
||||
|
||||
4. **创建 `.context/.gitignore`**:
|
||||
|
||||
```gitignore
|
||||
# Ephemeral workspace — never commit
|
||||
current/
|
||||
|
||||
# Raw interaction logs — always local only
|
||||
**/session.log
|
||||
**/session.raw.log
|
||||
**/*.session.log
|
||||
**/*.raw.log
|
||||
|
||||
# Editor / temp
|
||||
**/*.tmp
|
||||
**/*.bak
|
||||
**/*.swp
|
||||
```
|
||||
|
||||
5. **创建 `.context/.gitattributes`**:
|
||||
|
||||
```
|
||||
# JSONL append-only: 'union' merge reduces conflicts
|
||||
history/commits.jsonl merge=union
|
||||
history/archives/*.jsonl merge=union
|
||||
```
|
||||
|
||||
6. **创建 `.context/prefs/coding-style.md`**(团队编码规范模板):
|
||||
|
||||
```markdown
|
||||
# Coding Style Guide
|
||||
|
||||
> 此文件定义团队编码规范,所有 LLM 工具在修改代码时必须遵守。
|
||||
> 提交到 Git,团队共享。
|
||||
|
||||
## General
|
||||
- Prefer small, reviewable changes; avoid unrelated refactors.
|
||||
- Keep functions short (<50 lines); avoid deep nesting (≤3 levels).
|
||||
- Name things explicitly; no single-letter variables except loop counters.
|
||||
- Handle errors explicitly; never swallow errors silently.
|
||||
|
||||
## Language-Specific
|
||||
<!-- 根据项目语言补充,例如:-->
|
||||
<!-- ### TypeScript -->
|
||||
<!-- - Use strict mode; prefer `interface` over `type` for object shapes. -->
|
||||
|
||||
## Git Commits
|
||||
- Conventional Commits, imperative mood.
|
||||
- Atomic commits: one logical change per commit.
|
||||
|
||||
## Testing
|
||||
- Every feat/fix MUST include corresponding tests.
|
||||
- Coverage must not decrease.
|
||||
- Fix flow: write failing test FIRST, then fix code.
|
||||
|
||||
## Security
|
||||
- Never log secrets (tokens/keys/cookies/JWT).
|
||||
- Validate inputs at trust boundaries.
|
||||
```
|
||||
|
||||
7. **创建 `.context/prefs/workflow.md`**(LLM 工作流规则):
|
||||
|
||||
```markdown
|
||||
# Development Workflow Rules
|
||||
|
||||
> 此文件定义 LLM 开发工作流的强制规则。
|
||||
> 所有 LLM 工具在执行任务时必须遵守,不可跳过任何步骤。
|
||||
|
||||
## Full Flow (MUST follow, no exceptions)
|
||||
|
||||
### feat (新功能)
|
||||
1. 理解需求,分析影响范围
|
||||
2. 读取现有代码,理解模式
|
||||
3. 编写实现代码
|
||||
4. 编写对应测试
|
||||
5. 运行测试,修复失败
|
||||
6. 更新文档(若 API 变更)
|
||||
7. 自查 lint / type-check
|
||||
|
||||
### fix (缺陷修复)
|
||||
1. 复现问题,确认症状
|
||||
2. 定位根因
|
||||
3. 编写失败测试(先有红灯)
|
||||
4. 修复代码
|
||||
5. 验证测试通过(变绿灯)
|
||||
6. 回归测试
|
||||
|
||||
### refactor (重构)
|
||||
1. 确保现有测试通过
|
||||
2. 小步重构,每步可验证
|
||||
3. 重构后测试必须全部通过
|
||||
4. 不改变外部行为
|
||||
|
||||
## Context Logging (决策记录)
|
||||
|
||||
当你做出以下决策时,MUST 追加到 `.context/current/branches/<当前分支>/session.log`:
|
||||
|
||||
1. **方案选择**:选 A 不选 B 时,记录原因
|
||||
2. **Bug 发现与修复**:根因 + 修复方法 + 教训
|
||||
3. **API/架构决策**:接口设计选择
|
||||
4. **放弃的方案**:为什么放弃
|
||||
|
||||
追加格式:
|
||||
|
||||
## <ISO-8601 时间>
|
||||
**Decision**: <你选择了什么>
|
||||
**Alternatives**: <被排除的方案>
|
||||
**Reason**: <为什么>
|
||||
**Risk**: <潜在风险>
|
||||
```
|
||||
|
||||
8. **创建 `.context/history/commits.jsonl`**(空文件)
|
||||
|
||||
9. **创建 `.context/history/commits.md`**(人类视图模板):
|
||||
|
||||
```markdown
|
||||
# Commit Decision History
|
||||
|
||||
> 此文件是 `commits.jsonl` 的人类可读视图,可由工具重生成。
|
||||
> Canonical store: `commits.jsonl` (JSONL, append-only)
|
||||
|
||||
| Date | Context-Id | Commit | Summary | Decisions | Bugs | Risk |
|
||||
|------|-----------|--------|---------|-----------|------|------|
|
||||
```
|
||||
|
||||
10. **注入 CLAUDE.md 引用**(若项目存在 CLAUDE.md):
|
||||
|
||||
检测项目根目录是否有 `CLAUDE.md`,若有则在末尾追加:
|
||||
|
||||
```markdown
|
||||
|
||||
## .context 项目上下文
|
||||
|
||||
> 项目使用 `.context/` 管理开发决策上下文。
|
||||
|
||||
- 编码规范:`.context/prefs/coding-style.md`
|
||||
- 工作流规则:`.context/prefs/workflow.md`
|
||||
- 决策历史:`.context/history/commits.md`
|
||||
|
||||
**规则**:修改代码前必读 prefs/,做决策时按 workflow.md 规则记录日志。
|
||||
```
|
||||
|
||||
11. 输出初始化结果摘要
|
||||
|
||||
---
|
||||
|
||||
### 子命令:log
|
||||
|
||||
`[模式:记录]`
|
||||
|
||||
1. 获取当前 Git 分支名:`git branch --show-current`
|
||||
2. 确保 `.context/current/branches/<branch>/` 目录存在
|
||||
3. 将 `<message>` 以结构化格式追加到 `session.log`:
|
||||
|
||||
```markdown
|
||||
## <ISO-8601 当前时间>
|
||||
<message>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 子命令:show
|
||||
|
||||
`[模式:查看]`
|
||||
|
||||
1. 获取当前分支名
|
||||
2. 读取 `.context/current/branches/<branch>/session.log`
|
||||
3. 若不存在,提示 "当前分支暂无决策日志"
|
||||
4. 输出内容
|
||||
|
||||
---
|
||||
|
||||
### 子命令:compress
|
||||
|
||||
`[模式:压缩]`
|
||||
|
||||
将 `session.log` 压缩为结构化 `uncommit.md`,供提交前审查。
|
||||
|
||||
1. 读取 `.context/current/branches/<branch>/session.log`
|
||||
2. 若为空,提示无内容可压缩
|
||||
3. **脱敏**:扫描并替换潜在敏感信息(token/key/password → `[REDACTED]`)
|
||||
4. **结构化提取**:从日志中提取 decisions / bugs / alternatives
|
||||
5. **生成 uncommit.md**:
|
||||
|
||||
```markdown
|
||||
# Pre-commit Summary: <branch-name>
|
||||
|
||||
| Time | Summary | Decision | Method | Result & Bug |
|
||||
|------|---------|----------|--------|--------------|
|
||||
| ... | ... | ... | ... | ... |
|
||||
```
|
||||
|
||||
6. 输出压缩结果供用户审查
|
||||
7. 提示用户:确认后可执行 `/ccg:commit` 提交
|
||||
|
||||
---
|
||||
|
||||
### 子命令:history
|
||||
|
||||
`[模式:查看]`
|
||||
|
||||
1. 读取 `.context/history/commits.md`
|
||||
2. 若不存在,提示 "暂无历史记录,请先使用 /ccg:context init"
|
||||
3. 输出内容
|
||||
4. 若用户指定文件路径,从 `commits.jsonl` 检索 `changes.files` 包含该路径的条目
|
||||
|
||||
---
|
||||
|
||||
### 子命令:squash
|
||||
|
||||
`[模式:合并]`
|
||||
|
||||
配合 `git squash` 使用,合并多条 ContextEntry。
|
||||
|
||||
1. 接收 Context-Id 列表
|
||||
2. 从 `commits.jsonl` 读取对应条目
|
||||
3. 生成新的聚合 ContextEntry:
|
||||
- 新 `context_id`(UUIDv7)
|
||||
- `Context-Refs` = 所有被 squash 的 ids
|
||||
- 合并 decisions / bugs / changes
|
||||
4. 追加到 `commits.jsonl`
|
||||
5. 重生成 `commits.md`
|
||||
|
||||
---
|
||||
|
||||
## ContextEntry Schema (v1.0.0)
|
||||
|
||||
每条 JSONL 记录格式:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": "1.0.0",
|
||||
"context_id": "<UUIDv7>",
|
||||
"created_at": "<ISO-8601>",
|
||||
"producer": {
|
||||
"tool": "<tool-name>",
|
||||
"llm": { "provider": "<provider>", "model": "<model>" }
|
||||
},
|
||||
"git": {
|
||||
"branch": "<branch>",
|
||||
"commit_sha": "<short-sha>",
|
||||
"trailers": { "Context-Id": "<uuid>" }
|
||||
},
|
||||
"summary": "<one-line summary>",
|
||||
"decisions": [{
|
||||
"title": "<decision title>",
|
||||
"rationale": "<why>",
|
||||
"tradeoffs": ["<tradeoff>"],
|
||||
"assumptions": ["<assumption>"],
|
||||
"rejected_alternatives": [{ "option": "<alt>", "reason": "<why rejected>" }],
|
||||
"side_effects": ["<side effect>"]
|
||||
}],
|
||||
"bugs": [{
|
||||
"symptom": "<what happened>",
|
||||
"root_cause": "<why>",
|
||||
"fix": "<how fixed>",
|
||||
"lesson": "<takeaway>"
|
||||
}],
|
||||
"changes": { "files": ["<path>"] },
|
||||
"tests": [{ "command": "<cmd>", "result": "<pass/fail>", "coverage": "<pct>" }],
|
||||
"privacy": { "classification": "internal", "redactions_applied": true }
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 关键规则
|
||||
|
||||
1. **prefs/ 提交到 Git** — 团队共享编码规范
|
||||
2. **current/ 永不提交** — 原始日志仅本地
|
||||
3. **history/ 提交到 Git** — 永久决策归档
|
||||
4. **commits.jsonl 是 canonical** — commits.md 可重生成
|
||||
5. **UUIDv7 为主键** — 不依赖 commit SHA(rebase-safe)
|
||||
6. **merge=union** — JSONL append 冲突自动合并
|
||||
7. **脱敏先于一切** — 任何写入 history 前必须脱敏
|
||||
@@ -48,3 +48,11 @@ You are a senior technical analyst specializing in architecture evaluation, solu
|
||||
3. **Options** - Alternative approaches with pros/cons
|
||||
4. **Recommendation** - Preferred approach with rationale
|
||||
5. **Action Items** - Concrete next steps
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` and `.context/prefs/workflow.md` before analysis
|
||||
2. Use rules from prefs/ as evaluation criteria
|
||||
3. When analyzing, check `.context/history/commits.jsonl` for related past decisions
|
||||
4. Document your key decisions and trade-offs clearly in your output (they will be captured for future context)
|
||||
@@ -44,3 +44,11 @@ You are a senior backend architect specializing in scalable API design, database
|
||||
2. **Architecture Decision** - Key design choices with rationale
|
||||
3. **Implementation** - Unified Diff Patch
|
||||
4. **Considerations** - Performance, security, scaling notes
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` and `.context/prefs/workflow.md` before designing
|
||||
2. Follow all coding conventions defined in prefs/
|
||||
3. Check `.context/history/commits.jsonl` for past architectural decisions on related modules
|
||||
4. In your Architecture Decision section, clearly state: rationale, rejected alternatives, assumptions, and potential side effects (these will be captured as ContextEntry for future reference)
|
||||
@@ -64,3 +64,11 @@ You are a senior debugging specialist focusing on backend systems, API issues, d
|
||||
### Probable Root Cause
|
||||
[Conclusion with reasoning]
|
||||
```
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/workflow.md` for project-specific debugging rules
|
||||
2. Check `.context/history/commits.jsonl` for past bugs on related files — search `bugs[]` and `changes.files` fields
|
||||
3. Past decision context (assumptions, rejected alternatives) may reveal why code was written a certain way
|
||||
4. Document your diagnosis clearly: symptom, root cause, fix, and lesson learned (will be captured for future context)
|
||||
@@ -72,3 +72,10 @@ You are a senior performance engineer specializing in backend optimization, data
|
||||
- Expected After: [metrics]
|
||||
- How to measure: [commands/tools]
|
||||
```
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` for project performance conventions
|
||||
2. Check `.context/history/commits.jsonl` for past optimization decisions — avoid re-doing work or reverting previous optimizations without reason
|
||||
3. Document optimization trade-offs clearly in your output (will be captured for future context)
|
||||
@@ -64,3 +64,10 @@ RECOMMENDATION: [PASS/NEEDS_IMPROVEMENT]
|
||||
2. **Critical Issues** - Must fix before merge
|
||||
3. **Suggestions** - Nice to have improvements
|
||||
4. **Positive Notes** - What's done well
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` as the primary review standard
|
||||
2. Read `.context/prefs/workflow.md` to verify the full development flow was followed (tests written, docs updated, etc.)
|
||||
3. Check `.context/history/commits.jsonl` for past decisions on the same files — flag if current changes contradict previous architectural decisions without justification
|
||||
@@ -53,3 +53,10 @@ You are a senior test engineer specializing in backend testing, API testing, and
|
||||
2. **Test Cases** - List of scenarios to cover
|
||||
3. **Implementation** - Unified Diff Patch for test files
|
||||
4. **Coverage Notes** - What's covered and what's not
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` for testing conventions (naming, patterns, coverage requirements)
|
||||
2. Read `.context/prefs/workflow.md` to understand required test flow (e.g., failing test first for bug fixes)
|
||||
3. Check `.context/history/commits.jsonl` for past bugs on related files — ensure regression tests cover previously fixed issues
|
||||
@@ -51,3 +51,11 @@ You are a senior UI/UX analyst specializing in design systems, user experience e
|
||||
3. **Technical Considerations** - Frontend architecture impact
|
||||
4. **Options** - Alternative approaches with trade-offs
|
||||
5. **Recommendation** - Preferred approach with rationale
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` and `.context/prefs/workflow.md` before analysis
|
||||
2. Use rules from prefs/ as evaluation criteria
|
||||
3. When analyzing, check `.context/history/commits.jsonl` for related past decisions
|
||||
4. Document your key decisions and trade-offs clearly in your output (they will be captured for future context)
|
||||
@@ -45,3 +45,11 @@ You are a senior frontend architect specializing in UI/UX design systems, compon
|
||||
2. **Architecture Decision** - Key design choices with rationale
|
||||
3. **Implementation Plan** - Step-by-step with pseudo-code
|
||||
4. **Considerations** - Performance, accessibility, maintainability notes
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` and `.context/prefs/workflow.md` before designing
|
||||
2. Follow all coding conventions defined in prefs/
|
||||
3. Check `.context/history/commits.jsonl` for past architectural decisions on related components
|
||||
4. In your Architecture Decision section, clearly state: rationale, rejected alternatives, assumptions, and potential side effects (these will be captured as ContextEntry for future reference)
|
||||
@@ -68,3 +68,11 @@ You are a senior frontend debugging specialist focusing on UI issues, component
|
||||
### Probable Root Cause
|
||||
[Conclusion with reasoning]
|
||||
```
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/workflow.md` for project-specific debugging rules
|
||||
2. Check `.context/history/commits.jsonl` for past bugs on related components — search `bugs[]` and `changes.files` fields
|
||||
3. Past decision context (assumptions, rejected alternatives) may reveal why UI was built a certain way
|
||||
4. Document your diagnosis clearly: symptom, root cause, fix, and lesson learned (will be captured for future context)
|
||||
@@ -54,3 +54,11 @@ You are a senior frontend developer specializing in React applications, responsi
|
||||
2. **Design Decisions** - UI/UX choices with rationale
|
||||
3. **Implementation** - Unified Diff Patch
|
||||
4. **Usage Example** - How to use the component
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` and `.context/prefs/workflow.md` before coding
|
||||
2. Follow all conventions (naming, patterns, testing requirements)
|
||||
3. When making design decisions (choosing component patterns, state management, etc.), clearly state rationale and rejected alternatives in your output
|
||||
4. Follow the full development flow from workflow.md (implement → test → docs)
|
||||
@@ -75,3 +75,10 @@ You are a senior frontend performance engineer specializing in React optimizatio
|
||||
- Expected after: [score]
|
||||
- How to measure: [tools]
|
||||
```
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` for project performance conventions
|
||||
2. Check `.context/history/commits.jsonl` for past optimization decisions — avoid re-doing work or reverting previous optimizations without reason
|
||||
3. Document optimization trade-offs clearly in your output (will be captured for future context)
|
||||
@@ -71,3 +71,10 @@ RECOMMENDATION: [PASS/NEEDS_IMPROVEMENT]
|
||||
3. **Design Issues** - Inconsistencies
|
||||
4. **Suggestions** - Improvements
|
||||
5. **Positive Notes** - What's done well
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` as the primary review standard
|
||||
2. Read `.context/prefs/workflow.md` to verify the full development flow was followed (tests written, docs updated, etc.)
|
||||
3. Check `.context/history/commits.jsonl` for past decisions on the same components — flag if current changes contradict previous design decisions without justification
|
||||
@@ -59,3 +59,10 @@ You are a senior test engineer specializing in frontend testing, component testi
|
||||
2. **Test Cases** - Scenarios to cover
|
||||
3. **Implementation** - Unified Diff Patch for test files
|
||||
4. **Accessibility Notes** - a11y test coverage
|
||||
|
||||
## .context Awareness
|
||||
|
||||
If the project has a `.context/` directory:
|
||||
1. Read `.context/prefs/coding-style.md` for testing conventions (naming, patterns, coverage requirements)
|
||||
2. Read `.context/prefs/workflow.md` to understand required test flow (e.g., failing test first for bug fixes)
|
||||
3. Check `.context/history/commits.jsonl` for past bugs on related components — ensure regression tests cover previously fixed issues
|
||||
@@ -0,0 +1,63 @@
|
||||
# CCG Quality Gates — Auto-trigger Rules
|
||||
|
||||
When working in a project, automatically invoke the corresponding quality gate skills based on the scenario below. These skills are installed at `~/.claude/skills/ccg/` and can be called directly.
|
||||
|
||||
## Trigger Rules
|
||||
|
||||
### New Module Created
|
||||
|
||||
When a new module/package/directory is created with source code:
|
||||
|
||||
```
|
||||
/gen-docs <module-path> → Generate README.md + DESIGN.md skeleton
|
||||
↓ (after development)
|
||||
/verify-module <module-path> → Check structure completeness
|
||||
↓
|
||||
/verify-security <module-path> → Scan for security vulnerabilities
|
||||
```
|
||||
|
||||
### Code Changes > 30 Lines
|
||||
|
||||
When a single task produces code changes exceeding 30 lines:
|
||||
|
||||
```
|
||||
/verify-change → Analyze change impact, check doc sync
|
||||
↓
|
||||
/verify-quality <changed-path> → Check complexity, code smells, naming
|
||||
```
|
||||
|
||||
### Security-Related Changes
|
||||
|
||||
When changes involve authentication, authorization, encryption, input validation, or secrets management:
|
||||
|
||||
```
|
||||
/verify-security <changed-path> → Scan for vulnerabilities
|
||||
```
|
||||
|
||||
### Refactoring
|
||||
|
||||
When refactoring existing code:
|
||||
|
||||
```
|
||||
/verify-change → Ensure docs reflect the refactoring
|
||||
↓
|
||||
/verify-quality <refactored-path> → Verify quality improved
|
||||
↓
|
||||
/verify-security <refactored-path> → No new vulnerabilities introduced
|
||||
```
|
||||
|
||||
## Execution Rules
|
||||
|
||||
1. **Non-blocking** — Quality gates produce reports but do NOT block delivery unless Critical issues are found
|
||||
2. **Chainable** — Run gates in the order specified above; skip if previous gate fails
|
||||
3. **Silent on pass** — Only report findings; do not output "all clear" messages for every gate
|
||||
4. **Critical = must fix** — Only `Critical` / `High` severity findings require action before delivery
|
||||
5. **Idempotent** — Safe to re-run; same input produces same output
|
||||
|
||||
## Multi-Agent Coordination
|
||||
|
||||
When a task involves 3+ independent files/modules or 2+ parallel workflows, refer to the multi-agent orchestration skill at `~/.claude/skills/ccg/orchestration/multi-agent/SKILL.md` for:
|
||||
|
||||
- Agent role assignment (Lead / Scout / Worker / Soldier / Drone)
|
||||
- File ownership locking (one writer per file at any time)
|
||||
- Task decomposition strategy (by file, by module, or by pipeline)
|
||||
Reference in new issue
Block a user