candid-loop
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCandid Loop
Candid 循环
Run repeatedly until your code is clean. This skill automates the fix-review-fix cycle, applying fixes and re-running reviews until no issues remain (or max iterations is reached).
candid-review重复运行,直至你的代码无问题。该Skill可自动化修复-审核-修复的循环流程,应用修复并重新运行审核,直至无问题残留(或达到最大迭代次数)。
candid-reviewWorkflow
工作流程
Execute these steps in order:
按以下顺序执行步骤:
Step 1: Load Configuration
步骤1:加载配置
Load loop configuration from CLI flags and config files.
Precedence (highest to lowest):
- CLI flags
- Project config (→
.candid/config.jsonfield)loop - User config (→
~/.candid/config.jsonfield)loop - Defaults
从CLI参数和配置文件中加载循环配置。
优先级(从高到低):
- CLI参数
- 项目配置(→
.candid/config.json字段)loop - 用户配置(→
~/.candid/config.json字段)loop - 默认值
Check CLI Arguments
检查CLI参数
Parse CLI arguments for loop options:
| Flag | Description | Default |
|---|---|---|
| Execution mode | |
| Maximum loop iterations | |
| Categories to enforce (comma-separated) | |
Valid modes:
- - Automatically apply all fixes
auto - - Go through each fix one by one (Yes/No for each)
review-each - - Full control with skip, ignore, and batch options
interactive
Valid categories: , , , , , ,
criticalmajorstandardssmelledge_casearchitecturalallIf CLI flags are provided, use them and skip config file checks for those specific options.
解析CLI参数中的循环选项:
| 参数 | 描述 | 默认值 |
|---|---|---|
| 执行模式 | |
| 最大循环迭代次数 | |
| 要强制执行的分类(逗号分隔) | |
有效模式:
- - 自动应用所有修复
auto - - 逐个查看每个修复(对每个修复选择是/否)
review-each - - 完全控制,支持跳过、忽略和批量处理选项
interactive
有效分类: , , , , , ,
criticalmajorstandardssmelledge_casearchitecturalall如果提供了CLI参数,则使用这些参数,并跳过对应选项的配置文件检查。
Check Project Config
检查项目配置
Read and extract the field:
.candid/config.jsonloopbash
jq -r '.loop // null' .candid/config.json 2>/dev/nullIf the field exists:
loop- Extract if not set by CLI
mode - Extract if not set by CLI
maxIterations - Extract if not set by CLI
enforceCategories - Extract object (categories, patterns, ids)
ignored
Output when loading from config:
Using loop settings from project config读取并提取字段:
.candid/config.jsonloopbash
jq -r '.loop // null' .candid/config.json 2>/dev/null如果字段存在:
loop- 若CLI未设置则提取该值
mode - 若CLI未设置则提取该值
maxIterations - 若CLI未设置则提取该值
enforceCategories - 提取对象(分类、模式、ID)
ignored
加载配置时输出:
Using loop settings from project configCheck User Config
检查用户配置
Same procedure for if project config doesn't have field.
~/.candid/config.jsonloopOutput when loading from user config:
Using loop settings from user config如果项目配置中没有字段,对执行相同操作。
loop~/.candid/config.json加载配置时输出:
Using loop settings from user configApply Defaults
应用默认值
For any options not set by CLI or config:
mode = "auto"
maxIterations = 5
enforceCategories = ["all"]
ignored = { categories: [], patterns: [], ids: [] }对于任何未通过CLI或配置设置的选项:
mode = "auto"
maxIterations = 5
enforceCategories = ["all"]
ignored = { categories: [], patterns: [], ids: [] }Step 2: Initialize Loop State
步骤2:初始化循环状态
Set up tracking variables:
iteration = 0
totalFixesApplied = 0
allFixedIssues = []Display mode banner:
Auto mode:
[Auto Mode] Running candid-loop with max [N] iterations...Review-each mode:
[Review-Each Mode] Running candid-loop with max [N] iterations...
You will review each fix one by one.Interactive mode:
[Interactive Mode] Running candid-loop with max [N] iterations...
Full control: skip, ignore, or batch process fixes.设置跟踪变量:
iteration = 0
totalFixesApplied = 0
allFixedIssues = []显示模式横幅:
自动模式:
[自动模式] 运行candid-loop,最大迭代次数为[N]...逐个审核模式:
[逐个审核模式] 运行candid-loop,最大迭代次数为[N]...
你将逐个审核每个修复。交互模式:
[交互模式] 运行candid-loop,最大迭代次数为[N]...
完全控制:跳过、忽略或批量处理修复。Step 3: Run Review Loop
步骤3:运行审核循环
Execute the main loop:
WHILE iteration < maxIterations:
iteration++
Execute Step 3.1 through Step 3.6
IF exitLoop == true:
BREAK
IF iteration >= maxIterations AND remainingIssues > 0:
Output warning: "Max iterations ([N]) reached. [M] issues remain."
List remaining issues执行主循环:
WHILE iteration < maxIterations:
iteration++
执行步骤3.1至步骤3.6
IF exitLoop == true:
BREAK
IF iteration >= maxIterations AND remainingIssues > 0:
输出警告:"已达到最大迭代次数([N])。剩余[M]个问题。"
列出剩余问题Step 3.1: Run candid-review
步骤3.1:运行candid-review
Display iteration header:
[Iteration [N]/[MAX]]
Running candid-review...Invoke the candid-review skill to analyze current code:
- Use the Skill tool to run
/candid-review - Pass through tone settings if configured
- Wait for review to complete and save state to
.candid/last-review.json
Note: candid-review will present its own fix selection prompt. In auto mode, we need to handle this by selecting "Apply all fixes". In interactive mode, we defer to the user's choices within candid-review.
显示迭代标题:
[迭代次数 [N]/[MAX]]
正在运行candid-review...调用candid-review Skill分析当前代码:
- 使用Skill工具运行
/candid-review - 如果配置了语气设置则传递该设置
- 等待审核完成并将状态保存到
.candid/last-review.json
注意: candid-review会显示自己的修复选择提示。在自动模式下,我们需要通过选择"应用所有修复"来处理该提示。在交互模式下,我们将决定权交给candid-review中的用户选择。
Step 3.2: Read Review Results
步骤3.2:读取审核结果
After candid-review completes, read the saved review state:
bash
cat .candid/last-review.json 2>/dev/nullParse the JSON to extract:
- array with all found issues
issues - Each issue has: ,
id,file,line,category,titledescription
If file doesn't exist or is empty:
No review state found. candid-review may not have completed.Exit with error.
candid-review完成后,读取保存的审核状态:
bash
cat .candid/last-review.json 2>/dev/null解析JSON以提取:
- 数组,包含所有发现的问题
issues - 每个问题包含:,
id,file,line,category,titledescription
如果文件不存在或为空:
未找到审核状态。candid-review可能未完成。退出并显示错误。
Step 3.3: Filter Issues by Category
步骤3.3:按分类筛选问题
If is NOT :
enforceCategories["all"]Filter the issues array to only include issues matching enforceCategories:
filteredIssues = issues.filter(issue =>
enforceCategories.includes(issue.category)
)Category mapping:
- → issues with category "critical"
critical - → issues with category "major"
major - → issues with category "standards"
standards - → issues with category "smell"
smell - → issues with category "edge_case"
edge_case - → issues with category "architectural"
architectural
Output:
Enforcing categories: [list]. Filtered to [N] issues.如果不是:
enforceCategories["all"]过滤issues数组,仅保留与enforceCategories匹配的问题:
filteredIssues = issues.filter(issue =>
enforceCategories.includes(issue.category)
)分类映射:
- → 分类为"critical"的问题
critical - → 分类为"major"的问题
major - → 分类为"standards"的问题
standards - → 分类为"smell"的问题
smell - → 分类为"edge_case"的问题
edge_case - → 分类为"architectural"的问题
architectural
输出:
强制执行分类:[列表]。已筛选至[N]个问题。Step 3.4: Filter Out Ignored Issues
步骤3.4:过滤掉忽略的问题
Apply the ignored filters from config:
1. Filter by ignored categories:
filteredIssues = filteredIssues.filter(issue =>
!ignored.categories.includes(issue.category)
)2. Filter by ignored patterns (regex match on title):
filteredIssues = filteredIssues.filter(issue =>
!ignored.patterns.some(pattern =>
new RegExp(pattern, 'i').test(issue.title)
)
)3. Filter by ignored IDs:
filteredIssues = filteredIssues.filter(issue =>
!ignored.ids.includes(issue.id)
)If any issues were filtered:
Filtered out [N] ignored issues ([M] remaining)应用配置中的忽略筛选规则:
1. 按忽略的分类筛选:
filteredIssues = filteredIssues.filter(issue =>
!ignored.categories.includes(issue.category)
)2. 按忽略的模式筛选(匹配标题的正则表达式):
filteredIssues = filteredIssues.filter(issue =>
!ignored.patterns.some(pattern =>
new RegExp(pattern, 'i').test(issue.title)
)
)3. 按忽略的ID筛选:
filteredIssues = filteredIssues.filter(issue =>
!ignored.ids.includes(issue.id)
)如果有任何问题被过滤:
已过滤掉[N]个被忽略的问题(剩余[M]个)Step 3.5: Check for Completion
步骤3.5:检查是否完成
If :
filteredIssues.length === 0[Iteration [N]/[MAX]] No issues found!
exitLoop = trueSkip to Step 4 (Summary).
如果:
filteredIssues.length === 0[迭代次数 [N]/[MAX]] 未发现问题!
exitLoop = true跳至步骤4(总结)。
Step 3.6: Handle Issues Based on Mode
步骤3.6:根据模式处理问题
If mode == "auto":
Display found issues:
[N/MAX] Found [M] issues. Applying fixes...The candid-review skill will have already applied fixes if the user selected "Apply all fixes" in its prompt. Since we're in auto mode, we should have configured candid-review to auto-apply.
For each issue that was fixed, log:
✓ [icon] Fixed: [title] in [file]:[line]Track fixes:
totalFixesApplied += appliedCount
allFixedIssues.push(...appliedIssues)Continue to next iteration.
If mode == "review-each":
Go through each fix one by one with simple Yes/No prompts.
Display found issues:
[N/MAX] Found [M] issues. Reviewing each...For each issue, use AskUserQuestion:
[1/M] [icon] [title]
File: [file]:[line]
Problem: [description]Question: "Apply this fix?"
Options:
- "Yes, apply this fix"
- "No, skip this fix"
Track user choices:
- If "Yes" → Apply the fix, increment totalFixesApplied
- If "No" → Continue to next issue
After processing all issues, if any fixes were applied, continue to next iteration.
If mode == "interactive":
Full control mode with additional options for skipping, ignoring, and batch processing.
Display found issues:
Found [M] issues:For each issue, use AskUserQuestion:
[1/M] [icon] [title]
File: [file]:[line]
Problem: [description]Question: "How would you like to handle this issue?"
Options:
- "Apply fix" - Apply this fix and continue
- "Skip" - Skip this issue and continue to next
- "Add to ignore list" - Add this issue ID to ignored.ids and skip
- "Skip all remaining" - Exit the loop with remaining issues listed
Track user choices:
- If "Apply fix" → Apply the fix, increment totalFixesApplied
- If "Skip" → Continue to next issue
- If "Add to ignore list" → Add issue.id to ignored.ids in config, continue
- If "Skip all remaining" → Set exitLoop = true, break inner loop
After processing all issues in interactive mode, if any fixes were applied, continue to next iteration.
如果模式为"auto":
显示发现的问题:
[N/MAX] 发现[M]个问题。正在应用修复...如果用户在candid-review的提示中选择了"应用所有修复",则该Skill已应用修复。由于我们处于自动模式,应已配置candid-review自动应用修复。
对于每个已修复的问题,记录:
✓ [图标] 已修复:[标题] in [file]:[line]跟踪修复情况:
totalFixesApplied += appliedCount
allFixedIssues.push(...appliedIssues)继续下一次迭代。
如果模式为"review-each":
通过简单的是/否提示逐个处理每个修复。
显示发现的问题:
[N/MAX] 发现[M]个问题。正在逐个审核...对于每个问题,使用AskUserQuestion:
[1/M] [图标] [标题]
文件:[file]:[line]
问题:[description]问题: "是否应用此修复?"
选项:
- "是,应用此修复"
- "否,跳过此修复"
跟踪用户选择:
- 如果选择"是" → 应用修复,增加totalFixesApplied
- 如果选择"否" → 继续处理下一个问题
处理完所有问题后,如果应用了任何修复,继续下一次迭代。
如果模式为"interactive":
完全控制模式,支持跳过、忽略和批量处理的额外选项。
显示发现的问题:
发现[M]个问题:对于每个问题,使用AskUserQuestion:
[1/M] [图标] [标题]
文件:[file]:[line]
问题:[description]问题: "你想如何处理此问题?"
选项:
- "应用修复" - 应用此修复并继续
- "跳过" - 跳过此问题并继续下一个
- "添加到忽略列表" - 将此问题ID添加到ignored.ids并跳过
- "跳过所有剩余问题" - 退出循环并列出剩余问题
跟踪用户选择:
- 如果选择"应用修复" → 应用修复,增加totalFixesApplied
- 如果选择"跳过" → 继续处理下一个问题
- 如果选择"添加到忽略列表" → 将issue.id添加到配置中的ignored.ids,继续
- 如果选择"跳过所有剩余问题" → 设置exitLoop = true,中断内层循环
在交互模式下处理完所有问题后,如果应用了任何修复,继续下一次迭代。
Step 3.7: Update Ignore List (If Requested)
步骤3.7:更新忽略列表(如果有请求)
If user chose "Add to ignore list" for any issues:
- Read current (or create if doesn't exist)
.candid/config.json - Add issue IDs to array
loop.ignored.ids - Write updated config back to file
bash
undefined如果用户选择将任何问题"添加到忽略列表":
- 读取当前的(如果不存在则创建)
.candid/config.json - 将问题ID添加到数组
loop.ignored.ids - 将更新后的配置写回文件
bash
undefinedRead, modify, write
读取、修改、写入
jq '.loop.ignored.ids += ["issue-id-1", "issue-id-2"]' .candid/config.json > tmp.json
mv tmp.json .candid/config.json
Output: `Added [N] issues to ignore list in .candid/config.json`jq '.loop.ignored.ids += ["issue-id-1", "issue-id-2"]' .candid/config.json > tmp.json
mv tmp.json .candid/config.json
输出:`已将[N]个问题添加到.candid/config.json的忽略列表中`Step 4: Display Summary
步骤4:显示总结
After loop exits (success or max iterations), display final summary:
Success (no issues remaining):
Candid Loop Complete
Summary:
- Iterations: [N]
- Issues fixed: [M]
- Status: PASS
Your code is clean!Max iterations reached:
Candid Loop Stopped
Summary:
- Iterations: [N] (max reached)
- Issues fixed: [M]
- Issues remaining: [P]
- Status: INCOMPLETE
Remaining issues:
[icon] [title] in [file]:[line]
[icon] [title] in [file]:[line]
...
Consider:
- Increasing --max-iterations
- Adding persistent ignores for false positives
- Manually reviewing complex issuesUser cancelled (interactive mode):
Candid Loop Cancelled
Summary:
- Iterations: [N]
- Issues fixed: [M]
- Issues skipped: [P]
- Status: CANCELLED
Skipped issues:
[icon] [title] in [file]:[line]
...循环退出后(成功或达到最大迭代次数),显示最终总结:
成功(无剩余问题):
Candid 循环完成
总结:
- 迭代次数:[N]
- 已修复问题数:[M]
- 状态:通过
你的代码已无问题!达到最大迭代次数:
Candid 循环已停止
总结:
- 迭代次数:[N](已达最大值)
- 已修复问题数:[M]
- 剩余问题数:[P]
- 状态:未完成
剩余问题:
[图标] [标题] in [file]:[line]
[图标] [标题] in [file]:[line]
...
建议:
- 增加--max-iterations的值
- 为误报添加持久忽略规则
- 手动审核复杂问题用户取消(交互模式):
Candid 循环已取消
总结:
- 迭代次数:[N]
- 已修复问题数:[M]
- 已跳过问题数:[P]
- 状态:已取消
已跳过的问题:
[图标] [标题] in [file]:[line]
...Configuration
配置
Config File Schema
配置文件 Schema
Add to :
.candid/config.jsonjson
{
"version": 1,
"tone": "harsh",
"loop": {
"mode": "auto",
"maxIterations": 5,
"enforceCategories": ["all"],
"ignored": {
"categories": [],
"patterns": [],
"ids": []
}
}
}添加至:
.candid/config.jsonjson
{
"version": 1,
"tone": "harsh",
"loop": {
"mode": "auto",
"maxIterations": 5,
"enforceCategories": ["all"],
"ignored": {
"categories": [],
"patterns": [],
"ids": []
}
}
}Field Descriptions
字段说明
| Field | Type | Default | Description |
|---|---|---|---|
| string | | |
| number | | Maximum review-fix cycles |
| array | | Categories to enforce |
| array | | Categories to skip entirely |
| array | | Regex patterns to match issue titles |
| array | | Specific issue IDs to skip |
| 字段 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| 字符串 | | 可选值: |
| 数字 | | 最大审核-修复循环次数 |
| 数组 | | 要强制执行的分类 |
| 数组 | | 完全跳过的分类 |
| 数组 | | 匹配问题标题的正则表达式模式 |
| 数组 | | 要跳过的特定问题ID |
Examples
示例
Ignore all edge cases and architectural issues:
json
{
"loop": {
"ignored": {
"categories": ["edge_case", "architectural"]
}
}
}Ignore issues mentioning Unicode or timezone:
json
{
"loop": {
"ignored": {
"patterns": ["Unicode", "timezone", "DST"]
}
}
}Only enforce critical and major issues:
json
{
"loop": {
"enforceCategories": ["critical", "major"]
}
}忽略所有边缘情况和架构问题:
json
{
"loop": {
"ignored": {
"categories": ["edge_case", "architectural"]
}
}
}忽略提及Unicode或时区的问题:
json
{
"loop": {
"ignored": {
"patterns": ["Unicode", "timezone", "DST"]
}
}
}仅强制执行严重和主要问题:
json
{
"loop": {
"enforceCategories": ["critical", "major"]
}
}CLI Examples
CLI 示例
bash
undefinedbash
undefinedRun with defaults (auto mode, all categories, max 5 iterations)
使用默认值运行(自动模式,所有分类,最大5次迭代)
/candid-loop
/candid-loop
Review-each mode - go through each fix one by one (Yes/No)
逐个审核模式 - 逐个查看每个修复(是/否)
/candid-loop --mode review-each
/candid-loop --mode review-each
Interactive mode - full control with skip, ignore, batch options
交互模式 - 完全控制,支持跳过、忽略和批量处理选项
/candid-loop --mode interactive
/candid-loop --mode interactive
Limit iterations
限制迭代次数
/candid-loop --max-iterations 3
/candid-loop --max-iterations 3
Only fix critical issues
仅修复严重问题
/candid-loop --categories critical
/candid-loop --categories critical
Fix critical and major issues
修复严重和主要问题
/candid-loop --categories critical,major
/candid-loop --categories critical,major
Combine options
组合选项
/candid-loop --mode review-each --max-iterations 10 --categories critical,major
undefined/candid-loop --mode review-each --max-iterations 10 --categories critical,major
undefinedIssue Categories Reference
问题分类参考
| Category | Icon | Description |
|---|---|---|
| 🔥 | Production killers: crashes, security holes, data loss |
| ⚠️ | Serious problems: performance, missing error handling |
| 📜 | Technical.md violations |
| 📋 | Maintainability: complexity, duplication |
| 🤔 | Unhandled scenarios: null, empty, concurrent |
| 💭 | Design concerns: coupling, SRP violations |
| 分类 | 图标 | 描述 |
|---|---|---|
| 🔥 | 生产环境致命问题:崩溃、安全漏洞、数据丢失 |
| ⚠️ | 严重问题:性能、缺少错误处理 |
| 📜 | 违反Technical.md规范 |
| 📋 | 可维护性问题:复杂度、重复代码 |
| 🤔 | 未处理的场景:空值、空输入、并发 |
| 💭 | 设计问题:耦合、违反单一职责原则 |
Remember
注意事项
The goal of candid-loop is to automate the review-fix cycle so you can quickly get your code to a clean state.
Mode selection:
- auto - Fast iteration, applies all fixes automatically
- review-each - Go through each fix one by one with simple Yes/No
- interactive - Full control with skip, ignore list, and batch options
Best practices:
- Start with auto mode for quick cleanup
- Use review-each mode to understand what's being fixed
- Use interactive mode when you need to ignore or skip specific issues
- Add patterns to ignore list for known false positives
- Keep maxIterations reasonable (5-10) to avoid infinite loops
- Review the summary to understand what was fixed
Candid循环的目标是自动化审核-修复循环,让你快速将代码清理至无问题状态。
模式选择建议:
- auto - 快速迭代,自动应用所有修复
- review-each - 逐个查看每个修复,了解修复内容
- interactive - 需要忽略或跳过特定问题时使用,完全控制
- 为已知误报添加忽略模式
- 保持maxIterations在合理范围(5-10),避免无限循环
- 查看总结了解已修复的问题