Skip to content

feat(git): Add Claude as a TextGenerationProvider#1323

Open
keyzou wants to merge 9 commits intopingdotgg:mainfrom
keyzou:feat/claude-text-generation
Open

feat(git): Add Claude as a TextGenerationProvider#1323
keyzou wants to merge 9 commits intopingdotgg:mainfrom
keyzou:feat/claude-text-generation

Conversation

@keyzou
Copy link

@keyzou keyzou commented Mar 23, 2026

What Changed

  • Added Claude as an alternate provider for git operations
  • Added a dropdown in the settings to choose a provider for Git operations.
  • Default provider is Claude Haiku 4.5 (changeable), reasoning low (unchangeable)
  • Tried to keep the feature parity with Codex for git operations, hope I didn't miss anything

I suggest reviewing commit-by-commit :)

I'm also not too familiar with Effect, so there might be some AI slop here and there, don't hesitate to flag it

⚠️ I'm also proposing an optional last commit (c6c833e) to refactor both providers to extract the prompt building logic into shared utilities. This is fairly opinionated, and we should probably discuss this, so I'm totally down to just drop that commit; we might want to tweak the prompts for a specific provider in the future

⚠️ I also couldn't test for regression on the Codex side, so I'll ask for one of you to make sure this all works correctly (tests are passing, I added a few for Claude, but maybe some bug went through, especially with the refactor)

I saw a similar PR at #1222 but since the change was not enough, I wanted to take a stab at the issue myself (not sure about the proper open-source etiquette here though)

Fixes #1221

Why

Pretty straightforward: I don't have Codex, so Git-related operations couldn't work for me :)

UI Changes

Here's the setting page with the Git section using Claude:

Enregistrement.de.l.ecran.2026-03-23.a.19.37.28.mov

Here's a demo of the branch name generation working (not sure I have the right flow) -- old model picker, see the video above for the updated version ^:

Enregistrement.de.l.ecran.2026-03-23.a.02.17.41.mp4

And here's a demo of committing and pushing (thus generating a commit message) -- old model picker, see the video above for the updated version:

Enregistrement.de.l.ecran.2026-03-23.a.02.15.14.mp4

Checklist

  • This PR is small and focused (not that small actually)
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Add Claude as a selectable text generation provider for git actions

  • Adds a new ClaudeTextGenerationLive layer in ClaudeTextGeneration.ts that spawns the claude CLI with JSON-structured output and a 180s timeout to generate commit messages, PR content, and branch names.
  • Adds a RoutingTextGenerationLive layer that dispatches text generation to Codex or Claude based on a provider field ('codex' | 'claudeAgent') on each request.
  • Extracts shared prompt builders and utilities into textGenerationPrompts.ts and textGenerationUtils.ts; refactors CodexTextGeneration to use them.
  • Exposes a textGenerationProvider setting in app settings (defaulting to 'codex') and updates the settings UI with a provider+model picker; the chosen provider is forwarded through the runStackedAction API call.
  • Behavioral Change: The server now provides RoutingTextGenerationLive instead of CodexTextGenerationLive, meaning all text generation requests go through the router; existing behavior is preserved when provider is unset (defaults to Codex).

Macroscope summarized c9d1242.

keyzou and others added 7 commits March 23, 2026 01:24
Move limitSection, sanitizeCommitSubject, and sanitizePrTitle into a
dedicated textGenerationUtils module so they can be reused by multiple
text generation providers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the single DEFAULT_GIT_TEXT_GENERATION_MODEL constant with a
DEFAULT_GIT_TEXT_GENERATION_MODEL_BY_PROVIDER map keyed by provider kind,
enabling per-provider default models. Update all consumers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nterfaces

Introduce a standalone TextGenerationProvider union type and add an
optional provider field to all text generation input interfaces, allowing
callers to select which backend generates the content.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add ClaudeTextGeneration layer that spawns `claude -p` with structured
JSON output for commit messages, PR content, and branch names. Introduce
a RoutingTextGeneration layer that dispatches to Codex or Claude based
on the provider field, and wire it into the server DI graph. Thread the
provider selection through GitManager to all text generation call sites.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a provider selector (Codex/Claude) to the git settings panel with
dynamic model options per provider. Pass the selected provider through
to the stacked action mutation. Also fix a pre-existing bug where the
model field name was incorrect in the RPC call.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Match the pattern already used by Codex (CODEX_REASONING_EFFORT)
to make the setting visible and easy to change.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract prompt construction logic into buildCommitMessagePrompt, buildPrContentPrompt, and buildBranchNamePrompt in new textGenerationPrompts.ts
- Replace duplicate normalizeClaudeError and normalizeCodexError with shared normalizeCliError function parameterized by CLI name
- Update Claude and Codex text generation layers to use shared utilities, reducing duplication
- Add comprehensive tests for prompt builders and error normalization
@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7b38c34a-28a5-4d8a-a1b4-4fb96259a3be

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions bot added size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 23, 2026
@juliusmarminge
Copy link
Member

can we reuse the model picker from the chat UI? So it's a single select with provider top level, model submenu?

- Consolidate provider and model selection into reusable component
- Replace getAppModelOptions with getCustomModelOptionsByProvider
- Simplifies settings UI and enables reuse across the app
@keyzou
Copy link
Author

keyzou commented Mar 23, 2026

yep, didn't think about that, what do you think ? (updated the screenshot in the PR aswell)

Enregistrement.de.l.ecran.2026-03-23.a.19.37.28.mov

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

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Allow Claude to generate commit messages

2 participants