Skip to content

fix: address jq escaping and Step 5 dismissal ordering in CI skills - #1241

Merged
max-sixty merged 4 commits into
mainfrom
nightly/review-22537310327
Mar 1, 2026
Merged

max-sixty merged 4 commits into
mainfrom
nightly/review-22537310327

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Summary

Closes #1239
Closes #1240

Test plan

  • Verify running-in-ci SKILL.md renders correctly
  • Verify pr-review SKILL.md Step 5 instructions are clear

🤖 Generated with Claude Code

1. Add jq `!=` escaping warning to running-in-ci skill. Despite the
   pre-flight template fix in #1152, Claude still generates `!=` in
   ad-hoc jq queries during CI polling — 4 of 6 review sessions in the
   past 24 hours hit this bug. The new guidance tells Claude to use
   `| not` instead of `!=` in all jq expressions.

2. Swap Step 5 dismissal ordering in pr-review. Previously: dismiss
   approval first, then post analysis. If the session times out between
   these, the PR author gets a bare dismissal with no context (happened
   on PR #1238, run 22536752559). Now: post analysis first, dismiss
   second — the safer ordering.

Closes #1239
Closes #1240

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comment thread .claude/skills/running-in-ci/SKILL.md Outdated
)"
```

3. **`!=` in jq expressions** — `jq 'select(.x != "y")'` breaks because `!`

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

can we instead suggest the heredoc approach, or whatever approach allows for ! to work OK?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good call — updated to suggest storing the filter in a variable instead:

filter='select(.status != "COMPLETED")'
gh api ... --jq "$filter"

Single-quoted assignment is safe from history expansion, and this keeps the natural != syntax.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

does a heredoc work here? or no?

test it out yourself. my concern is that filter='select(.status != "COMPLETED")' doesn't actually help

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Tested it — you're right, the variable approach doesn't reliably help. The ! gets escaped to \! at the tool level before bash even processes the command, so moving it into a variable doesn't change anything.

The heredoc approach does work consistently:

jq_filter=$(cat <<'EOF'
select(.status != "COMPLETED")
EOF
)
gh api ... --jq "$jq_filter"

Updated the guidance to use heredocs instead of variables in 4f733f1.

Store jq filters in a variable to sidestep bash history expansion,
keeping the natural != syntax rather than requiring an alternate
jq idiom.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The general rule on line 142 now has a third valid approach (the variable technique from item 3) that it doesn't mention — could confuse the LLM about which pattern to use.

Comment thread .claude/skills/running-in-ci/SKILL.md Resolved
Testing confirmed max-sixty's concern: the variable approach
(`filter='select(.status != "COMPLETED")'`) doesn't reliably prevent
`!` escaping — the escaping happens at the tool level before bash
processes the command. The heredoc approach (`<<'EOF'`) works
consistently because the content is treated as a literal string.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner

can we do a pass and simplify? maybe just "always write commands containing ! to a file before exciutijg the file", or similar?

Collapses three enumerated failure modes into a single rule: "write it
to a file or heredoc first." One example for $, one for ! — covers all
cases without the repetition.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Simplified — collapsed the three enumerated cases into one rule ("write it to a file or heredoc first") with two examples: one for $, one for !. Went from 45 lines to 19.

@max-sixty

Copy link
Copy Markdown
Owner

does it work to write the file with a heredoc? or does the file need to be written with the FileEdit tool to avoid the ! escaping problem? make sure we test this, thx

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Tested — heredocs with quoted delimiters (<< 'EOF') work fine. Both $ and ! pass through literally with no escaping needed:

# File write — works
cat > /tmp/test.txt << 'EOF'
select(.status != "COMPLETED")
query($owner: String!, $repo: String!)
EOF

# Variable capture — works
jq_filter=$(cat <<'EOF'
select(.status != "COMPLETED")
EOF
)

The key is the quoted delimiter ('EOF' not EOF). Quoting the delimiter disables all shell expansion inside the heredoc — $, !, backticks all stay literal. This is standard bash behavior and doesn't depend on the Claude Code Bash tool doing anything special.

The Write/Edit tools would also work (they bypass the shell entirely), but the heredoc approach is sufficient and keeps the guidance self-contained within bash — no need to mix tool types.

@max-sixty
max-sixty merged commit e79332c into main Mar 1, 2026
21 checks passed
@max-sixty
max-sixty deleted the nightly/review-22537310327 branch March 1, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants