Skip to content

fix(ci): replace envsubst with node for prompt templating#1238

Merged
glottologist merged 2 commits intomasterfrom
jason/fix-extraction
Mar 23, 2026
Merged

fix(ci): replace envsubst with node for prompt templating#1238
glottologist merged 2 commits intomasterfrom
jason/fix-extraction

Conversation

@glottologist
Copy link
Contributor

@glottologist glottologist commented Mar 23, 2026

Describe the changes
A clear and concise description of what the bug fix, feature, or improvement is.

Related Issue(s)
Please link to the issue(s) that will be closed with this PR.

Checklist

  • Tests have been added/updated for the changes.
  • Documentation has been updated for the changes (if applicable).
  • The code follows Rust's style guidelines.

Additional Context
Add any other context about the pull request here.

Summary by CodeRabbit

  • Chores
    • Streamlined the design extraction workflow by changing prompt construction to in-memory generation and direct streaming, removing the temporary file and intermediate substitution step. Preserves existing invocation behavior while improving robustness and reducing process complexity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

Replaces a shell heredoc + envsubst that wrote /tmp/ci-prompt.md with a Node.js heredoc using a JavaScript template string that interpolates environment variables and streams the prompt to Claude via stdout, removing the intermediate file and changing prompt construction flow.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
.github/workflows/design-extraction.yml
Replaced shell heredoc + envsubst + temporary /tmp/ci-prompt.md file with a Node.js heredoc that builds the Claude prompt via a JS template string (interpolating process.env.DESIGN_PLAN, process.env.PR_COMMENTS, PR number/title) and streams it to Claude through process.stdout.write(). Claude invocation flags remain unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Runner as "GitHub Actions Runner"
  participant Node as "Node.js script (heredoc)"
  participant Claude as "Claude CLI/API"

  Runner->>Node: spawn Node heredoc script (with env)
  Node->>Node: build prompt using JS template (interpolate env vars)
  Node->>Claude: stream prompt via stdout to Claude CLI
  Claude-->>Node: return response/output
  Node-->>Runner: exit with streamed output
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • ci(design): extract design documents #1212: Modifies the same .github/workflows/design-extraction.yml workflow and replaces the previous envsubst/temp-file prompt-generation with a Node-based templating/streaming approach.

Suggested reviewers

  • JesseTheRobot
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: replacing envsubst with Node for prompt templating in the CI workflow, which matches the primary modification in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jason/fix-extraction

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/design-extraction.yml:
- Around line 200-220: The pipeline step that runs the heredoc piped into the
claude invocation (the `node <<'NODE_EOF' | npx claude` pipeline) can hide
failures from earlier commands; enable Bash pipefail so the step fails if `node`
or `npx claude` fails by setting the shell to use pipefail (e.g., set `shell:
bash -eo pipefail {0}` at the GitHub Actions step or add `set -o pipefail`
before the pipeline) so the heredoc/pipeline exit status is correctly
propagated.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: facc8762-0292-4d49-bf35-84f5300651e9

📥 Commits

Reviewing files that changed from the base of the PR and between 9725fe9 and 9d6e2e6.

📒 Files selected for processing (1)
  • .github/workflows/design-extraction.yml

@github-actions
Copy link
Contributor

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/design-extraction.yml:
- Around line 204-214: The prompt construction interpolates unescaped PR content
into the const prompt using process.env.DESIGN_PLAN and process.env.PR_COMMENTS
inside the <design_plan> and <pr_comments> tags, allowing those values to
prematurely close the tags; fix this by sanitizing or encoding those environment
values before interpolation (e.g., escape "</design_plan>" and "</pr_comments>"
or JSON.stringify/base64-encode the values) so the text cannot break out of the
tag blocks, and update the prompt assembly where the variable prompt is defined
to use the sanitized versions of process.env.DESIGN_PLAN and
process.env.PR_COMMENTS.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 47721cf6-5984-4cc9-bd42-31bfb1fe4ad0

📥 Commits

Reviewing files that changed from the base of the PR and between 9d6e2e6 and 059e08d.

📒 Files selected for processing (1)
  • .github/workflows/design-extraction.yml

@glottologist glottologist merged commit 6044ecc into master Mar 23, 2026
22 checks passed
@glottologist glottologist deleted the jason/fix-extraction branch March 23, 2026 10:53
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