Skip to content

chore(release): suggest version via claude -p instead of an Anthropic API key - #1299

Closed
dangrondahl wants to merge 1 commit into
mainfrom
release-script-claude-cli
Closed

dangrondahl wants to merge 1 commit into
mainfrom
release-script-claude-cli

Conversation

@dangrondahl

@dangrondahl dangrondahl commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

💊 Blue pill. One of two alternative PRs that remove the shared Anthropic API key from the release flow. Only one should merge; the other is the red pill, #1300.

bin/suggest-version-ai.sh now calls the Claude Code CLI (claude -p) under the releaser's own Claude login, instead of calling the Messages API with a key from 1Password (or ANTHROPIC_API_KEY). make release behaves as before: same prompt, same parsing, same $EDITOR step and confirmation.

  • The call runs from an empty temp dir with all tools disabled, so it stays a plain diff-in, text-out request and doesn't pick up the repo's CLAUDE.md or MCP servers.
  • The curl checks are gone from the Makefile; the release guide now lists jq and a logged-in Claude Code CLI as prerequisites.
  • After merge, the op://Shared/Anthropic API Key item can be deleted if nothing else uses it.

Choose this if you want make release to stay a fixed, scripted flow.

Tested locally (writing to a scratch dir, no tag created): since v2.48.2 it suggested a patch with "No user-facing CLI changes" (correct, only CI changed); since v2.48.0 it suggested a minor with a changelog under three headings. claude missing and an invalid model both exit 1 and leave no stale output files.

Checklist

  • Docs are autogenerated from CLI help — make sure the help text reflects your changes (n/a: no CLI changes)
  • Helm chart (charts/k8s-reporter/) updated, if needed (n/a)
  • Terraform provider and related changes updated, if needed (n/a)

… API key

The release version/changelog suggestion now runs through the Claude Code
CLI under the releaser's own Claude login, removing the shared API key in
1Password and the ANTHROPIC_API_KEY fallback. The call runs from an empty
temp dir with all tools disabled, so it stays a plain diff-in, text-out
request.
@github-actions github-actions Bot added documentation Improvements or additions to documentation chore labels Oct 24, 2026
@claude

claude Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @dangrondahl's task in 1m 22s —— View job


PR review: claude -p instead of the shared API key

  • Static checks (go build, go vet, go mod tidy)
  • Review the diff (Makefile, bin/suggest-version-ai.sh, release-guide.md)
  • Post inline comments

Static checks: go build ./..., go vet ./... and go mod tidy all pass, and go.mod/go.sum are unchanged. The PR has no Go changes.

Findings

  1. The temp dir isn't deleted after a successful run (bin/suggest-version-ai.sh:92). The trap - EXIT at the end of the script clears the trap that removes $WORK_DIR. Each successful make release leaves /tmp/tmp.XXXX/input behind, holding the prompt and up to 50 KB of the diff. The old DIFF_FILE leaked the same way, so this isn't new. The fix is one line: rm -rf "$WORK_DIR" right after the claude -p call.
  2. Nit: isolation is partial (bin/suggest-version-ai.sh:97-104). Running from an empty cwd keeps out the repo's CLAUDE.md and MCP servers. The releaser's user-level ~/.claude/CLAUDE.md, hooks and plugins still load, and they could change the output format. --setting-sources "", or --bare if the CLI version supports it, would make the call fully deterministic. Not a blocker: the parser falls back to patch, and the $EDITOR step lets the releaser fix odd output.

What's good

  • Removing the shared secret is a real security gain: no 1Password item to rotate, and usage is tied to each releaser's own account.
  • --tools "" plus an empty cwd keeps the call a plain diff-in, text-out request, and the comment explains why.
  • Errors are handled more robustly. select(.is_error == false) and the || true guards make a missing CLI, an auth failure or a bad model end in a clean exit 1, and the trap still clears stale output files.
  • The claude existence check gives an actionable message that points to the make release tag=vX.Y.Z fallback.
  • The Makefile, script header and release guide are updated together; dropping the curl check is correct.

Summary

The PR is small and clean, and it's ready to merge once the temp dir cleanup (finding 1) is fixed. Finding 2 is optional hardening.

Comment thread bin/suggest-version-ai.sh
Comment on lines +97 to +104
RESPONSE=$(cd "$WORK_DIR" && claude -p \
--model "$CLAUDE_MODEL" \
--tools "" \
--output-format json \
--no-session-persistence \
--strict-mcp-config \
--disable-slash-commands \
< input) || true

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.

Nit on isolation: the empty cwd keeps out the repo's CLAUDE.md and .mcp.json. The releaser's user-level config still loads, though: ~/.claude/CLAUDE.md, user hooks such as SessionStart/Stop, and plugins. A personal "always answer in X style" memory, or a hook that prints to stdout, could bend the output away from the BUMP: / ---CHANGELOG--- format. If you want the call fully deterministic, look at --setting-sources "", or --bare if your Claude Code version supports it. Also consider --append-system-prompt/--system-prompt to pin the format. Not a blocker: the parser already falls back to patch, and the $EDITOR step catches any odd output.

Comment thread bin/suggest-version-ai.sh
# The response may start with a thinking block, so join all text blocks instead of reading content[0].
CONTENT=$(echo "$RESPONSE" | jq -r '[.content[]? | select(.type == "text") | .text] | join("\n")')
WORK_DIR=$(mktemp -d)
trap 'rm -rf "$WORK_DIR"; rm -f "$RELEASE_NOTES_FILE" "$SUGGESTED_VERSION_FILE"' EXIT

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.

Temp dir leaks on success. The trap - EXIT near the end of the script (line 158) clears this trap, so rm -rf "$WORK_DIR" only runs on failure. Every successful make release leaves a /tmp/tmp.XXXX/input holding the prompt and up to 50 KB of the diff. The old DIFF_FILE leaked the same way, so this isn't new, but it's a one-line fix. Add rm -rf "$WORK_DIR" just before the final trap - EXIT, or clean it up right after the claude -p call since nothing reads it afterwards:

RESPONSE=$(cd "$WORK_DIR" && claude -p ... < input) || true
rm -rf "$WORK_DIR"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant