#2

feat: Add Claude Code subscription support via Claude Agent SDK

Openbigph00twants to merge intofrom

Summary

  • Adds support for running Ralph Loop Agent without an API key by using the official @anthropic-ai/claude-agent-sdk
  • The SDK spawns Claude Code as a subprocess, authenticating with the user's Claude Max subscription
  • Implements a new provider at ralph-loop-agent/providers/claude-code

Benefits

  • No API key required - Uses Claude Max subscription directly
  • Full Claude Code tools - Access to Bash, Read, Edit, Grep, Glob, etc.
  • Permission control - Auto-accept edits or prompt for approval
  • Cost tracking - See usage (covered by subscription, not billed separately)

Usage

import { runWithClaudeCode } from 'ralph-loop-agent/providers/claude-code';

const result = await runWithClaudeCode({
  prompt: 'Fix all TypeScript errors',
  maxTurns: 10,
  permissionMode: 'acceptEdits',
  
  verifyCompletion: ({ text }) => ({
    complete: text.includes('All errors fixed'),
  }),
  
  onTurnStart: ({ turn }) => console.log(`Turn ${turn}`),
});

console.log(`Completed: ${result.completionReason}`);
console.log(`Cost: $${result.cost} (covered by subscription)`);

Installation

npm install ralph-loop-agent @anthropic-ai/claude-agent-sdk
claude auth login  # Authenticate with Claude

Test plan

  • Install optional dependency @anthropic-ai/claude-agent-sdk
  • Run runWithClaudeCode() with a simple task
  • Verify turns, completion, and cost tracking work
  • Test permission modes (default, acceptEdits, bypassPermissions)

🤖 Generated with Claude Code