Skip to content

ci: Add Claude Code GitHub Workflow - #1

Merged
edenreich merged 3 commits into
mainfrom
add-claude-github-actions-1754791198022
Aug 10, 2025
Merged

edenreich merged 3 commits into
mainfrom
add-claude-github-actions-1754791198022

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

🤖 Installing Claude Code GitHub App

This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.

What is Claude Code?

Claude Code is an AI coding agent that can help with:

  • Bug fixes and improvements
  • Documentation updates
  • Implementing new features
  • Code reviews and suggestions
  • Writing tests
  • And more!

How it works

Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.
Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action.

Important Notes

  • This workflow won't take effect until this PR is merged
  • @claude mentions won't work until after the merge is complete
  • The workflow runs automatically whenever Claude is mentioned in PR or issue comments
  • Claude gets access to the entire PR or issue context including files, diffs, and previous comments

Security

  • Our Anthropic API key is securely stored as a GitHub Actions secret
  • Only users with write access to the repository can trigger the workflow
  • All Claude runs are stored in the GitHub Actions run history
  • Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits.
  • We can add more allowed tools by adding them to the workflow file like:
allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test)

There's more information in the Claude Code action repo.

After merging this PR, let's try mentioning @claude in a comment on any PR to get started!

@claude

claude Bot commented Aug 10, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @edenreich's task —— View job


PR Review: Claude Code GitHub Workflows

I've analyzed both workflow files and here's my comprehensive review:

Review Checklist

  • Read and analyze both workflow files
  • Review security practices and permissions
  • Check workflow triggers and configuration
  • Assess potential bugs or issues
  • Evaluate performance considerations
  • Provide comprehensive feedback

✅ Overall Assessment: APPROVED

The workflows are well-structured and follow GitHub Actions best practices. Here's my detailed analysis:

Security Review

🔒 Strong Security Practices:

  • Proper use of GitHub secrets for API tokens (.github/workflows/claude-code-review.yml:38, .github/workflows/claude.yml:37)
  • Minimal necessary permissions specified (both workflows define appropriate permissions blocks)
  • Uses id-token: write for secure authentication
  • No hardcoded secrets or sensitive data
  • Proper checkout with fetch-depth: 1 to limit data exposure

🛡️ Security Recommendations:

  • Consider adding repository_dispatch protection if needed for external triggers
  • The workflows correctly restrict to organization members through GitHub's built-in access controls

Code Quality & Best Practices

✅ Excellent Practices:

  • Uses latest GitHub Actions (actions/checkout@v4)
  • Clear, descriptive job and step names
  • Proper YAML structure and indentation
  • Comprehensive commented configuration options for future customization
  • Conditional execution logic is well-structured (.github/workflows/claude.yml:15-19)

📋 Workflow Logic Analysis:

claude-code-review.yml:

  • Trigger: Runs on PR open/sync - appropriate for automated reviews
  • Purpose: Automated code review without @claude mention
  • Configuration: Clean direct prompt for review criteria

claude.yml:

  • Trigger: Multiple event types with proper @claude detection
  • Conditional Logic: Robust conditional checks for different event types
  • Flexibility: Extensive configuration options (commented out appropriately)

Performance Considerations

⚡ Performance Strengths:

  • fetch-depth: 1 minimizes checkout time and resource usage
  • Conditional execution prevents unnecessary runs
  • Single job per workflow keeps resource usage efficient
  • Uses ubuntu-latest for optimal performance

📊 Resource Impact:

  • Minimal computational overhead
  • Network usage limited to necessary API calls
  • No heavy build processes or dependencies

Potential Issues & Recommendations

🟡 Minor Considerations:

  1. Workflow File Naming: Both files serve different purposes but could have more distinctive names:

    • claude-code-review.yml → Consider claude-auto-review.yml
    • claude.yml → Consider claude-interactive.yml
  2. Missing Error Handling: Consider adding failure handling strategies:

    - name: Run Claude Code Review
      continue-on-error: true  # Prevents blocking other workflows
  3. Rate Limiting: No explicit rate limiting configuration - consider if high-traffic scenarios could cause issues

🟢 Suggestions for Enhancement:

  • Consider using use_sticky_comment: true for the review workflow to avoid comment spam
  • The extensive commented examples are excellent for future customization

Test Coverage Assessment

❌ No Tests Present:

  • GitHub workflow files typically don't have traditional unit tests
  • Consider validating workflows with actionlint or similar tools in CI
  • Manual testing will be required post-merge

Security Concerns

✅ No Critical Security Issues Found:

  • Proper secret management
  • Appropriate permissions scope
  • No code injection vulnerabilities
  • Secure action references

Final Recommendations

  1. Ready to Merge: This PR implements Claude Code integration correctly and safely

  2. Post-Merge Actions:

    • Verify CLAUDE_CODE_OAUTH_TOKEN secret is properly configured
    • Test with a sample @claude mention to ensure workflows activate correctly
    • Monitor first few runs for any edge cases
  3. Future Enhancements: The commented configuration options provide excellent pathways for customization as needs evolve

Summary

This is a well-implemented addition that follows GitHub Actions best practices with strong security posture. The workflows are production-ready and will provide valuable AI assistance for the repository.


…actor requests; update Claude workflows for improved functionality and permissions

Signed-off-by: Eden Reich <[email protected]>
@edenreich
edenreich merged commit cde6c53 into main Aug 10, 2025
@edenreich
edenreich deleted the add-claude-github-actions-1754791198022 branch August 10, 2025 02:08
inference-gateway-releaser Bot pushed a commit that referenced this pull request Aug 10, 2025
## [0.1.1](v0.1.0...v0.1.1) (2025-08-10)

### 👷 CI/CD

* Add Claude Code GitHub Workflow ([#1](#1)) ([cde6c53](cde6c53))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Aug 10, 2025
edenreich added a commit that referenced this pull request Jun 8, 2026
## Summary

This branch began as a hardening of what the Bash tool auto-approves and
grew into a broader pass over **agent safety**, **headless
secure-by-default behaviour**, and a batch of **chat-TUI / diff-viewer
UX** improvements. The sections below cover everything that ships in
this PR.

> Note: the bash auto-approval vocabulary was reworked **within this
branch** from the old `whitelist` model into a per-mode
**allowed-list**. The descriptions below reflect the final shipped state
(`tools.bash.mode.<mode>.allow`, `INFER_TOOLS_BASH_ALLOW_APPEND`) — the
earlier `INFER_TOOLS_BASH_WHITELIST_COMMANDS*` names no longer exist.

---

## 1. Bash auto-approval: per-mode allowed-list (default-deny)

Reworks bash auto-approval into a single, config-driven, **per-mode
allowed-list**. A command auto-runs only if it matches the allowed-list
for the active agent mode; anything unmatched is denied — an approval
prompt in chat, a hard reject with an actionable hint in headless agent
mode. There is no separate deny list.

- **Per-mode config** —
`tools.bash.mode.{all,plan,standard,auto}.allow`. `mode.all` is the
every-mode baseline, unioned with the active mode's own list
(`bashAllowFor`). `mode.auto` defaults to the `.*` sentinel
(unrestricted); `mode.plan` / `mode.standard` add nothing and reduce to
the read-only baseline.
- **Full-command matching** — entries match `\A(?:entry)\z`, so a bare
token like `gh` allows only `gh` (never `gh issue list`); entries opt
into arguments explicitly (`gh issue.*`). The single `.*` sentinel means
*unrestricted* and skips the clean-command guard.
- **Single matcher** — `IsBashCommandAllowed(command, mode)` is shared
by the Bash tool gate, the approval policy, and agent auto-approval.
Mode flows in via `domain.WithAgentMode` context +
`AgentMode.AllowedlistKey()`.
- **Clean-command guard** (every non-`.*` mode) rejects, before
matching:
  - command substitution (`$(…)`, backticks, `<()`/`>()`),
- multi-command chains / pipelines (top-level `|`, `&&`, `||`, `;`, `&`,
newline — operators inside quotes don't count, so `jq '… | …'` stays a
single command). This closes the `echo x | xargs rm` prefix hole.
- a surviving file-write redirect (`>`/`>>`; benign `2>&1` /
`>/dev/null` are stripped first),
  - dangerous `find` actions (`-exec`/`-delete`/…),
- the **env-var leak guard**: a printing/publishing command
(`echo`/`printf`/`gh issue|pr create|comment|edit`) may not expand
`$VAR`, so `echo $AWS_SECRET_ACCESS_KEY` is blocked while `ls $DIR`
stays allowed (a single-quoted or escaped `$` is literal).
- **Hardened defaults** — the raw `gh api` GET wildcard is dropped; the
baseline now enumerates explicit non-destructive `gh` subcommands
(`issue|pr|repo|release|run|workflow list|view|…`, `gh search`, and
read-only `gh project list|view|item-list|field-list`). `gh project`
*writes* (`item-add`/`item-edit`), `git push`, and `git commit` are
**not** in the defaults and fall through to approval. A raw-`gh api`
need is opt-in per repo.
- **Append-only override** — `--tools-bash-allow-append` /
`INFER_TOOLS_BASH_ALLOW_APPEND` (comma/newline list, env wins over flag)
merges onto `mode.all.allow` after config load, so CI can add a few safe
commands (e.g. `git commit` / `git push`) without rewriting config or
shipping `.*`.
- **Model feedback** — each guard rejection returns an actionable hint
(`BashCommandRejectionHint`), and the effective per-mode allow-list is
injected into the system prompt (`buildBashAllowInfo`), rebuilt each
turn so a chat mode toggle re-injects it. The model is told not to retry
a denied command but to stop and ask, or use an allowed alternative.

## 2. Headless secure-by-default (`approval_behaviour`)

Headless `infer agent` previously defaulted to auto mode (`.*`), so CI,
heartbeat, and any run without `--require-approval` could execute
**any** command unattended. This makes the restricted path the default.

- New `tools.safety.approval_behaviour` (`prompt` | `ipc` | `block`,
default `prompt`) decides **how** a needed approval is delivered,
alongside the existing `require_approval` which decides **whether**.
`config.ResolveApprovalDelivery(behaviour, brokerAttached, isChat)` is
the single resolver; `Config.Validate` rejects unknown values.
- The headless executor now runs in **standard** mode and routes
approval-requiring tools per behaviour: **IPC** when a broker is
attached (`--require-approval`, e.g. the channel manager), otherwise
**blocked** with a reason. No more `.*` default — full autonomy is now
an explicit opt-in.
- Chat honours `block` (rejects without prompting); `prompt` / `ipc`
still prompt.
- **Auto-accept safety prompt** — `prompts.agent.system_prompt_auto`
carries a destructive-action policy (confirm/avoid irreversible ops:
delete, force-push, drop, `rm -rf`, publish) for auto-accept mode, wired
via `getSystemPromptForMode`; falls back to `system_prompt` when blank.
- **Controlled-autonomy CI profile**: `approval_behaviour: block` +
`tools.write.require_approval: false` + a curated bash allow-list / the
append override.

## 3. `BlockingTools` agent state for undeliverable approval

A new `StateBlockingTools` handles the case where a tool needs approval
but no approver is reachable (`approval_behaviour=block`, or `=ipc` with
no broker).

- Entered from `EvaluatingTools` when approval is required **and**
undeliverable for all gated tools in the batch.
- Walks the batch in order: non-gated tools (read-only, allow-listed
Bash) still execute; gated tools are rejected with an actionable reason
telling the model not to retry but to explain what it needs. Results are
appended in conversation order, mirroring the `ApprovingTools` contract.
- Emits a terminal tool-progress event so the live streaming overlay
clears instead of lingering, then transitions to `PostToolExecution`.

## 4. Tool-execution stop routed through the event loop (fix)

The `executeTools` goroutine transitioned to `StateStopped` directly,
but `ExecutingTools → Stopped` was never registered and the goroutine
emitted no event, so `processEvents` never woke to observe the terminal
state — the loop hung until session cancel (reachable via a rejected
tool result or a successful `RequestPlanApproval`).

- `executeTools` now only emits `ToolsCompletedEvent{Stop}`; the
`ExecutingTools` state owns the transition (`Stop → Stopped`). Registers
`ExecutingTools → Stopped` as the single needed from-state.
- `Completing` now explicitly consumes `CompletionRequestedEvent` rather
than finalizing on any event.
- State journey is now debuggable: the transition chokepoint log is
bumped to Info (file-only) and a Debug `dispatching event` line carries
event + state + request_id.

## 5. Tool approval UX: diff preview

When approval is required for file-mutating tools (**Edit / MultiEdit /
Write**), the approval box now renders a **colored, syntax-aware diff
preview** (file path + old/new content, plus a "replace all occurrences"
note for `replace_all`) instead of the compact one-liner. The preview is
height-capped (≈ half the terminal, bounded 6–30 lines) with a dim "… N
more lines (full diff shown after approval)" hint when truncated. All
other tools keep the compact `Name(arg=value, …)` summary.

## 6. Agent skills enabled by default

`AgentSkillsConfig.Enabled` now defaults to `true`, so skills are
discovered and injected into the system prompt out of the box. CLI help
text, tests, and the seeded `config.yaml` are updated accordingly.

---

## Chat-TUI / diff-viewer / git-staging UX

- **Patch line selection + hunk split** — in the diff viewer you can
select a line range within a hunk and stage/unstage only those lines
(default: `space`/`v` to anchor a selection, navigate, apply with the
stage/unstage keys), and split a multi-change hunk into independent
blocks (`s`) so each can be staged separately. The hint text reflects
whether a selection is active.
- **Stage all / unstage all** — stage every change at once (default `A`
→ `git add -A`, incl. untracked & deletions) or unstage everything
(default `U` → `git reset -q HEAD`), from anywhere in the panel.
- **Staged-file hint** — the footer hides the `discard` option when a
staged file is selected, since discard only applies to unstaged changes.
- **Removed file-type emoji icons** from the diff renderer; file paths
render plain.
- **Clipboard status flashes** — copy/paste now show brief
auto-dismissing status messages ("Copied to clipboard", "Text pasted
from clipboard", "Image pasted from clipboard") that preserve any active
loading spinner.
- **Image placeholder fix** — attachments are labeled `[Image 1]`
instead of `[Image #1]`, so the `#` is no longer parsed as a Markdown
heading.
- **Unified `/model` command** — `/model <name>` permanently switches
the active model (replaces `/switch`), while `/model <name> <prompt…>`
runs a single message with that model and restores the session model
afterward. `/switch` is deprecated.
- **Autocomplete no longer auto-executes** — `Tab` always completes the
suggestion (fills input + trailing space, never submits); `Enter`
submits the current input. Prevents accidental command execution on
selection.
- **Theme-aware editor background** — the embedded vim/pty editor
launches with `set background=dark|light` (and `syntax enable`) matched
to the active TUI theme, so editor colors aren't washed out.
- **Bash streaming output coalescing** — the Bash tool now buffers
streamed output and flushes at most every ~50 ms or per ~64 KB, so
high-volume commands (large `git diff`, logs) no longer flood the TUI
with per-line update cycles. Captured output is unaffected.

## Internal cleanup

- Removed 21 never-used chat/agent event types and their orphaned
publish sites (4 of which were broadcast to the Go→Swift bridge with no
Go consumer and dropped as "ambiguous", which also removes
per-transition log noise to the floating window). State-transition
observability is retained via the adjacent `logger.Debug`.
*(internal-only refactor — no docs ticket.)*
- Lowercased remaining logging statements for consistency; check the
scanner error after agent output; consistent named imports for
third-party libraries.

---

## Breaking changes / migration

- **`tools.bash.whitelist.commands` is removed.** Configure
`tools.bash.mode.<mode>.allow` instead. The
`INFER_TOOLS_BASH_WHITELIST_COMMANDS[_APPEND]` env vars and
`--tools-bash-whitelist-commands*` flags are gone; use
`INFER_TOOLS_BASH_ALLOW_APPEND` / `--tools-bash-allow-append` (append
onto the `mode.all` baseline).
- **Headless `infer agent` no longer auto-approves everything.** It runs
in standard mode; off-list / mutating actions are blocked in
CI/heartbeat and sent for IPC approval under a channel manager. Restore
full autonomy explicitly via a curated allow-list, the append override,
or `mode.auto`/`.*`.
- **Compound/piped commands and `echo $VAR` no longer auto-approve** —
they now require approval. Re-add specific safe commands via the append
override.
- **Agent skills are now on by default** (`agent.skills.enabled: true`).

## Verification

`go test ./...`, `golangci-lint run`, `gofmt`, and `markdownlint` all
pass. Seeded config files were regenerated (`go run . init --overwrite`)
with user-curated files (`agents.yaml`, etc.) restored.

## Docs follow-up (`inference-gateway/docs`)

Public-surface changes that warrant a `[DOCS]` issue: the per-mode bash
allowed-list (`tools.bash.mode.<mode>.allow`) +
`INFER_TOOLS_BASH_ALLOW_APPEND`, `tools.safety.approval_behaviour` and
the controlled-autonomy CI profile, agent skills now default-on, the
unified `/model` command, and the new diff-viewer keybindings (patch
line selection, hunk split, stage/unstage all). Internal refactors
(dead-event removal, stop-routing fix) need no docs ticket.
edenreich added a commit that referenced this pull request Jun 30, 2026
Render background shells and subagents as first-class rows in /tasks
alongside A2A tasks - three per-kind tables (A2A Tasks / Background Shells /
Subagents) sourced from the supervisor Snapshot, each retaining the last 5
terminal entries by default.

- Supervisor: count-based per-kind terminal retention, evicting the oldest
  over-cap terminal jobs on finish with their Close teardown run outside the
  lock; unbounded when unset.
- Config: tools.bash.background_shells.completed_retention and
  tools.agent.completed_retention knobs (default 5); wired into the supervisor
  in the container.
- /tasks view: kind-grouped section walk over the existing flat selection;
  Completed tab includes Failed; fix Cancelled->Canceled spelling; cancel
  restricted to active A2A tasks.

Implements TODO #1 and #2 of #684.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant