dg
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDinesh vs Gilfoyle Code Review
Dinesh vs Gilfoyle 代码评审
Two-agent adversarial code review inspired by HBO's Silicon Valley. Gilfoyle attacks the code with withering technical precision. Dinesh defends it with flustered competence. The banter entertains; the back-and-forth produces genuinely better reviews.
受HBO《硅谷》启发的双Agent对抗式代码评审。Gilfoyle 以尖刻精准的技术视角攻击代码,Dinesh 则慌乱却不失专业地辩护。斗嘴妙趣横生,来回交锋间产出的评审质量着实更高。
Invocation
调用方式
- — review git diff (staged + unstaged)
/dg - — git diff, max 3 rounds
/dg 3 - — review specific file
/dg src/auth.ts - — specific file, 3 rounds max
/dg src/auth.ts 3
- — 评审 git diff(暂存+未暂存)
/dg - — git diff,最多3轮
/dg 3 - — 评审指定文件
/dg src/auth.ts - — 指定文件,最多3轮
/dg src/auth.ts 3
Parse Arguments
参数解析
- No args → target = git diff, cap = 5
- Number only → target = git diff, cap = that number
- Path only → target = that path, cap = 5
- Path + number → target = path, cap = number
- 无参数 → 目标 = git diff,上限 = 5
- 仅数字 → 目标 = git diff,上限 = 该数字
- 仅路径 → 目标 = 该路径,上限 = 5
- 路径 + 数字 → 目标 = 路径,上限 = 数字
Orchestration
编排流程
Step 1: Gather Code
步骤1:收集代码
If git diff:
bash
git diff HEAD
git diff --stagedCombine both diffs. If both are empty, tell the user there's nothing to review.
If file/path:
Read the target file(s). If path is a directory, read all source files in it.
Always: Gather dependency context.
Look for dependency files in the project root and include them in the context sent to agents:
- ,
package.json,package-lock.json,yarn.lock(Node.js)pnpm-lock.yaml - ,
requirements.txt,pyproject.toml(Python)Pipfile.lock - ,
go.mod(Go)go.sum - ,
pom.xml(Java)build.gradle - ,
Gemfile(Ruby)Gemfile.lock - ,
Cargo.toml(Rust)Cargo.lock - ,
composer.json(PHP)composer.lock
These are needed for Gilfoyle's dependency vulnerability scan.
如果是 git diff:
bash
git diff HEAD
git diff --staged合并两个diff的结果。如果两者都为空,告知用户没有可评审的内容。
如果是文件/路径:
读取目标文件。如果路径是目录,读取其中所有源文件。
始终执行:收集依赖上下文。
在项目根目录查找依赖文件,并将其包含在发送给Agent的上下文中:
- ,
package.json,package-lock.json,yarn.lock(Node.js)pnpm-lock.yaml - ,
requirements.txt,pyproject.toml(Python)Pipfile.lock - ,
go.mod(Go)go.sum - ,
pom.xml(Java)build.gradle - ,
Gemfile(Ruby)Gemfile.lock - ,
Cargo.toml(Rust)Cargo.lock - ,
composer.json(PHP)composer.lock
这些是Gilfoyle进行依赖漏洞扫描所需的内容。
Step 2: Run the Debate
步骤2:开展辩论
Initialize: ,
round = 0debate_history = []dot
digraph debate {
"Gather code" [shape=box];
"Dispatch Gilfoyle" [shape=box];
"New issues found?" [shape=diamond];
"Dispatch Dinesh" [shape=box];
"All conceded, no pushback?" [shape=diamond];
"Round >= cap?" [shape=diamond];
"Ask user: continue?" [shape=diamond];
"Synthesize final review" [shape=doublecircle];
"Gather code" -> "Dispatch Gilfoyle";
"Dispatch Gilfoyle" -> "New issues found?";
"New issues found?" -> "Synthesize final review" [label="no — converged"];
"New issues found?" -> "Dispatch Dinesh" [label="yes"];
"Dispatch Dinesh" -> "All conceded, no pushback?";
"All conceded, no pushback?" -> "Synthesize final review" [label="yes — converged"];
"All conceded, no pushback?" -> "Round >= cap?";
"Round >= cap?" -> "Dispatch Gilfoyle" [label="no — next round"];
"Round >= cap?" -> "Ask user: continue?" [label="yes"];
"Ask user: continue?" -> "Dispatch Gilfoyle" [label="yes — extend cap"];
"Ask user: continue?" -> "Synthesize final review" [label="no"];
}Each round:
-
Dispatch Gilfoyle agent (Agent tool, general-purpose) with:
- Full content of from this skill's directory
gilfoyle-agent.md - The code under review
- Full debate history
- Round number
- Instruction: "You are doing research only — read the code and produce your review. Do NOT edit any files."
- Full content of
-
Display Gilfoyle's banter to the user.
-
Check convergence: Parse Gilfoyle's FINDINGS section. If all findings are repeats from previous rounds → converge.
-
Dispatch Dinesh agent (Agent tool, general-purpose) with:
- Full content of from this skill's directory
dinesh-agent.md - The code under review
- Gilfoyle's latest full response
- Full debate history
- Round number
- Instruction: "You are doing research only — read the code and produce your defense. Do NOT edit any files."
- Full content of
-
Display Dinesh's banter to the user.
-
Check convergence: Parse Dinesh's FINDINGS section. If every point iswith zero
[concede]or[defend]→ converge.[dismiss] -
Append both responses to debate_history, increment round.
-
If round >= cap: Ask user: "These two could go all night. Continue for more rounds? (y/N)"
- Yes → extend cap by original amount, continue loop
- No → proceed to synthesis
Convergence announcements (pick one that fits):
- "Gilfoyle has run out of things to hate. Unprecedented."
- "Dinesh has conceded defeat. As expected."
- "These two are going in circles. Separating them before it gets physical."
初始化:,
round = 0debate_history = []dot
digraph debate {
"Gather code" [shape=box];
"Dispatch Gilfoyle" [shape=box];
"New issues found?" [shape=diamond];
"Dispatch Dinesh" [shape=box];
"All conceded, no pushback?" [shape=diamond];
"Round >= cap?" [shape=diamond];
"Ask user: continue?" [shape=diamond];
"Synthesize final review" [shape=doublecircle];
"Gather code" -> "Dispatch Gilfoyle";
"Dispatch Gilfoyle" -> "New issues found?";
"New issues found?" -> "Synthesize final review" [label="no — converged"];
"New issues found?" -> "Dispatch Dinesh" [label="yes"];
"Dispatch Dinesh" -> "All conceded, no pushback?";
"All conceded, no pushback?" -> "Synthesize final review" [label="yes — converged"];
"All conceded, no pushback?" -> "Round >= cap?";
"Round >= cap?" -> "Dispatch Gilfoyle" [label="no — next round"];
"Round >= cap?" -> "Ask user: continue?" [label="yes"];
"Ask user: continue?" -> "Dispatch Gilfoyle" [label="yes — extend cap"];
"Ask user: continue?" -> "Synthesize final review" [label="no"];
}每一轮:
-
调度 Gilfoyle Agent(Agent 工具,通用型),传入以下内容:
- 本skill目录下 的完整内容
gilfoyle-agent.md - 待评审代码
- 完整辩论历史
- 轮次编号
- 指令:「你仅负责调研 —— 阅读代码并给出评审意见。不要编辑任何文件。」
- 本skill目录下
-
向用户展示 Gilfoyle 的斗嘴内容。
-
检查收敛: 解析Gilfoyle的FINDINGS部分。如果所有发现都是之前轮次的重复 → 收敛。
-
调度 Dinesh Agent(Agent 工具,通用型),传入以下内容:
- 本skill目录下 的完整内容
dinesh-agent.md - 待评审代码
- Gilfoyle最新的完整回复
- 完整辩论历史
- 轮次编号
- 指令:「你仅负责调研 —— 阅读代码并给出辩护意见。不要编辑任何文件。」
- 本skill目录下
-
向用户展示 Dinesh 的斗嘴内容。
-
检查收敛: 解析Dinesh的FINDINGS部分。如果每一点都是,没有
[concede]或[defend]→ 收敛。[dismiss] -
将两份回复追加到 debate_history,轮次加1。
-
如果轮次 >= 上限: 询问用户:「这俩能吵一整晚。要继续加轮次吗?(y/N)」
- 是 → 按原上限增加轮次上限,继续循环
- 否 → 进入汇总阶段
收敛公告(选一个合适的):
- 「Gilfoyle 已经没东西可挑刺了。史无前例。」
- 「Dinesh 已经认输了。意料之中。」
- 「这俩在绕圈子。趁还没动手先把他俩拉开。」
Step 3: Synthesize Final Review
步骤3:汇总最终评审结果
After the debate ends, produce a structured summary from the full debate transcript.
Display format:
markdown
undefined辩论结束后,根据完整的辩论记录生成结构化总结。
显示格式:
markdown
undefinedDinesh vs Gilfoyle Review — [target]
Dinesh vs Gilfoyle Review — [target]
[N] rounds of mass destruction
[N] rounds of mass destruction
Best of the Banter
Best of the Banter
[2-4 of the funniest or most insightful exchanges from the debate]
[2-4 of the funniest or most insightful exchanges from the debate]
Verdict
Verdict
Critical (Gilfoyle won, Dinesh conceded)
Critical (Gilfoyle won, Dinesh conceded)
[Issues where Dinesh couldn't mount a defense — these are real and need fixing]
- — issue — fix
file:line
[Issues where Dinesh couldn't mount a defense — these are real and need fixing]
- — issue — fix
file:line
Important (Gilfoyle won after debate)
Important (Gilfoyle won after debate)
[Issues Dinesh tried to defend but Gilfoyle's argument was stronger]
- — issue — fix
file:line
[Issues Dinesh tried to defend but Gilfoyle's argument was stronger]
- — issue — fix
file:line
Contested (Dinesh held his ground)
Contested (Dinesh held his ground)
[Issues where Dinesh's defense was valid — code is likely fine]
- — what was raised — why the defense holds
file:line
[Issues where Dinesh's defense was valid — code is likely fine]
- — what was raised — why the defense holds
file:line
Dismissed (Gilfoyle was nitpicking)
Dismissed (Gilfoyle was nitpicking)
[Issues both sides agree don't matter]
- — what was raised — why it's a non-issue
file:line
[Issues both sides agree don't matter]
- — what was raised — why it's a non-issue
file:line
Strengths
Strengths
[Things even Gilfoyle grudgingly acknowledged were good]
[Things even Gilfoyle grudgingly acknowledged were good]
Score
Score
Gilfoyle: X | Dinesh: Y
[Tongue-in-cheek tally of who won more arguments]
Gilfoyle: X | Dinesh: Y
[Tongue-in-cheek tally of who won more arguments]
Recommended Changes
Recommended Changes
[Clean checklist — no banter, no context, just what to do]
- — what to change
file:line - — what to change
file:line - ...
If no changes needed: "Nothing to fix. Gilfoyle is furious."
undefined[Clean checklist — no banter, no context, just what to do]
- — what to change
file:line - — what to change
file:line - ...
If no changes needed: "Nothing to fix. Gilfoyle is furious."
undefinedStep 4: Offer Comic Strip
步骤4:提供连环漫画
After displaying the final review, ask the user:
"Want a comic strip of the best moments? (y/N/pr)"
- y — generate and open in browser
- pr — generate, convert to PNG, and attach to the current PR as a comment
- N — skip
If or , generate an HTML comic strip:
ypr- Read the comic template from in this skill's directory.
comic-template.html - Fill in the template placeholders:
- — the target reviewed (e.g., "UI Codebase", "git diff", file path)
{{REVIEW_TARGET}} - — number of debate rounds
{{ROUND_COUNT}} - /
{{GILFOYLE_SCORE}}— final scores{{DINESH_SCORE}} - — current date
{{DATE}} - — Generate 4-8 comic panels from the best banter exchanges. Each panel uses this HTML structure:
{{PANELS}}
html
<!-- Gilfoyle panel -->
<div class="panel gilfoyle">
<span class="panel-number">1</span>
<div class="panel-header">
<div class="avatar"><svg><use href="#gilfoyle-avatar"/></svg></div>
GILFOYLE
</div>
<div class="panel-body">
<div class="speech">The quote goes here. Use <code>inline code</code> for technical references.</div>
</div>
</div>
<!-- Dinesh panel -->
<div class="panel dinesh">
<span class="panel-number">2</span>
<div class="panel-header">
<div class="avatar"><svg><use href="#dinesh-avatar"/></svg></div>
DINESH
</div>
<div class="panel-body">
<div class="speech">The response goes here.</div>
</div>
</div>
<!-- Full-width panel for dramatic moments -->
<div class="panel gilfoyle full-width">
<span class="panel-number">3</span>
<div class="panel-header">
<div class="avatar"><svg><use href="#gilfoyle-avatar"/></svg></div>
GILFOYLE
</div>
<div class="panel-body">
<div class="speech">A particularly devastating line that deserves the full width.</div>
</div>
</div>- — Generate verdict items from the final review:
{{VERDICT_ITEMS}}
html
<div class="verdict-item">
<span class="tag tag-fixed">FIXED</span> CSP nonce replaced with deploy-time placeholder
</div>
<div class="verdict-item">
<span class="tag tag-contested">CONTESTED</span> MutationObserver lifetime — Dinesh held ground
</div>
<div class="verdict-item">
<span class="tag tag-dismissed">DISMISSED</span> prop-types — tree-shakes out
</div>-
Select the best moments for panels. Prioritize:
- The funniest exchanges (back-and-forth pairs work best)
- Moments where Gilfoyle conceded (rare, dramatic)
- Dinesh's best zingers
- The most technically devastating lines
- Keep quotes concise — trim to 1-3 sentences per speech bubble
-
Write the filled HTML to a timestamped file:
/tmp/dg-comic-{timestamp}.html
If :
5. Open it in the browser:
6. Tell the user where the file is saved.
yopen /tmp/dg-comic-{timestamp}.htmlIf :
5. Convert to PNG using a headless browser:
prbash
# Try puppeteer/chromium first, fall back to wkhtmltoimage, then to Safari
npx --yes puppeteer-screenshot /tmp/dg-comic-{timestamp}.html /tmp/dg-comic-{timestamp}.png 2>/dev/null \
|| wkhtmltoimage --quality 90 /tmp/dg-comic-{timestamp}.html /tmp/dg-comic-{timestamp}.png 2>/dev/null \
|| /usr/bin/osascript -e 'tell application "Safari" to open POSIX file "/tmp/dg-comic-{timestamp}.html"'If screenshot tools aren't available, tell the user to screenshot manually from the browser.
6. Detect the current PR:
bash
gh pr view --json number,url --jq '.number'- Upload the image and comment on the PR:
Note: Ifbash
gh pr comment {PR_NUMBER} --body "$(cat <<'EOF' ## /dg Review Comic Strip  _Generated by [/dg](https://github.com/v1r3n/dinesh-gilfoyle)_ EOF )"doesn't support local image upload, upload the image to the PR body as a drag-drop suggestion, or convert to base64 and embed.gh pr comment - Tell the user the comment was posted with a link to the PR.
展示最终评审结果后,询问用户:
「想要精彩片段的连环漫画吗?(y/N/pr)」
- y — 生成并在浏览器中打开
- pr — 生成后转换为PNG,作为评论附加到当前PR
- N — 跳过
如果选择 或 ,生成HTML连环漫画:
ypr- 读取本skill目录下的 漫画模板。
comic-template.html - 填充模板占位符:
- — 评审目标(例如「UI代码库」、「git diff」、文件路径)
{{REVIEW_TARGET}} - — 辩论轮次数
{{ROUND_COUNT}} - /
{{GILFOYLE_SCORE}}— 最终得分{{DINESH_SCORE}} - — 当前日期
{{DATE}} - — 从最精彩的斗嘴对话中生成4-8个漫画面板。每个面板使用以下HTML结构:
{{PANELS}}
html
<!-- Gilfoyle panel -->
<div class="panel gilfoyle">
<span class="panel-number">1</span>
<div class="panel-header">
<div class="avatar"><svg><use href="#gilfoyle-avatar"/></svg></div>
GILFOYLE
</div>
<div class="panel-body">
<div class="speech">The quote goes here. Use <code>inline code</code> for technical references.</div>
</div>
</div>
<!-- Dinesh panel -->
<div class="panel dinesh">
<span class="panel-number">2</span>
<div class="panel-header">
<div class="avatar"><svg><use href="#dinesh-avatar"/></svg></div>
DINESH
</div>
<div class="panel-body">
<div class="speech">The response goes here.</div>
</div>
</div>
<!-- Full-width panel for dramatic moments -->
<div class="panel gilfoyle full-width">
<span class="panel-number">3</span>
<div class="panel-header">
<div class="avatar"><svg><use href="#gilfoyle-avatar"/></svg></div>
GILFOYLE
</div>
<div class="panel-body">
<div class="speech">A particularly devastating line that deserves the full width.</div>
</div>
</div>- — 从最终评审结果生成结论项:
{{VERDICT_ITEMS}}
html
<div class="verdict-item">
<span class="tag tag-fixed">FIXED</span> CSP nonce replaced with deploy-time placeholder
</div>
<div class="verdict-item">
<span class="tag tag-contested">CONTESTED</span> MutationObserver lifetime — Dinesh held ground
</div>
<div class="verdict-item">
<span class="tag tag-dismissed">DISMISSED</span> prop-types — tree-shakes out
</div>-
选择最佳片段制作面板。 优先级:
- 最有趣的对话(一来一回的对话效果最好)
- Gilfoyle 认输的时刻(罕见,有戏剧性)
- Dinesh 最精彩的反击
- 技术上最具杀伤力的台词
- 保持引言简洁 —— 每个对话框删减到1-3句话
-
将填充后的HTML写入带时间戳的文件:
/tmp/dg-comic-{timestamp}.html
如果选择 :
5. 在浏览器中打开:
6. 告知用户文件保存位置。
yopen /tmp/dg-comic-{timestamp}.html如果选择 :
5. 使用无头浏览器转换为PNG:
prbash
# Try puppeteer/chromium first, fall back to wkhtmltoimage, then to Safari
npx --yes puppeteer-screenshot /tmp/dg-comic-{timestamp}.html /tmp/dg-comic-{timestamp}.png 2>/dev/null \
|| wkhtmltoimage --quality 90 /tmp/dg-comic-{timestamp}.html /tmp/dg-comic-{timestamp}.png 2>/dev/null \
|| /usr/bin/osascript -e 'tell application "Safari" to open POSIX file "/tmp/dg-comic-{timestamp}.html"'如果截图工具不可用,告知用户手动从浏览器截图。
6. 检测当前PR:
bash
gh pr view --json number,url --jq '.number'- 上传图片并在PR上评论:
注意:如果bash
gh pr comment {PR_NUMBER} --body "$(cat <<'EOF' ## /dg Review Comic Strip  _Generated by [/dg](https://github.com/v1r3n/dinesh-gilfoyle)_ EOF )"不支持本地图片上传,将图片作为拖拽建议上传到PR正文,或转换为base64嵌入。gh pr comment - 告知用户评论已发布,并提供PR链接。
Key Principles
核心原则
- The banter is the feature, not decoration — it keeps reviews entertaining and thorough
- Dinesh's concessions are the strongest signal — when he can't defend, it's a real issue
- Successful defenses validate code — if Dinesh can justify it under Gilfoyle's assault, it's solid
- Always end with actionable summary — fun on the outside, useful on the inside
- Be technically correct — the humor only works if the technical substance is real
- 斗嘴是核心功能,而非装饰 —— 它让评审既有趣又全面
- Dinesh 的认输是最强信号 —— 当他无法辩护时,说明问题确实存在
- 成功的辩护验证了代码质量 —— 如果Dinesh能在Gilfoyle的猛攻下自圆其说,说明代码很可靠
- 始终以可行动的总结收尾 —— 外表有趣,内核实用
- 技术上必须正确 —— 只有技术内容真实可信,幽默才有意义