Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .claude/commands/list-claude-pr-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description: List Claude-authored PRs that haven't failed (ready or still running) with their actual check state
---

List open PRs authored by Claude (branches starting with `claude/`) that have **not** had any check fail. Show each PR's actual state (READY when all checks finished green, RUNNING when sweeps are still queued/in-progress) along with a per-status check breakdown.
List open PRs authored by Claude (branches starting with `claude/`) that have **not** had any check fail. Show each PR's actual state (READY when all checks finished green, RUNNING when sweeps are still queued/in-progress) along with a per-status check breakdown, rendered as a markdown table.

## Step 1 — list candidate `claude/*` PRs

Expand Down Expand Up @@ -49,13 +49,21 @@
done < /tmp/claude_pr_candidates.tsv
```

## Step 3 — present the result
## Step 3 — render markdown table

Sort READY first, then RUNNING. Render a markdown table with columns:
Print the result directly as a markdown table. READY rows first, then RUNNING. Each PR is a clickable link.

| PR | State | Check breakdown | Title |
|---|---|---|---|
```bash
{
printf '| PR | State | Check breakdown | Title |\n'
printf '|---|---|---|---|\n'
# READY first, then RUNNING; within each group keep input order (descending PR number from gh)
awk -F'\t' '$2 == "READY"' /tmp/claude_pr_status.tsv
awk -F'\t' '$2 == "RUNNING"' /tmp/claude_pr_status.tsv
} | awk -F'\t' 'NR<=2 {print; next}
{printf "| [#%s](https://github.com/SemiAnalysisAI/InferenceX/pull/%s) | %s | `%s` | %s |\n", $1, $1, $2, $3, $4}'
```

Check warning on line 65 in .claude/commands/list-claude-pr-status.md

View check run for this annotation

Claude / Claude Code Review

PR title containing pipe character breaks markdown table

PR titles containing a literal `|` will corrupt the rendered markdown table. The awk `printf` at line 64 interpolates the title field (`$4`) directly into a table cell with no escaping, so a title like `Fix foo | refactor bar` produces a row with extra column boundaries and a misaligned table. Easy fix: `gsub(/\|/, "\\|", $4)` inside the awk action before printing.
Comment on lines +64 to +65
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 PR titles containing a literal | will corrupt the rendered markdown table. The awk printf at line 64 interpolates the title field ($4) directly into a table cell with no escaping, so a title like Fix foo | refactor bar produces a row with extra column boundaries and a misaligned table. Easy fix: gsub(/\|/, "\\|", $4) inside the awk action before printing.

Extended reasoning...

What the bug is

In Step 3 (lines 55-66), the renderer pipes the TSV through awk and emits each data row with:

printf "| [#%s](https://github.com/SemiAnalysisAI/InferenceX/pull/%s) | %s | `%s` | %s |\n", $1, $1, $2, $3, $4

The title column ($4) is interpolated verbatim. GitHub PR titles are free-form user input coming from gh pr list --json title and can legitimately contain a literal | (e.g. frontend | use new API, Fix foo | refactor bar).

How it manifests

For a PR titled Fix foo | refactor bar, the emitted row is:

| [#123](https://github.com/SemiAnalysisAI/InferenceX/pull/123) | READY | `SUCCESS=44` | Fix foo | refactor bar |

Markdown parses pipes as column separators, so that row becomes 6 cells in a 4-column table and the row is misaligned in the rendered output.

Why existing code doesn't prevent it

The previous Step 3 was prose that delegated rendering to the assistant, which could escape pipes when constructing the table. This PR moves rendering into a deterministic bash/awk pipeline that emits raw field values. The check-breakdown column ($3) is wrapped in backticks which incidentally tolerates pipes inside it, but the title column has no such protection.

Step-by-step proof

  1. Author opens a PR on a claude/... branch with title Fix foo | refactor bar.
  2. Step 1 stores 123\tFix foo | refactor bar into /tmp/claude_pr_candidates.tsv.
  3. Step 2 classifies it as READY and appends 123\tREADY\tSUCCESS=44\tFix foo | refactor bar to /tmp/claude_pr_status.tsv.
  4. Step 3's awk reads that line with -F'\t', so $4 = "Fix foo | refactor bar".
  5. The printf emits | [#123](...) | READY | SUCCESS=44 | Fix foo | refactor bar |.
  6. The markdown renderer sees 6 |-delimited segments and produces a misaligned 6-cell row under a 4-column header.

Impact

Cosmetic / display-only. The link and information are still present and readable in raw form, and this is an informational developer slash command. Pipes in PR titles are uncommon — but not impossible — for Claude-authored PRs.

How to fix

Escape pipes in the title before printing, e.g.:

{ gsub(/\|/, "\\|", $4);
  printf "| [#%s](https://github.com/SemiAnalysisAI/InferenceX/pull/%s) | %s | `%s` | %s |\n", $1, $1, $2, $3, $4 }


Each PR cell should be a markdown link to `https://github.com/SemiAnalysisAI/InferenceX/pull/<number>`. The check breakdown column should show the per-state counts (e.g. `SUCCESS=44 SKIPPED=7 NEUTRAL=1` or `SUCCESS=9 QUEUED=34 IN_PROGRESS=14 SKIPPED=6 NEUTRAL=1`).
If `/tmp/claude_pr_status.tsv` is empty, print: `_No claude/* PRs are currently READY or RUNNING — all open Claude PRs have failures or no sweep results._`

Do **not** auto-merge. This command is informational only.
Output the resulting markdown table to the user verbatim. This command is informational only — do **not** auto-merge.