dg

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Dinesh 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

调用方式

  • /dg
    — review git diff (staged + unstaged)
  • /dg 3
    — git diff, max 3 rounds
  • /dg src/auth.ts
    — review specific file
  • /dg src/auth.ts 3
    — specific file, 3 rounds max
  • /dg
    — 评审 git diff(暂存+未暂存)
  • /dg 3
    — git diff,最多3轮
  • /dg src/auth.ts
    — 评审指定文件
  • /dg src/auth.ts 3
    — 指定文件,最多3轮

Parse Arguments

参数解析

  1. No args → target = git diff, cap = 5
  2. Number only → target = git diff, cap = that number
  3. Path only → target = that path, cap = 5
  4. Path + number → target = path, cap = number
  1. 无参数 → 目标 = git diff,上限 = 5
  2. 仅数字 → 目标 = git diff,上限 = 该数字
  3. 仅路径 → 目标 = 该路径,上限 = 5
  4. 路径 + 数字 → 目标 = 路径,上限 = 数字

Orchestration

编排流程

Step 1: Gather Code

步骤1:收集代码

If git diff:
bash
git diff HEAD
git diff --staged
Combine 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
    ,
    pnpm-lock.yaml
    (Node.js)
  • requirements.txt
    ,
    pyproject.toml
    ,
    Pipfile.lock
    (Python)
  • go.mod
    ,
    go.sum
    (Go)
  • pom.xml
    ,
    build.gradle
    (Java)
  • Gemfile
    ,
    Gemfile.lock
    (Ruby)
  • Cargo.toml
    ,
    Cargo.lock
    (Rust)
  • composer.json
    ,
    composer.lock
    (PHP)
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
    ,
    pnpm-lock.yaml
    (Node.js)
  • requirements.txt
    ,
    pyproject.toml
    ,
    Pipfile.lock
    (Python)
  • go.mod
    ,
    go.sum
    (Go)
  • pom.xml
    ,
    build.gradle
    (Java)
  • Gemfile
    ,
    Gemfile.lock
    (Ruby)
  • Cargo.toml
    ,
    Cargo.lock
    (Rust)
  • composer.json
    ,
    composer.lock
    (PHP)
这些是Gilfoyle进行依赖漏洞扫描所需的内容。

Step 2: Run the Debate

步骤2:开展辩论

Initialize:
round = 0
,
debate_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:
  1. Dispatch Gilfoyle agent (Agent tool, general-purpose) with:
    • Full content of
      gilfoyle-agent.md
      from this skill's directory
    • 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."
  2. Display Gilfoyle's banter to the user.
  3. Check convergence: Parse Gilfoyle's FINDINGS section. If all findings are repeats from previous rounds → converge.
  4. Dispatch Dinesh agent (Agent tool, general-purpose) with:
    • Full content of
      dinesh-agent.md
      from this skill's directory
    • 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."
  5. Display Dinesh's banter to the user.
  6. Check convergence: Parse Dinesh's FINDINGS section. If every point is
    [concede]
    with zero
    [defend]
    or
    [dismiss]
    → converge.
  7. Append both responses to debate_history, increment round.
  8. 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 = 0
,
debate_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"];
}
每一轮:
  1. 调度 Gilfoyle Agent(Agent 工具,通用型),传入以下内容:
    • 本skill目录下
      gilfoyle-agent.md
      的完整内容
    • 待评审代码
    • 完整辩论历史
    • 轮次编号
    • 指令:「你仅负责调研 —— 阅读代码并给出评审意见。不要编辑任何文件。」
  2. 向用户展示 Gilfoyle 的斗嘴内容。
  3. 检查收敛: 解析Gilfoyle的FINDINGS部分。如果所有发现都是之前轮次的重复 → 收敛。
  4. 调度 Dinesh Agent(Agent 工具,通用型),传入以下内容:
    • 本skill目录下
      dinesh-agent.md
      的完整内容
    • 待评审代码
    • Gilfoyle最新的完整回复
    • 完整辩论历史
    • 轮次编号
    • 指令:「你仅负责调研 —— 阅读代码并给出辩护意见。不要编辑任何文件。」
  5. 向用户展示 Dinesh 的斗嘴内容。
  6. 检查收敛: 解析Dinesh的FINDINGS部分。如果每一点都是
    [concede]
    ,没有
    [defend]
    或
    [dismiss]
    → 收敛。
  7. 将两份回复追加到 debate_history,轮次加1。
  8. 如果轮次 >= 上限: 询问用户:「这俩能吵一整晚。要继续加轮次吗?(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
undefined

Dinesh 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]
  • file:line
    — issue — fix
[Issues where Dinesh couldn't mount a defense — these are real and need fixing]
  • file:line
    — issue — fix

Important (Gilfoyle won after debate)

Important (Gilfoyle won after debate)

[Issues Dinesh tried to defend but Gilfoyle's argument was stronger]
  • file:line
    — issue — fix
[Issues Dinesh tried to defend but Gilfoyle's argument was stronger]
  • file:line
    — issue — fix

Contested (Dinesh held his ground)

Contested (Dinesh held his ground)

[Issues where Dinesh's defense was valid — code is likely fine]
  • file:line
    — what was raised — why the defense holds
[Issues where Dinesh's defense was valid — code is likely fine]
  • file:line
    — what was raised — why the defense holds

Dismissed (Gilfoyle was nitpicking)

Dismissed (Gilfoyle was nitpicking)

[Issues both sides agree don't matter]
  • file:line
    — what was raised — why it's a non-issue
[Issues both sides agree don't matter]
  • file:line
    — what was raised — why it's a non-issue

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]
  • file:line
    — what to change
  • file:line
    — what to change
  • ...
If no changes needed: "Nothing to fix. Gilfoyle is furious."
undefined
[Clean checklist — no banter, no context, just what to do]
  • file:line
    — what to change
  • file:line
    — what to change
  • ...
If no changes needed: "Nothing to fix. Gilfoyle is furious."
undefined

Step 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
y
or
pr
, generate an HTML comic strip:
  1. Read the comic template from
    comic-template.html
    in this skill's directory.
  2. Fill in the template placeholders:
    • {{REVIEW_TARGET}}
      — the target reviewed (e.g., "UI Codebase", "git diff", file path)
    • {{ROUND_COUNT}}
      — number of debate rounds
    • {{GILFOYLE_SCORE}}
      /
      {{DINESH_SCORE}}
      — final scores
    • {{DATE}}
      — current date
    • {{PANELS}}
      — Generate 4-8 comic panels from the best banter exchanges. Each panel uses this HTML structure:
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}}
    — Generate verdict items from the final review:
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>
  1. 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
  2. Write the filled HTML to a timestamped file:
    /tmp/dg-comic-{timestamp}.html
If
y
:
5. Open it in the browser:
open /tmp/dg-comic-{timestamp}.html
6. Tell the user where the file is saved.
If
pr
:
5. Convert to PNG using a headless browser:
bash
# 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'
  1. Upload the image and comment on the PR:
    bash
    gh pr comment {PR_NUMBER} --body "$(cat <<'EOF'
    ## /dg Review Comic Strip
    
    ![Dinesh vs Gilfoyle](/tmp/dg-comic-{timestamp}.png)
    
    _Generated by [/dg](https://github.com/v1r3n/dinesh-gilfoyle)_
    EOF
    )"
    Note: If
    gh pr comment
    doesn't support local image upload, upload the image to the PR body as a drag-drop suggestion, or convert to base64 and embed.
  2. Tell the user the comment was posted with a link to the PR.
展示最终评审结果后,询问用户:
「想要精彩片段的连环漫画吗?(y/N/pr)」
  • y — 生成并在浏览器中打开
  • pr — 生成后转换为PNG,作为评论附加到当前PR
  • N — 跳过
如果选择
y
或
pr
,生成HTML连环漫画:
  1. 读取本skill目录下的
    comic-template.html
    漫画模板。
  2. 填充模板占位符:
    • {{REVIEW_TARGET}}
      — 评审目标(例如「UI代码库」、「git diff」、文件路径)
    • {{ROUND_COUNT}}
      — 辩论轮次数
    • {{GILFOYLE_SCORE}}
      /
      {{DINESH_SCORE}}
      — 最终得分
    • {{DATE}}
      — 当前日期
    • {{PANELS}}
      — 从最精彩的斗嘴对话中生成4-8个漫画面板。每个面板使用以下HTML结构:
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>
  1. 选择最佳片段制作面板。 优先级:
    • 最有趣的对话(一来一回的对话效果最好)
    • Gilfoyle 认输的时刻(罕见,有戏剧性)
    • Dinesh 最精彩的反击
    • 技术上最具杀伤力的台词
    • 保持引言简洁 —— 每个对话框删减到1-3句话
  2. 将填充后的HTML写入带时间戳的文件:
    /tmp/dg-comic-{timestamp}.html
如果选择
y
:
5. 在浏览器中打开:
open /tmp/dg-comic-{timestamp}.html
6. 告知用户文件保存位置。
如果选择
pr
:
5. 使用无头浏览器转换为PNG:
bash
# 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'
  1. 上传图片并在PR上评论:
    bash
    gh pr comment {PR_NUMBER} --body "$(cat <<'EOF'
    ## /dg Review Comic Strip
    
    ![Dinesh vs Gilfoyle](/tmp/dg-comic-{timestamp}.png)
    
    _Generated by [/dg](https://github.com/v1r3n/dinesh-gilfoyle)_
    EOF
    )"
    注意:如果
    gh pr comment
    不支持本地图片上传,将图片作为拖拽建议上传到PR正文,或转换为base64嵌入。
  2. 告知用户评论已发布,并提供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的猛攻下自圆其说,说明代码很可靠
  • 始终以可行动的总结收尾 —— 外表有趣,内核实用
  • 技术上必须正确 —— 只有技术内容真实可信,幽默才有意义