Skip to content

fix(ce-pr-description): hand off PR body via temp file#581

Merged
tmchow merged 4 commits intomainfrom
tmchow/pr-desc-tempfile
Apr 17, 2026
Merged

fix(ce-pr-description): hand off PR body via temp file#581
tmchow merged 4 commits intomainfrom
tmchow/pr-desc-tempfile

Conversation

@tmchow
Copy link
Copy Markdown
Collaborator

@tmchow tmchow commented Apr 17, 2026

Summary

Generating a PR description used to tokenize the body twice: once as the skill's returned text, then again when the caller heredoc'd it into gh pr create/edit. On large PRs that compounds. Now the skill writes the body to an OS temp file and the caller reads it back with $(cat "$BODY_FILE"). Body tokenized once, caller's tool input shrinks to just the path.

Reviewing that commit surfaced a second problem: the new Step 9 grew three bullets of design archaeology (why mktemp -u, why not EOF, why not the Write tool). Every line of SKILL.md loads on every invocation, so that archaeology carries forward forever. A new AGENTS.md rule, Rationale Discipline, formalizes the principle that drove the cuts so future skill authoring has the guardrail.

What changed

  • ce-pr-description contract moved from {title, body} to {title, body_file}. Step 9 writes the composed body via mktemp -u + heredoc and prints the path. mktemp -u sidesteps Claude Code's Write sandbox (which can't touch /tmp and refuses to overwrite unread files). The quoted heredoc sentinel keeps $VAR, backticks, and literal EOF in the body from clashing with the terminator. OS reaps /tmp on its own, so no cleanup.

  • git-commit-push-pr callers read the body from the returned path. DU-3 (description-only) and Step 7 (full flow, both new and existing PR) substitute with $(cat "$BODY_FILE") inside gh pr create/edit. DU-3's compare-and-confirm note explicitly says not to cat the file when summarizing differences: the body is already in context from the bash call that wrote it.

  • New AGENTS.md authoring exception for value-producing preparatory commands (VAR=$(cmd1) && cmd2 "$VAR"). The "no action chaining" rule used to block this pattern. The new exception permits it when cmd2 strictly consumes cmd1's output and splitting would force manually threading the value through model context across two bash calls.

  • New AGENTS.md Rationale Discipline rule. Include rationale only when it changes what the agent does at runtime: if behavior wouldn't differ without the sentence, cut it. Keep rationale at the highest-level location that covers it; restate behavioral directives at the point they take effect (long skills drift if constraints sit at line 9 while the agent executes line 400). Portability notes, defenses against mistakes the agent wasn't going to make, and meta-commentary about repo authoring rules belong in commit messages or docs/solutions/, not in the skill body.

  • Concrete cuts applying the rule. Step 9's three bullets of design notes lost two (kept one load-bearing line on sentinel semantics). A cross-reference to the new AGENTS.md exception got cut as pure meta-commentary. The "avoid double-tokenize" rationale, repeated across 4+ locations in the two skills, collapsed to one mention in the ce-pr-description frontmatter.

Why these ship together

The Rationale Discipline rule was written in direct response to reviewing the first commit's Step 9; the cuts it demands ARE the first application. Splitting would mean either committing a rule with no evidence it matters or committing cuts with no explanation of the principle. Together they carry the full compound arc: refactor, then lesson caught on review.


Compound Engineering
Claude_Code

tmchow and others added 2 commits April 16, 2026 22:06
… temp file

Change ce-pr-description's output contract from {title, body} to
{title, body_file}. The body is written to an OS temp file via
mktemp + heredoc and the caller substitutes it back with
"$(cat "$body_file")". This avoids emitting the body text twice
(once as the skill's output, again when the caller formats the
gh pr command), which was wasteful on large PR descriptions.

Also add a narrow AGENTS.md exception for value-producing
preparatory commands (VAR=$(cmd1) && cmd2 "$VAR"), so the skill
can use the natural mktemp + heredoc pattern without manually
threading the path across two bash calls.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add a Rationale Discipline subsection to the plugin AGENTS.md
skill compliance checklist. The rule: every line in SKILL.md
loads on every invocation, so rationale earns its space only
when it changes what the agent does at runtime. Keep rationale
at the highest-level location that covers it; restate behavioral
directives at the point they take effect so long skills don't
drift by line 400. Portability notes, defenses against mistakes
the agent wouldn't make, and meta-commentary about repo rules
go in commit messages or docs/solutions/, not the skill body.

Apply the rule to ce-pr-description and git-commit-push-pr:
Step 9 shed three bullets of archaeology (why mktemp -u, sentinel
choice, why not Write), the AGENTS.md cross-reference, and the
double-tokenize rationale repeated across four locations.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ba5ef3b86

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/compound-engineering/skills/ce-pr-description/SKILL.md Outdated
Address PR review feedback (#581)

- `mktemp -u -t ce-pr-body` fails on GNU mktemp (Linux/Codex) with
  "too few X's in template". Switch to bare-template form
  `mktemp -u "${TMPDIR:-/tmp}/ce-pr-body.XXXXXX"`, which works
  cleanly on both BSD (macOS) and GNU (Linux) mktemp.
@tmchow tmchow changed the title refactor: hand off PR body via temp file; add rationale discipline rule fix(ce-pr-description): hand off PR body via temp file Apr 17, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ee9b1312e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/compound-engineering/skills/ce-pr-description/SKILL.md Outdated
Comment thread plugins/compound-engineering/skills/ce-pr-description/SKILL.md Outdated
…rite

Address PR review feedback (#581)

- Drop `mktemp -u`: the -u flag only prints a candidate path without
  creating the file, which is a TOCTOU race — another process can
  create or symlink that path before `cat > "$BODY_FILE"` runs. Using
  `mktemp` without -u creates the file atomically with mode 0600,
  so the heredoc writes into a path this process already owns.
- Chain `echo "$BODY_FILE"` behind the heredoc write with `&&`. The
  previous layout ran echo on the next line regardless of whether
  `mktemp` or the heredoc succeeded, so a failure would surface a
  path to a missing/partial file and break the caller later in
  `gh pr create/edit`. Chaining propagates the failure cleanly.
@tmchow tmchow merged commit c89f18a into main Apr 17, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant