定制 woda/laravel-ralph 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

woda/laravel-ralph

Composer 安装命令:

composer require woda/laravel-ralph

包简介

Claude Code agent loop runner for Laravel

README 文档

README

Claude Code agent loop runner for Laravel. Runs Claude CLI iteratively in a GNU screen session, tracking progress, detecting completion, and logging everything.

Requirements

  • PHP 8.2+
  • Laravel 11 or 12
  • Node.js
  • Claude CLI (claude in PATH)
  • GNU screen (not needed with --once)

Installation

composer require woda/laravel-ralph

Setup

php artisan ralph:init

Configures .claude/settings.json with sandbox permissions so Claude doesn't hang waiting for bash approval.

Usage

# Interactive — choose from open GitHub issues, PRDs, or enter a prompt manually
php artisan ralph:start

# Work on a GitHub issue
php artisan ralph:start --issue=42

# Inline prompt
php artisan ralph:start --prompt="Refactor the payment service"

# Prompt from file
php artisan ralph:start --prompt=prompts/task.md

# Single iteration, foreground (no screen)
php artisan ralph:start --once --prompt="Fix the failing tests"

Options

Flag Description
name Session name (argument, optional)
--issue=N Work on a GitHub issue
--prompt=TEXT|FILE Inline prompt or path to prompt file
--iterations=N Max iterations (default: 30)
--model=MODEL Override Claude model
--budget=USD Max spend per Claude invocation
--fresh Don't resume — each iteration is independent
--resume Resume a previous session
--attach Auto-attach to screen after start
--once Single iteration in foreground

Managing Sessions

# List running sessions
php artisan ralph:status
php artisan ralph:status --json
php artisan ralph:status --clean    # Remove dead entries

# Attach to a session
php artisan ralph:attach
php artisan ralph:attach my-feature

# Kill a session
php artisan ralph:kill my-feature
php artisan ralph:kill --all --force

# View logs
php artisan ralph:logs
php artisan ralph:logs --tail
php artisan ralph:logs --lines=100
php artisan ralph:logs --all        # List all log files

Configuration

php artisan vendor:publish --tag=ralph-config

config/ralph.php

'loop' => [
    'default_iterations'       => env('RALPH_LOOP_ITERATIONS', 30),
    'permission_mode'          => env('RALPH_PERMISSION_MODE', 'acceptEdits'),
    'model'                    => env('RALPH_MODEL'),
    'completion_marker'        => '<promise>COMPLETE</promise>',
    'max_consecutive_failures' => env('RALPH_MAX_CONSECUTIVE_FAILURES', 3),
],

'prompt' => [
    'default_file'  => env('RALPH_PROMPT_FILE'),
    'prd_path'      => 'prd/backlog',
    'suffix'        => 'Focus on one task at a time. Run tests after changes. ...',
    'continuation'  => 'Continue working. Check the PRD and progress files ...',
],

'screen' => [
    'prefix' => 'ralph',
    'shell'  => env('RALPH_SCREEN_SHELL', 'zsh'),
],

'tracking' => [
    'file' => env('RALPH_TRACKING_FILE', '.live-agents'),
],

'logging' => [
    'directory'               => storage_path('ralph-logs'),
    'non_json_warn_threshold' => 50,
],

'script_path' => null,

Prompt Customization

Ralph appends prompt.suffix to every initial prompt and uses prompt.continuation as the prompt for iterations 2+. There is no base system prompt — Ralph passes your content directly to claude -p and relies on Claude's defaults and your project's CLAUDE.md.

PRD Mode

Place PRDs at prd/backlog/{name}/project.md. Optionally add a progress.md alongside it. Ralph discovers these in the interactive menu and passes them as @file references to Claude.

How It Works

  1. You provide a prompt (issue, PRD, file, or text).
  2. Ralph writes the prompt to a temp file, appends the configured suffix.
  3. A Node.js loop runner (ralph-loop.cjs) spawns claude -p with --output-format stream-json.
  4. On iteration 1, a new session is created. On iterations 2+, the session is resumed with the continuation prompt.
  5. Each iteration's output is scanned for the completion marker (<promise>COMPLETE</promise>).
  6. The loop stops when: the marker is detected (exit 0), max iterations reached (exit 2), or consecutive failures exceed the threshold (exit 1).

All of this runs inside a GNU screen session so you can detach and reattach freely.

License

MIT

woda/laravel-ralph 适用场景与选型建议

woda/laravel-ralph 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 283 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「Agent」 「loop」 「claude」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 woda/laravel-ralph 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 woda/laravel-ralph 我们能提供哪些服务?
定制开发 / 二次开发

基于 woda/laravel-ralph 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 283
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 20
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-21