Skip to content

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Jan 8, 2026

Summary

Implements the Ralph Wiggum technique for iterative, self-referential AI development loops, compatible with Claude CLI, OpenCode, and other AI CLI tools.

Based on Geoffrey Huntley's Ralph technique and the Claude Code ralph-wiggum plugin.

Changes

Core Ralph Implementation

  • workflows/ralph-loop.md - Comprehensive documentation
  • scripts/ralph-loop-helper.sh - Cross-tool helper script with state management
  • Commands: /ralph-loop, /cancel-ralph, /ralph-status

Upstream Sync

  • scripts/ralph-upstream-check.sh - Compare against Claude plugin for updates
  • Auto-runs when starting OpenCode session in aidevops repo
  • Caches results for 24h to avoid API rate limits

Quality Loops (Ralph Pattern Applied)

  • scripts/quality-loop-helper.sh - Iterative quality workflows
  • /preflight-loop - Run checks until all pass (promise: PREFLIGHT_PASS)
  • /pr-loop - Monitor PR until approved/merged (promise: PR_APPROVED)
  • /postflight-loop - Monitor release health (promise: RELEASE_HEALTHY)

Ralph Task Classification

  • Added to workflows/plans.md
  • #ralph tag for autonomous tasks
  • Metadata: ralph-promise, ralph-verify, ralph-max
  • /ralph-task command to run tasks from TODO.md by ID

New Quality Workflow

/preflight-loop → /create-pr → /pr-loop → /postflight-loop

Ralph Task Format

- [ ] t042 Fix all ShellCheck violations #ralph ~2h
  ralph-promise: "SHELLCHECK_CLEAN"
  ralph-verify: "shellcheck .agent/scripts/*.sh"
  ralph-max: 10

Testing

  • ShellCheck passes on all new scripts
  • Helper scripts tested manually
  • Commands documented and added to generate-opencode-commands.sh

Summary by CodeRabbit

  • New Features

    • Ralph iterative AI loops and companion quality loops with CLI helpers, status, cancel, external-run, and task-run capabilities.
    • Git worktree tooling for parallel-branch workflows and session management.
  • Documentation

    • Comprehensive Ralph workflow, planning/tagging guidance, worktree workflow docs, and quick-starts.
  • Chores

    • Added an upstream update check and supporting helper utilities.

✏️ Tip: You can customize this high-level summary in your review settings.

Implement the Ralph Wiggum technique for iterative, self-referential
AI development loops, compatible with Claude CLI, OpenCode, and other
AI CLI tools.

New files:
- workflows/ralph-loop.md: comprehensive documentation
- scripts/ralph-loop-helper.sh: cross-tool helper script

Features:
- /ralph-loop command to start iterative loops
- /cancel-ralph to stop active loops
- /ralph-status to check loop state
- Completion detection via <promise> tags
- Max iterations safety limit
- External loop mode for tools without hook support

Based on Geoffrey Huntley's Ralph technique and the Claude Code
ralph-wiggum plugin.
- Add ralph-upstream-check.sh to compare against Claude Code plugin
- Integrate check into aidevops-update-check.sh (runs in aidevops repo)
- Add 'Upstream Sync' section to ralph-loop.md documentation
- Cache results for 24h to avoid excessive API calls
- Detects new options and documentation sections in upstream
Quality Loop Helper (quality-loop-helper.sh):
- /preflight-loop: iterate until all checks pass
- /pr-loop: monitor PR until approved/merged
- /postflight-loop: monitor release health
- Completion promises for Ralph integration

Ralph Task Classification (plans.md):
- Define Ralph-able task criteria
- #ralph tag for autonomous tasks
- ralph-promise, ralph-verify, ralph-max metadata
- /ralph-task command to run by task ID

New OpenCode commands:
- /preflight-loop, /pr-loop, /postflight-loop
- /ralph-task for running tasks from TODO.md

This enables fully autonomous quality workflows using
the Ralph Wiggum iterative development pattern.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

Walkthrough

Adds a "Ralph" iterative AI loop and supporting tooling: new CLI helpers (.agent/scripts/*.sh) for Ralph loops, quality loops, worktree management, and upstream checks; generated OpenCode command files for iterative workflows (duplicate blocks present); and documentation updates integrating Ralph and worktree workflows into planning.

Changes

Cohort / File(s) Summary
Ralph Loop Core
​.agent/scripts/ralph-loop-helper.sh, ​.agent/scripts/ralph-upstream-check.sh, ​.agent/AGENTS.md
New Ralph loop CLI (setup/cancel/status/increment/check-completion, external-run) storing state in .claude/ralph-loop.local.md; upstream plugin change checker with 24h cache; AGENTS.md updated to reference Ralph/workflows.
Quality Automation Loops
​.agent/scripts/quality-loop-helper.sh
New quality-loop helper implementing preflight (linters, optional auto-fix), PR review loop (gh + CI aggregation), postflight release monitoring, local state management, status/cancel, and completion promises.
Worktree Utilities & Docs
​.agent/scripts/worktree-helper.sh, ​.agent/workflows/worktree.md, ​.agent/workflows/git-workflow.md
Adds Git worktree management CLI (add/list/remove/switch/clean/status) plus docs describing patterns, commands, safety checks, and integration with parallel OpenCode sessions.
OpenCode Command Generation
​.agent/scripts/generate-opencode-commands.sh
Adds generation of OpenCode command files for Ralph flows (ralph-loop, cancel-ralph, ralph-status, preflight-loop, pr-loop, postflight-loop, ralph-task) and updates help/workflow text. Diff contains duplicate Ralph command blocks that should be deduplicated.
Update / Sync Helpers
​.agent/scripts/aidevops-update-check.sh, ​.agent/scripts/terminal-title-helper.sh
check_ralph_upstream() added and invoked from main() (errors swallowed to preserve exit behavior); terminal-title resolution switched to --git-common-dir with absolute-path handling for linked worktrees.
Planning & Workflow Docs
​.agent/workflows/ralph-loop.md, ​.agent/workflows/plans.md
Adds Ralph concept, tagging (#ralph with ralph-promise/ralph-verify/ralph-max), examples, command usage, loop lifecycle, state schema, and integration guidance into planning docs.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RalphCLI as Ralph Loop CLI
    participant StateFile as State File (.claude/ralph-loop.local.md)
    participant ExternalTool as External Tool (Claude/OpenCode/Aider)
    participant Completion as Completion Detector

    User->>RalphCLI: setup --max-iterations 5 --completion-promise "<promise>DONE</promise>"
    RalphCLI->>StateFile: create state (iteration:1, active:true, promise)
    RalphCLI-->>User: confirmation

    loop iterate until complete or max
        RalphCLI->>ExternalTool: run iteration (build prompt from state)
        ExternalTool-->>RalphCLI: tool output (may include <promise>)
        RalphCLI->>Completion: check-completion (tool output)
        alt promise matches
            Completion-->>RalphCLI: COMPLETE
            RalphCLI->>StateFile: set active=false
            RalphCLI-->>User: loop complete
        else not matched
            Completion-->>RalphCLI: NOT_COMPLETE
            RalphCLI->>StateFile: increment iteration
            RalphCLI-->>User: continue / retry
        end
    end
Loading
sequenceDiagram
    participant Operator
    participant QualityCLI as Quality Loop Helper
    participant Preflight as Preflight Checks
    participant PRMonitor as PR Monitor (gh)
    participant CI as CI System
    participant Postflight as Postflight Health

    Operator->>QualityCLI: preflight (--auto-fix)
    QualityCLI->>Preflight: run linters & checks
    alt all pass
        Preflight-->>QualityCLI: <promise>PREFLIGHT_PASS</promise>
    else failures/fixes
        Preflight-->>QualityCLI: report/fix attempts
    end

    Operator->>QualityCLI: pr-review (--wait-for-ci)
    QualityCLI->>PRMonitor: query PR, reviews
    PRMonitor->>CI: request checks
    CI-->>PRMonitor: results
    PRMonitor-->>QualityCLI: aggregated status (READY/CI_FAILED/MERGED)
    alt merged
        QualityCLI-->>Operator: <promise>PR_MERGED</promise>
    else iterate/wait
        QualityCLI-->>Operator: continue
    end

    QualityCLI->>Postflight: check_release_health (version, workflows)
    alt healthy
        Postflight-->>QualityCLI: <promise>RELEASE_HEALTHY</promise>
    else retry/report
        Postflight-->>QualityCLI: unhealthy
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🔁 Ralph loops hum in scripted light,
Frontmatter counts the steps each night,
Preflight, PR, postflight sing along,
Promises found — the loop grows strong,
Automation dances until it's right.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 67.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: Ralph Loop iterative AI development workflows' accurately summarizes the main change—adding a comprehensive Ralph Loop implementation for iterative AI development with helper scripts, workflows, and command integrations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66f2815 and 9594945.

📒 Files selected for processing (1)
  • .agent/scripts/terminal-title-helper.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • .agent/scripts/terminal-title-helper.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis

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.

@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the AI development framework by integrating the "Ralph Loop" technique, which enables autonomous, iterative refinement of tasks by AI agents. It introduces core loop management, extends this iterative approach to critical quality assurance workflows like preflight checks and PR monitoring, and establishes a system for classifying and executing tasks suitable for AI-driven iteration. This aims to streamline development by allowing AI to self-correct and progress on well-defined problems.

Highlights

  • Core Ralph Loop Integration: Introduced the foundational "Ralph Loop" for iterative AI development, including a helper script (ralph-loop-helper.sh) and OpenCode commands (/ralph-loop, /cancel-ralph, /ralph-status) for managing AI-driven iterative tasks.
  • Automated Quality Workflows: Implemented new quality-focused iterative loops (quality-loop-helper.sh) such as /preflight-loop for pre-commit checks, /pr-loop for PR monitoring, and /postflight-loop for release health, all leveraging the Ralph pattern.
  • Upstream Sync and Task Classification: Added a mechanism (ralph-upstream-check.sh) to monitor the upstream Claude Code Ralph plugin for updates and integrated Ralph task classification into plans.md, allowing specific tasks to be tagged (#ralph) and executed via /ralph-task.
  • Comprehensive Documentation: Provided detailed documentation (ralph-loop.md) explaining the Ralph technique, its philosophy, best practices for prompt writing, and cross-tool compatibility.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 171 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Jan 8 18:41:20 UTC 2026: Code review monitoring started
Thu Jan 8 18:41:21 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 171
Thu Jan 8 18:41:21 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Thu Jan 8 18:41:23 UTC 2026: Codacy analysis completed with auto-fixes
Thu Jan 8 18:41:24 UTC 2026: Applied 1 automatic fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 171
  • VULNERABILITIES: 0

Generated on: Thu Jan 8 18:41:57 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@augmentcode
Copy link

augmentcode bot commented Jan 8, 2026

🤖 Augment PR Summary

Summary: Adds “Ralph Loop” iterative AI workflows to make autonomous, self-referential development loops first-class in aidevops.

Changes:

  • Added .agent/workflows/ralph-loop.md documenting the Ralph technique, completion promises, and cross-tool usage.
  • Introduced .agent/scripts/ralph-loop-helper.sh to manage loop state (setup/status/cancel) and an external loop wrapper for tools without hook support.
  • Added .agent/scripts/quality-loop-helper.sh implementing Ralph-style loops for preflight checks, PR monitoring, and postflight release health.
  • Added .agent/scripts/ralph-upstream-check.sh to compare against the upstream Claude Code ralph-wiggum plugin with 24h caching.
  • Updated .agent/scripts/aidevops-update-check.sh to trigger the upstream check when running in the aidevops repo.
  • Extended OpenCode command generation to include /ralph-loop, /cancel-ralph, /ralph-status, /preflight-loop, /pr-loop, /postflight-loop, and /ralph-task.
  • Updated .agent/workflows/plans.md to define “Ralph-able” task criteria and tagging/metadata conventions.
  • Updated agent docs (.agent/AGENTS.md) to reference the new workflow documentation.

Technical Notes: Loop state is stored under .claude/ (local, gitignored), and workflow completion is signaled via <promise>...</promise> markers for deterministic automation.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.


# Check 1: ShellCheck
print_info " Checking ShellCheck..."
if find .agent/scripts -name "*.sh" -exec shellcheck {} \; >/dev/null 2>&1; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find ... -exec shellcheck typically won’t propagate shellcheck’s non-zero exit code, so this can report ShellCheck: PASS even when ShellCheck finds violations. That would make the /preflight-loop promise unreliable.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

print_info "=== PR Review Iteration $iteration / $max_iterations ==="

local status
status=$(check_pr_status "$pr_number" "$wait_for_ci")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the script uses set -e, if check_pr_status returns non-zero this assignment will terminate the whole script immediately (before your retry/loop logic can run). That can make /pr-loop brittle when gh fails transiently or isn’t authenticated.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

if [[ -n "$upstream_setup" ]]; then
# Look for new case options
local upstream_options
upstream_options=$(echo "$upstream_setup" | grep -E '^\s+--[a-z-]+\)' | sed 's/)//' | tr -d ' ' || true)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grep -E doesn’t treat \s as “whitespace” in many environments, so this pattern may never match and upstream option detection could be silently skipped.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the Ralph Loop for iterative AI development, a significant feature that includes new helper scripts, OpenCode commands, and extensive documentation. The implementation is robust, with new scripts for the core loop, quality checks, and upstream version comparison. The changes are well-documented in markdown files. The code is of high quality, but I've identified a few areas for improvement in the shell scripts, mainly concerning security in temporary file creation and robustness in path resolution and loop timing.

return 1
fi

local temp_file="${STATE_FILE}.tmp.$$"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using $$ for temporary filenames is not secure as it can be predictable, leading to potential race conditions. It's safer to use mktemp to generate a unique temporary file name.

Suggested change
local temp_file="${STATE_FILE}.tmp.$$"
local temp_file; temp_file=$(mktemp)

iteration=$(increment_iteration)

if [[ $iteration -le $max_iterations ]]; then
local wait_time=$((monitor_duration / max_iterations))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The calculation for wait_time uses integer division. If monitor_duration is less than max_iterations, wait_time could become 0, leading to a busy-loop that consumes CPU and finishes the monitoring instantly. This change ensures the wait time is at least 1 second.

Suggested change
local wait_time=$((monitor_duration / max_iterations))
local wait_time=$((monitor_duration / max_iterations)); [[ $wait_time -lt 1 ]] && wait_time=1

local next_iteration=$((current_iteration + 1))

# Update iteration in frontmatter (portable across macOS and Linux)
local temp_file="${RALPH_STATE_FILE}.tmp.$$"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using $$ for temporary filenames is not secure as it can be predictable, leading to potential race conditions. It's safer to use mktemp to generate a unique temporary file name. This also makes it consistent with run_external_loop in the same script, which correctly uses mktemp.

Suggested change
local temp_file="${RALPH_STATE_FILE}.tmp.$$"
local temp_file; temp_file=$(mktemp)


if [[ "$current_repo" == "aidevops" ]]; then
local script_dir
script_dir="$(dirname "$0")"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using dirname "$0" can be unreliable, for instance when the script is symlinked or called from a different directory. A more robust method to get the script's directory is to use ${BASH_SOURCE[0]} with cd and pwd. This is also consistent with the pattern used in the other new scripts in this pull request.

Suggested change
script_dir="$(dirname "$0")"
script_dir="$(cd \"$(dirname \"${BASH_SOURCE[0]}\")\" && pwd)"

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In @.agent/scripts/quality-loop-helper.sh:
- Around line 609-682: postflight_loop silently ignores invalid
--monitor-duration values; update the parsing block that reads duration_str to
detect when the value doesn't match minutes (^[0-9]+m$), hours (^[0-9]+h$) or
plain seconds (^[0-9]+$) and emit a warning (e.g., via print_warning or
print_info) indicating the unrecognized format and that the default
monitor_duration will be used, then leave monitor_duration unchanged or set to
DEFAULT_MONITOR_DURATION; specifically modify the branch handling duration_str
in postflight_loop to add an else case that logs the warning and prevents silent
failure.

In @.agent/scripts/ralph-loop-helper.sh:
- Around line 438-453: In the case block for tool handling (case "$tool" in ...
esac), the aider branch currently sends the prompt twice (via echo pipe and
--message); update the aider case in the ralph-loop-helper.sh helper to stop the
duplicate input by using a single invocation method—e.g., call aider with
--message "$full_prompt" and remove the echo "$full_prompt" pipe, keeping the
same redirection to "$output_file" and stderr (2>&1) and preserving the || true
fallback.
- Around line 370-397: The run_external_loop function currently parses
--max-iterations and --completion-promise but does not validate them like
setup_loop does; update run_external_loop to validate that the parsed
max_iterations is a positive integer (e.g., check with a numeric regex or
arithmetic test) and that completion_promise is non-empty before use, and on
invalid values emit a clear error message and exit or fallback to safe defaults;
mirror the same validation logic and error handling used in setup_loop for
--max-iterations and --completion-promise so behavior is consistent across both
functions.
🧹 Nitpick comments (4)
.agent/scripts/ralph-loop-helper.sh (1)

467-472: Sleep between iterations is reasonable but consider making it configurable.

The 2-second delay is hardcoded. For longer-running AI tasks, this is fine, but flexibility could be useful.

.agent/scripts/quality-loop-helper.sh (1)

518-543: Long sleep durations in PR review loop may be intentional but consider documenting.

The 30-second wait for PENDING CI and 60-second wait between iterations are hardcoded. This is reasonable for CI checks but could be configurable for different workflows.

Consider adding --poll-interval option for users with faster CI pipelines.

.agent/scripts/ralph-upstream-check.sh (1)

131-192: Comparison logic is thorough but grep patterns could use refinement.

The detection of new options (Line 152) and new sections (Line 161) provides useful signal. However, the hardcoded list of known sections may need updates as documentation evolves.

Consider extracting the known options and sections to variables at the top of the file for easier maintenance:

readonly KNOWN_OPTIONS="max-iterations|completion-promise|help"
readonly KNOWN_SECTIONS="What is Ralph|Quick Start|Commands|Philosophy|..."
.agent/scripts/generate-opencode-commands.sh (1)

1314-1362: LGTM - Bridges task tracking with autonomous execution.

The integration between TODO.md and Ralph loops via task IDs is well-designed. Supporting both multi-line metadata and shorthand (#ralph(PROMISE)) syntax provides good flexibility.

Minor suggestion: Consider documenting error behavior when task ID is not found or required metadata is missing, so users know what to expect.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f8d5f6 and 07afe84.

📒 Files selected for processing (8)
  • .agent/AGENTS.md
  • .agent/scripts/aidevops-update-check.sh
  • .agent/scripts/generate-opencode-commands.sh
  • .agent/scripts/quality-loop-helper.sh
  • .agent/scripts/ralph-loop-helper.sh
  • .agent/scripts/ralph-upstream-check.sh
  • .agent/workflows/plans.md
  • .agent/workflows/ralph-loop.md
🧰 Additional context used
📓 Path-based instructions (1)
.agent/scripts/*.sh

⚙️ CodeRabbit configuration file

.agent/scripts/*.sh: Automation scripts - focus on:

  • Reliability and robustness
  • Clear logging and feedback
  • Proper exit codes
  • Error recovery mechanisms

Files:

  • .agent/scripts/aidevops-update-check.sh
  • .agent/scripts/ralph-upstream-check.sh
  • .agent/scripts/quality-loop-helper.sh
  • .agent/scripts/generate-opencode-commands.sh
  • .agent/scripts/ralph-loop-helper.sh
🧠 Learnings (5)
📚 Learning: 2025-11-29T04:34:42.033Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENT.md:0-0
Timestamp: 2025-11-29T04:34:42.033Z
Learning: Reference AGENTS.md (authoritative) instead of AGENT.md for AI assistant guidance

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-11-29T04:34:30.742Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: GEMINI.md:0-0
Timestamp: 2025-11-29T04:34:30.742Z
Learning: Reference AGENTS.md for authoritative AI assistant guidance instead of GEMINI.md

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-11-29T04:34:42.033Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENT.md:0-0
Timestamp: 2025-11-29T04:34:42.033Z
Learning: Maintain all AI assistant instructions, documentation, and operational guidance in AGENTS.md as the single source of truth

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2026-01-06T15:57:56.007Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-06T15:57:56.007Z
Learning: Applies to **/.agent/scripts/linters-local.sh : Run quality checks before committing using .agent/scripts/linters-local.sh

Applied to files:

  • .agent/AGENTS.md
  • .agent/scripts/aidevops-update-check.sh
  • .agent/scripts/ralph-upstream-check.sh
  • .agent/scripts/quality-loop-helper.sh
📚 Learning: 2026-01-06T15:57:56.008Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-06T15:57:56.008Z
Learning: Applies to **/AGENTS.md : Limit root AGENTS.md to ~50-100 max instructions with universal applicability to >80% of tasks

Applied to files:

  • .agent/scripts/generate-opencode-commands.sh
🧬 Code graph analysis (3)
.agent/scripts/ralph-upstream-check.sh (1)
.agent/scripts/aidevops-update-check.sh (1)
  • main (50-69)
.agent/scripts/quality-loop-helper.sh (1)
.opencode/tool/mcp-integrations.ts (1)
  • validate (15-25)
.agent/scripts/ralph-loop-helper.sh (1)
.opencode/tool/mcp-integrations.ts (1)
  • setup (3-13)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (43)
.agent/scripts/ralph-loop-helper.sh (8)

1-34: LGTM! Solid script foundation with proper safety settings.

Good use of set -euo pipefail and readonly constants. Color definitions are clean.


40-62: Helper functions are well-structured with consistent patterns.

Each function returns 0 explicitly, which is good practice for functions that always succeed. The >&2 redirection for errors is correct.


64-126: Comprehensive help documentation with examples and usage guidance.

The heredoc with clear sections for commands, options, examples, and monitoring makes this very user-friendly.


132-176: Robust argument parsing with proper validation.

Good validation for --max-iterations requiring a numeric value and --completion-promise requiring a non-empty argument. The prompt accumulation pattern handles multi-word prompts correctly.


178-233: State file creation and setup messaging are well-implemented.

The YAML frontmatter format is clear and the completion promise requirements are prominently displayed. Using ISO 8601 timestamps ensures consistency.


309-333: Safe iteration increment with temp file pattern.

Good use of $$ PID suffix for temp file uniqueness and proper mv for atomic update. This avoids race conditions and is portable across macOS and Linux.


479-527: Main dispatcher is clean with good command routing.

The case statement covers all documented commands with proper help fallback. Good use of shift || true to handle missing arguments gracefully.


285-307: Perl dependency for multiline regex extraction.

The check_completion function uses Perl for extracting promise text. This is a reasonable choice for multiline support, but Perl may not be available on all minimal systems.

Consider documenting the Perl dependency or adding a fallback. Most systems have Perl, but it's worth noting:

#!/bin/bash
# Verify Perl is available on target systems
command -v perl &>/dev/null && echo "Perl available" || echo "Perl NOT available"
.agent/scripts/quality-loop-helper.sh (9)

1-39: Good foundation with consistent patterns.

Constants and color definitions follow the same patterns as ralph-loop-helper.sh, maintaining consistency across the helper scripts.


79-100: State file creation is well-structured.

The YAML frontmatter includes all relevant fields. Good that checks_passed and checks_failed are initialized as empty arrays for future tracking.


102-128: State management functions are solid.

The update_state and get_state_field functions handle missing files gracefully. The sed-based update pattern matches ralph-loop-helper.sh.


246-267: Markdown linting with auto-fix is a nice touch.

Using increment_fixes to track applied fixes provides good observability. The || true ensures the script continues even if auto-fix partially fails.


294-358: Preflight loop logic is correct with proper state cleanup.

The loop correctly removes the state file on success (Line 331) and outputs the completion promise. The early exit when not using auto-fix (Line 353) is a reasonable design choice.


364-419: PR status checking is thorough with good jq usage.

The function handles various PR states (MERGED, READY, PENDING, CI_FAILED, CHANGES_REQUESTED, WAITING) comprehensively. Good use of // "NONE" for null coalescing.


421-450: PR feedback retrieval handles API errors gracefully.

Using || echo "" for curl failures and head -10/head -20 to limit output prevents overwhelming the user with feedback.


554-607: Release health check is well-implemented.

Good use of jq for parsing workflow run status and comparing versions. The version comparison logic (Line 594) correctly handles both v prefix and bare versions.


740-772: Main function routing is clean and complete.

All documented commands are handled with proper help fallback. The pr alias for pr-review is a nice convenience.

.agent/scripts/aidevops-update-check.sh (2)

35-48: Clean integration with proper error suppression.

The function correctly identifies when running in the aidevops repo and only then attempts the upstream check. The 2>/dev/null || true pattern ensures this never interrupts the main update check flow.


64-67: Good placement of Ralph upstream check.

Calling check_ralph_upstream after the version output ensures the primary update check completes before any secondary checks. This maintains predictable output ordering.

.agent/AGENTS.md (3)

243-243: Workflows table correctly updated.

The ralph-loop addition to the workflows list is consistent with the new .agent/workflows/ralph-loop.md file.


340-340: Key scripts documentation updated correctly.

The ralph-loop-helper.sh entry with description "Iterative AI development loops (Ralph technique)" accurately describes the new script.


411-411: Development workflows table entry is accurate.

The "Iterative AI loops" entry correctly links to workflows/ralph-loop.md.

.agent/workflows/ralph-loop.md (7)

1-12: Frontmatter correctly enables required tools.

The tool permissions (read, write, edit, bash, glob, grep, task) align with what the Ralph loop workflow needs to function.


14-46: Clear explanation of the Ralph concept and workflow.

The documentation accurately describes the iterative loop pattern and self-referential feedback mechanism. The ASCII workflow diagram is helpful.


47-66: Quick start examples are practical and match implementation.

The command examples use the correct syntax with --max-iterations and --completion-promise flags as implemented in ralph-loop-helper.sh.


97-126: State file documentation matches implementation.

The YAML frontmatter structure documented here matches exactly what setup_loop() creates in ralph-loop-helper.sh. The critical rules for completion promises are emphasized appropriately.


128-203: Excellent prompt writing best practices.

The good/bad examples clearly illustrate what makes a Ralph-able prompt. The escape hatches section (Lines 190-203) is particularly valuable for safety.


239-260: Cross-tool compatibility section is well-documented.

The table clearly shows which tools support native hooks vs. external loops. The external loop example uses correct script path and arguments.


275-296: Real-world results and upstream sync information.

Interesting context about the technique's origins. The automatic upstream check on aidevops repo sessions is correctly documented.

.agent/scripts/ralph-upstream-check.sh (4)

68-83: Cache validation handles cross-platform stat differences.

Good use of fallback between macOS (-f %m) and Linux (-c %Y) stat formats. The TTL check is correct.


101-125: API functions have proper error handling.

The curl -sf flags ensure silent failure on HTTP errors. The fallback to empty string on failure is appropriate for a non-critical check.


198-260: Main check function has good caching logic.

The SHA-based change detection is efficient - only fetching file contents when SHAs differ. Cache updates include proper timestamps for debugging.


292-325: Argument parsing is clean with force flag support.

The --force flag correctly clears the cache before checking. Unknown options are properly rejected with help display.

.agent/workflows/plans.md (3)

80-107: Ralph classification criteria are clearly documented.

The table format for criteria (Lines 88-95) and signals (Lines 98-107) provides quick reference. The "Ralph-able" vs "Non-Ralph-able" examples are practical.


108-140: Task tagging format with Ralph metadata is well-designed.

Both full format (with separate lines for ralph-promise, ralph-verify, ralph-max) and shorthand format #ralph(PROMISE) are documented. This provides flexibility for different task complexities.


141-179: Running Ralph tasks and PLANS.md integration are well-documented.

The /ralph-task command example and phase-level Ralph annotations in PLANS.md show practical integration patterns. The quality loop table (Lines 172-177) correctly references the completion promises from quality-loop-helper.sh.

.agent/scripts/generate-opencode-commands.sh (7)

1070-1118: LGTM - Ralph loop command generation is well-structured.

The command definition follows the established pattern, provides clear documentation with usage examples, and properly references the helper script. The completion promise mechanism (<promise>...</promise>) is well-documented.


1120-1143: LGTM - Cancel command is appropriately minimal.

Clear separation between the globally-installed helper script (~/.aidevops/agents/scripts/ralph-loop-helper.sh) and the project-local state file (.claude/ralph-loop.local.md).


1145-1171: LGTM - Status command provides expected diagnostics.

Documents the key status fields (iteration count, max iterations, completion promise, start time) that operators would need for monitoring.


1173-1217: LGTM - Preflight loop applies Ralph pattern to quality gates.

Correctly uses quality-loop-helper.sh (separate from the general-purpose ralph-loop-helper.sh), includes sensible defaults (max 10 iterations), and documents both manual and auto-fix workflows.


1219-1267: LGTM - PR loop covers the full review lifecycle.

The dual completion promises (PR_APPROVED / PR_MERGED) allow for different workflow termination points. The documented workflow correctly handles CI failures, review feedback, and pending states.


1269-1312: LGTM - Postflight monitoring with duration-based checks.

Lower default iterations (5) is sensible for post-deployment health checks. The --monitor-duration option enables time-boxed monitoring which aligns with observability best practices.


1412-1426: LGTM - Summary accurately reflects new commands.

All seven Ralph-related commands are properly listed under "Automation (Ralph Loops)", and the workflow documentation clearly shows the new quality workflow sequence (preflight-loop → create-pr → pr-loop → postflight-loop) and Ralph task workflow.

Note: The AI-generated summary mentioned "duplicate insertions" but no duplicate blocks are present in the actual code.

Comment on lines +206 to +292
run_preflight_checks() {
local auto_fix="$1"
local results=""
local all_passed=true

print_step "Running preflight checks..."

# Check 1: ShellCheck
print_info " Checking ShellCheck..."
if find .agent/scripts -name "*.sh" -exec shellcheck {} \; >/dev/null 2>&1; then
results="${results}shellcheck:pass\n"
print_success " ShellCheck: PASS"
else
results="${results}shellcheck:fail\n"
print_warning " ShellCheck: FAIL"
all_passed=false

if [[ "$auto_fix" == "true" ]]; then
print_info " Auto-fix not available for ShellCheck (manual fixes required)"
fi
fi

# Check 2: Secretlint
print_info " Checking secrets..."
if command -v secretlint &>/dev/null; then
if secretlint "**/*" --no-terminalLink 2>/dev/null; then
results="${results}secretlint:pass\n"
print_success " Secretlint: PASS"
else
results="${results}secretlint:fail\n"
print_warning " Secretlint: FAIL"
all_passed=false
fi
else
results="${results}secretlint:skip\n"
print_info " Secretlint: SKIPPED (not installed)"
fi

# Check 3: Markdown formatting
print_info " Checking markdown..."
if command -v markdownlint &>/dev/null || command -v markdownlint-cli2 &>/dev/null; then
local md_cmd="markdownlint"
command -v markdownlint-cli2 &>/dev/null && md_cmd="markdownlint-cli2"

if $md_cmd "**/*.md" --ignore node_modules 2>/dev/null; then
results="${results}markdown:pass\n"
print_success " Markdown: PASS"
else
results="${results}markdown:fail\n"
print_warning " Markdown: FAIL"
all_passed=false

if [[ "$auto_fix" == "true" ]]; then
print_info " Attempting auto-fix..."
$md_cmd "**/*.md" --fix --ignore node_modules 2>/dev/null || true
increment_fixes > /dev/null
fi
fi
else
results="${results}markdown:skip\n"
print_info " Markdown: SKIPPED (markdownlint not installed)"
fi

# Check 4: Version consistency
print_info " Checking version consistency..."
if [[ -x "${SCRIPT_DIR}/version-manager.sh" ]]; then
if "${SCRIPT_DIR}/version-manager.sh" validate &>/dev/null; then
results="${results}version:pass\n"
print_success " Version: PASS"
else
results="${results}version:fail\n"
print_warning " Version: FAIL"
all_passed=false
fi
else
results="${results}version:skip\n"
print_info " Version: SKIPPED (version-manager.sh not found)"
fi

# Return results
if [[ "$all_passed" == "true" ]]; then
echo "PASS"
else
echo "FAIL"
fi
return 0
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Preflight checks are comprehensive but have a glob expansion concern.

The find command in Line 215 and glob patterns like "**/*" for secretlint (Line 231) may behave unexpectedly depending on shell settings.

The secretlint "**/*" pattern relies on shell glob expansion which may not work as expected in all contexts. Consider using explicit find or secretlint's built-in file discovery.

🔧 Safer secretlint invocation
     # Check 2: Secretlint
     print_info "  Checking secrets..."
     if command -v secretlint &>/dev/null; then
-        if secretlint "**/*" --no-terminalLink 2>/dev/null; then
+        if secretlint --no-terminalLink 2>/dev/null; then
             results="${results}secretlint:pass\n"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run_preflight_checks() {
local auto_fix="$1"
local results=""
local all_passed=true
print_step "Running preflight checks..."
# Check 1: ShellCheck
print_info " Checking ShellCheck..."
if find .agent/scripts -name "*.sh" -exec shellcheck {} \; >/dev/null 2>&1; then
results="${results}shellcheck:pass\n"
print_success " ShellCheck: PASS"
else
results="${results}shellcheck:fail\n"
print_warning " ShellCheck: FAIL"
all_passed=false
if [[ "$auto_fix" == "true" ]]; then
print_info " Auto-fix not available for ShellCheck (manual fixes required)"
fi
fi
# Check 2: Secretlint
print_info " Checking secrets..."
if command -v secretlint &>/dev/null; then
if secretlint "**/*" --no-terminalLink 2>/dev/null; then
results="${results}secretlint:pass\n"
print_success " Secretlint: PASS"
else
results="${results}secretlint:fail\n"
print_warning " Secretlint: FAIL"
all_passed=false
fi
else
results="${results}secretlint:skip\n"
print_info " Secretlint: SKIPPED (not installed)"
fi
# Check 3: Markdown formatting
print_info " Checking markdown..."
if command -v markdownlint &>/dev/null || command -v markdownlint-cli2 &>/dev/null; then
local md_cmd="markdownlint"
command -v markdownlint-cli2 &>/dev/null && md_cmd="markdownlint-cli2"
if $md_cmd "**/*.md" --ignore node_modules 2>/dev/null; then
results="${results}markdown:pass\n"
print_success " Markdown: PASS"
else
results="${results}markdown:fail\n"
print_warning " Markdown: FAIL"
all_passed=false
if [[ "$auto_fix" == "true" ]]; then
print_info " Attempting auto-fix..."
$md_cmd "**/*.md" --fix --ignore node_modules 2>/dev/null || true
increment_fixes > /dev/null
fi
fi
else
results="${results}markdown:skip\n"
print_info " Markdown: SKIPPED (markdownlint not installed)"
fi
# Check 4: Version consistency
print_info " Checking version consistency..."
if [[ -x "${SCRIPT_DIR}/version-manager.sh" ]]; then
if "${SCRIPT_DIR}/version-manager.sh" validate &>/dev/null; then
results="${results}version:pass\n"
print_success " Version: PASS"
else
results="${results}version:fail\n"
print_warning " Version: FAIL"
all_passed=false
fi
else
results="${results}version:skip\n"
print_info " Version: SKIPPED (version-manager.sh not found)"
fi
# Return results
if [[ "$all_passed" == "true" ]]; then
echo "PASS"
else
echo "FAIL"
fi
return 0
}
run_preflight_checks() {
local auto_fix="$1"
local results=""
local all_passed=true
print_step "Running preflight checks..."
# Check 1: ShellCheck
print_info " Checking ShellCheck..."
if find .agent/scripts -name "*.sh" -exec shellcheck {} \; >/dev/null 2>&1; then
results="${results}shellcheck:pass\n"
print_success " ShellCheck: PASS"
else
results="${results}shellcheck:fail\n"
print_warning " ShellCheck: FAIL"
all_passed=false
if [[ "$auto_fix" == "true" ]]; then
print_info " Auto-fix not available for ShellCheck (manual fixes required)"
fi
fi
# Check 2: Secretlint
print_info " Checking secrets..."
if command -v secretlint &>/dev/null; then
if secretlint --no-terminalLink 2>/dev/null; then
results="${results}secretlint:pass\n"
print_success " Secretlint: PASS"
else
results="${results}secretlint:fail\n"
print_warning " Secretlint: FAIL"
all_passed=false
fi
else
results="${results}secretlint:skip\n"
print_info " Secretlint: SKIPPED (not installed)"
fi
# Check 3: Markdown formatting
print_info " Checking markdown..."
if command -v markdownlint &>/dev/null || command -v markdownlint-cli2 &>/dev/null; then
local md_cmd="markdownlint"
command -v markdownlint-cli2 &>/dev/null && md_cmd="markdownlint-cli2"
if $md_cmd "**/*.md" --ignore node_modules 2>/dev/null; then
results="${results}markdown:pass\n"
print_success " Markdown: PASS"
else
results="${results}markdown:fail\n"
print_warning " Markdown: FAIL"
all_passed=false
if [[ "$auto_fix" == "true" ]]; then
print_info " Attempting auto-fix..."
$md_cmd "**/*.md" --fix --ignore node_modules 2>/dev/null || true
increment_fixes > /dev/null
fi
fi
else
results="${results}markdown:skip\n"
print_info " Markdown: SKIPPED (markdownlint not installed)"
fi
# Check 4: Version consistency
print_info " Checking version consistency..."
if [[ -x "${SCRIPT_DIR}/version-manager.sh" ]]; then
if "${SCRIPT_DIR}/version-manager.sh" validate &>/dev/null; then
results="${results}version:pass\n"
print_success " Version: PASS"
else
results="${results}version:fail\n"
print_warning " Version: FAIL"
all_passed=false
fi
else
results="${results}version:skip\n"
print_info " Version: SKIPPED (version-manager.sh not found)"
fi
# Return results
if [[ "$all_passed" == "true" ]]; then
echo "PASS"
else
echo "FAIL"
fi
return 0
}

- Add warning for unrecognized --monitor-duration formats in postflight_loop
- Fix Aider duplicate prompt (was sending via both stdin and --message)
- Add validation for --max-iterations, --completion-promise, --tool in run_external_loop
- Add docstrings to all functions in both helper scripts (80%+ coverage)
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 171 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Jan 8 19:50:13 UTC 2026: Code review monitoring started
Thu Jan 8 19:50:14 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 171
Thu Jan 8 19:50:14 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Thu Jan 8 19:50:16 UTC 2026: Codacy analysis completed with auto-fixes
Thu Jan 8 19:50:17 UTC 2026: Applied 1 automatic fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 171
  • VULNERABILITIES: 0

Generated on: Thu Jan 8 19:50:51 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.agent/scripts/ralph-loop-helper.sh:
- Around line 366-368: The temp file creation using local
temp_file="${RALPH_STATE_FILE}.tmp.$$" is unsafe; replace it with mktemp to get
a secure unique temp file (e.g., use mktemp with a template or -t) and write the
sed output to that mktemp path instead of the PID-based name; also ensure you
register a trap to clean up the temp_file on exit/failure and use mv
"$temp_file" "$RALPH_STATE_FILE" as before so the atomic replacement behavior
remains (refer to the temp_file variable and RALPH_STATE_FILE in this change).
- Line 332: The extraction of promise_text uses perl and fails silently when
perl is missing; add an explicit dependency check before the perl call (verify
command -v perl and on failure call print_error "perl is required for completion
promise detection" and return 1) so the script fails fast with a clear message,
add a note in the script header/README documenting perl as a required
dependency, and optionally implement a simple Bash fallback for single-line
promises to use when perl is absent.
🧹 Nitpick comments (2)
.agent/scripts/ralph-loop-helper.sh (2)

211-221: Use atomic write pattern for state file creation.

The direct write to $RALPH_STATE_FILE could leave a corrupted state if interrupted mid-write (e.g., Ctrl+C, system crash). For improved reliability, write to a temporary file first, then use mv for an atomic replacement.

♻️ Proposed atomic write pattern
+    # Create state file atomically
+    local temp_state_file
+    temp_state_file=$(mktemp "${RALPH_STATE_FILE}.tmp.XXXXXX")
+
-    # Create state file
-    cat > "$RALPH_STATE_FILE" << EOF
+    cat > "$temp_state_file" << EOF
 ---
 active: true
 iteration: 1
 max_iterations: $max_iterations
 completion_promise: $completion_promise_yaml
 started_at: "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
 ---
 
 $prompt
 EOF
+
+    mv "$temp_state_file" "$RALPH_STATE_FILE"

456-462: Consider early validation for the --tool argument.

The tool name is accepted without validation during argument parsing. Invalid tools are only caught at runtime (line 522), after setup messages and potentially wasted iterations. Early validation would fail-fast and improve UX.

🔍 Early validation pattern
             --tool)
                 if [[ -z "${2:-}" ]]; then
                     print_error "--tool requires a tool name argument"
                     return 1
                 fi
+                # Validate tool is supported
+                if [[ ! "$2" =~ ^(opencode|claude|aider)$ ]]; then
+                    print_error "Unknown tool: $2. Supported: opencode, claude, aider"
+                    return 1
+                fi
                 tool="$2"
                 shift 2
                 ;;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07afe84 and 92d3844.

📒 Files selected for processing (2)
  • .agent/scripts/quality-loop-helper.sh
  • .agent/scripts/ralph-loop-helper.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • .agent/scripts/quality-loop-helper.sh
🧰 Additional context used
📓 Path-based instructions (1)
.agent/scripts/*.sh

⚙️ CodeRabbit configuration file

.agent/scripts/*.sh: Automation scripts - focus on:

  • Reliability and robustness
  • Clear logging and feedback
  • Proper exit codes
  • Error recovery mechanisms

Files:

  • .agent/scripts/ralph-loop-helper.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (4)
.agent/scripts/ralph-loop-helper.sh (4)

1-35: Excellent foundational setup.

Strong start with comprehensive documentation, strict error handling via set -euo pipefail, and proper use of readonly constants. The color definitions and clear directory structure provide good UX groundwork.


40-142: LGTM: Clean helper functions and comprehensive help.

The print helpers correctly route errors to stderr, use local variables, and provide consistent colored output. The help text is thorough, well-structured, and includes practical examples.


486-489: Excellent resource cleanup pattern.

Proper use of mktemp for safe temp file creation combined with a trap ensures cleanup even on script interruption. This is exactly the right pattern for robust shell scripting.


552-600: LGTM: Clean command dispatcher with sensible defaults.

The main function provides clear command routing, good error messages for unknown commands, and smart defaults (e.g., fetching completion promise from state when not provided). The shift || true pattern safely handles edge cases.

- Add worktree-helper.sh with add/list/remove/status/switch/clean commands
- Add workflows/worktree.md with full documentation and patterns
- Update git-workflow.md with worktree recommendation for parallel sessions
- Update AGENTS.md quick reference with worktree commands

Enables multiple terminal tabs/AI sessions to work on different branches
simultaneously without interference. Each branch gets its own directory
(e.g., ~/Git/repo-feature-auth/) sharing the same git database.
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 171 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Jan 8 22:14:34 UTC 2026: Code review monitoring started
Thu Jan 8 22:14:35 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 171
Thu Jan 8 22:14:35 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Thu Jan 8 22:14:37 UTC 2026: Codacy analysis completed with auto-fixes
Thu Jan 8 22:14:38 UTC 2026: Applied 2 automatic fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 171
  • VULNERABILITIES: 0

Generated on: Thu Jan 8 22:15:07 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
.agent/AGENTS.md (1)

144-158: Consider consolidating worktree guidance across files.

Lines 144-158 duplicate much of the Git worktrees section added to workflows/git-workflow.md (lines 64-80). While AGENTS.md serves as a quick reference, the command examples and brief explanations are nearly identical across both files.

Option 1 (recommended): Keep AGENTS.md concise with just the worktree-helper commands and reference to workflows/worktree.md (more like current git-workflow.md style). Move fuller context to worktree.md, which already has comprehensive coverage.

Option 2: Accept duplication since AGENTS.md is a quick-ref entry point vs git-workflow.md being the detailed orchestrator.

Current state works, but Option 1 would reduce maintenance burden if worktree commands change.

.agent/scripts/worktree-helper.sh (1)

83-99: Consider escaping branch names in grep patterns for robustness.

Lines 92 and 98 use unescaped branch names in grep patterns. While Git branch names have restrictions, certain characters like . could cause unintended regex matches.

🛡️ Recommended fix using grep -F or escaped patterns

For line 92:

 worktree_exists_for_branch() {
     local branch="$1"
-    git worktree list --porcelain | grep -q "branch refs/heads/$branch$"
+    git worktree list --porcelain | grep -qF "branch refs/heads/$branch"
 }

For line 98, a similar approach or use grep -F with -B2:

 get_worktree_path_for_branch() {
     local branch="$1"
-    git worktree list --porcelain | grep -B2 "branch refs/heads/$branch$" | grep "^worktree " | cut -d' ' -f2-
+    git worktree list --porcelain | grep -FB2 "branch refs/heads/$branch" | grep "^worktree " | cut -d' ' -f2-
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92d3844 and 78a4b36.

📒 Files selected for processing (4)
  • .agent/AGENTS.md
  • .agent/scripts/worktree-helper.sh
  • .agent/workflows/git-workflow.md
  • .agent/workflows/worktree.md
🧰 Additional context used
📓 Path-based instructions (1)
.agent/scripts/*.sh

⚙️ CodeRabbit configuration file

.agent/scripts/*.sh: Automation scripts - focus on:

  • Reliability and robustness
  • Clear logging and feedback
  • Proper exit codes
  • Error recovery mechanisms

Files:

  • .agent/scripts/worktree-helper.sh
🧠 Learnings (10)
📚 Learning: 2025-12-22T01:24:53.937Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/AGENTS.md:0-0
Timestamp: 2025-12-22T01:24:53.937Z
Learning: Follow all security protocols and working directory specifications defined in ~/Git/aidevops/AGENTS.md

Applied to files:

  • .agent/workflows/git-workflow.md
  • .agent/workflows/worktree.md
  • .agent/AGENTS.md
📚 Learning: 2025-12-22T01:25:03.138Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/git/AGENTS.md:0-0
Timestamp: 2025-12-22T01:25:03.138Z
Learning: Follow security protocols for all git and DevOps operations

Applied to files:

  • .agent/workflows/git-workflow.md
📚 Learning: 2025-12-22T01:24:53.937Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/AGENTS.md:0-0
Timestamp: 2025-12-22T01:24:53.937Z
Learning: Never store credentials in working directories (~/.aidevops/.agent-workspace/), Git repositories, home directory root, or hardcoded in code and scripts

Applied to files:

  • .agent/workflows/git-workflow.md
📚 Learning: 2025-12-22T01:24:53.937Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/AGENTS.md:0-0
Timestamp: 2025-12-22T01:24:53.937Z
Learning: Use only the specified working directories: ~/.aidevops/.agent-workspace/work/[project]/ for work files, ~/.aidevops/.agent-workspace/tmp/ for temporary files, and ~/.aidevops/.agent-workspace/memory/ for persistent memory

Applied to files:

  • .agent/workflows/git-workflow.md
  • .agent/workflows/worktree.md
📚 Learning: 2025-11-29T04:34:27.158Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-29T04:34:27.158Z
Learning: All instructions, documentation, and operational guidance should be maintained in AGENTS.md as the single source of truth

Applied to files:

  • .agent/workflows/worktree.md
📚 Learning: 2025-11-29T04:34:42.033Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENT.md:0-0
Timestamp: 2025-11-29T04:34:42.033Z
Learning: Reference AGENTS.md (authoritative) instead of AGENT.md for AI assistant guidance

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-11-29T04:34:30.742Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: GEMINI.md:0-0
Timestamp: 2025-11-29T04:34:30.742Z
Learning: Reference AGENTS.md for authoritative AI assistant guidance instead of GEMINI.md

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-11-29T04:34:42.033Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENT.md:0-0
Timestamp: 2025-11-29T04:34:42.033Z
Learning: Maintain all AI assistant instructions, documentation, and operational guidance in AGENTS.md as the single source of truth

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2026-01-06T15:57:56.008Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-06T15:57:56.008Z
Learning: Applies to **/AGENTS.md : Limit root AGENTS.md to ~50-100 max instructions with universal applicability to >80% of tasks

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2026-01-06T15:57:56.007Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-06T15:57:56.007Z
Learning: Applies to **/.agent/scripts/linters-local.sh : Run quality checks before committing using .agent/scripts/linters-local.sh

Applied to files:

  • .agent/AGENTS.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (15)
.agent/workflows/worktree.md (1)

1-394: Documentation is comprehensive and clear.

The worktree.md file provides excellent coverage: problem statement, practical patterns, detailed commands, troubleshooting, and best practices. The directory structure examples, workflow patterns, and comparison table will help developers quickly adopt git worktrees. Navigation and references to related workflows are clean.

.agent/workflows/git-workflow.md (1)

62-80: Integration looks solid.

The new Git Worktrees section fits naturally into the Parallel Session Safety guidance. The section appropriately references the detailed worktree.md without duplicating it, and the commands shown are practical entry points for developers discovering worktrees.

.agent/AGENTS.md (4)

259-259: List is clear and complete.

The workflows/ folder description now includes both new workflow types (ralph-loop, worktree). The additions fit naturally into the comma-separated list and are discoverable for users reading the subagent folders section.


356-356: Script entry follows established patterns.

The ralph-loop-helper.sh entry integrates well into the Key Scripts table with clear, concise description. The script is referenced in the PR summary and should be part of this PR's deliverables.

Confirm that .agent/scripts/ralph-loop-helper.sh is present in the PR files and matches the description provided here.


427-427: Routing entry is consistent and complete.

The "Iterative AI loops" entry in Development Workflows ensures users discovering the need for iterative development will be routed to workflows/ralph-loop.md. Combined with the listing on line 259, ralph-loop is now discoverable through multiple pathways in AGENTS.md.


1-428: Cross-file consistency is strong.

The modifications across all three files maintain consistent:

  • Script paths (worktree-helper.sh, ralph-loop-helper.sh)
  • Workflow references (worktree.md, ralph-loop.md)
  • Documentation structure and naming conventions
  • Progressive disclosure patterns (quick-ref → detailed guides)

All changes integrate cohesively with existing documentation structure. The main consideration is the optional deduplication of worktree guidance mentioned in the earlier comment.

.agent/scripts/worktree-helper.sh (9)

1-40: LGTM! Strong foundation with strict mode.

The script header properly enables set -euo pipefail for robust error handling, and the color constants enhance user experience. The shellcheck directives are appropriate for this use case.


42-56: LGTM! Clean helper functions with appropriate error handling.

These functions correctly handle the case when not in a Git repository by returning empty strings, allowing callers to validate state.


58-63: LGTM! Correctly distinguishes main from linked worktrees.

The logic properly identifies main worktrees (where .git is a directory) versus linked worktrees (where .git is a file). The dual path check handles both relative and absolute path scenarios.


65-81: LGTM! Sensible path generation pattern.

The function creates consistent, predictable worktree paths by converting branch names to filesystem-safe slugs. The pattern keeps worktrees organized alongside the main repository.


105-170: LGTM! Excellent validation and user guidance.

The function thoroughly validates inputs and provides clear, actionable feedback. The duplicate worktree detection (lines 122-131) prevents conflicts, and the helpful output includes multiple editor options for the user's convenience.


222-266: LGTM! Strong safety checks prevent accidental removal.

The function properly prevents removing the main worktree or the currently active worktree, and flexibly accepts either path or branch name as input. Good defensive programming.


268-304: LGTM! Clear and informative status reporting.

The function provides comprehensive worktree information with proper formatting and helpful guidance for users.


306-332: LGTM! Smart delegation and user guidance.

The function efficiently reuses cmd_add for worktree creation and provides clear instructions for switching to the worktree.


398-493: LGTM! Comprehensive help and clean command routing.

The help text provides excellent documentation, and the main dispatcher includes useful command aliases (ls, rm, st, sw) for improved user experience. Unknown command handling is appropriate.

Comment on lines 334 to 396
cmd_clean() {
echo -e "${BOLD}Checking for worktrees with merged branches...${NC}"
echo ""

local found_any=false
local worktree_path=""
local worktree_branch=""

while IFS= read -r line; do
if [[ "$line" =~ ^worktree\ (.+)$ ]]; then
worktree_path="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^branch\ refs/heads/(.+)$ ]]; then
worktree_branch="${BASH_REMATCH[1]}"
elif [[ -z "$line" ]]; then
# End of entry, check if merged
if [[ -n "$worktree_branch" ]] && [[ "$worktree_branch" != "main" ]] && [[ "$worktree_branch" != "master" ]]; then
if git branch --merged main 2>/dev/null | grep -q "^\s*$worktree_branch$"; then
found_any=true
echo -e " ${YELLOW}$worktree_branch${NC} (merged)"
echo " $worktree_path"
echo ""
fi
fi
worktree_path=""
worktree_branch=""
fi
done < <(git worktree list --porcelain; echo "")

if [[ "$found_any" == "false" ]]; then
echo -e "${GREEN}No merged worktrees to clean up${NC}"
return 0
fi

echo ""
echo -e "${YELLOW}Remove these worktrees? [y/N]${NC}"
read -r response

if [[ "$response" =~ ^[Yy]$ ]]; then
# Re-iterate and remove
while IFS= read -r line; do
if [[ "$line" =~ ^worktree\ (.+)$ ]]; then
worktree_path="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^branch\ refs/heads/(.+)$ ]]; then
worktree_branch="${BASH_REMATCH[1]}"
elif [[ -z "$line" ]]; then
if [[ -n "$worktree_branch" ]] && [[ "$worktree_branch" != "main" ]] && [[ "$worktree_branch" != "master" ]]; then
if git branch --merged main 2>/dev/null | grep -q "^\s*$worktree_branch$"; then
echo -e "${BLUE}Removing $worktree_branch...${NC}"
git worktree remove "$worktree_path" 2>/dev/null || true
fi
fi
worktree_path=""
worktree_branch=""
fi
done < <(git worktree list --porcelain; echo "")

echo -e "${GREEN}Cleanup complete${NC}"
else
echo "Cancelled"
fi

return 0
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Two robustness concerns: hardcoded branch and silent error suppression.

  1. Lines 350 and 380 hardcode "main" as the base branch (same issue as cmd_list).
  2. Line 382 suppresses removal errors with || true, potentially hiding failures that users should know about.
🔧 Proposed fixes

Fix 1: Use dynamic default branch detection (apply same fix as suggested for cmd_list)

+    local default_branch
+    default_branch=$(get_default_branch)
+
     echo -e "${BOLD}Checking for worktrees with merged branches...${NC}"

Then replace both occurrences:

-                if git branch --merged main 2>/dev/null | grep -q "^\s*$worktree_branch$"; then
+                if git branch --merged "$default_branch" 2>/dev/null | grep -q "^\s*$worktree_branch$"; then

Fix 2: Log removal failures instead of silencing

-                        git worktree remove "$worktree_path" 2>/dev/null || true
+                        if ! git worktree remove "$worktree_path" 2>&1; then
+                            echo -e "${RED}Warning: Failed to remove $worktree_path${NC}"
+                        fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cmd_clean() {
echo -e "${BOLD}Checking for worktrees with merged branches...${NC}"
echo ""
local found_any=false
local worktree_path=""
local worktree_branch=""
while IFS= read -r line; do
if [[ "$line" =~ ^worktree\ (.+)$ ]]; then
worktree_path="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^branch\ refs/heads/(.+)$ ]]; then
worktree_branch="${BASH_REMATCH[1]}"
elif [[ -z "$line" ]]; then
# End of entry, check if merged
if [[ -n "$worktree_branch" ]] && [[ "$worktree_branch" != "main" ]] && [[ "$worktree_branch" != "master" ]]; then
if git branch --merged main 2>/dev/null | grep -q "^\s*$worktree_branch$"; then
found_any=true
echo -e " ${YELLOW}$worktree_branch${NC} (merged)"
echo " $worktree_path"
echo ""
fi
fi
worktree_path=""
worktree_branch=""
fi
done < <(git worktree list --porcelain; echo "")
if [[ "$found_any" == "false" ]]; then
echo -e "${GREEN}No merged worktrees to clean up${NC}"
return 0
fi
echo ""
echo -e "${YELLOW}Remove these worktrees? [y/N]${NC}"
read -r response
if [[ "$response" =~ ^[Yy]$ ]]; then
# Re-iterate and remove
while IFS= read -r line; do
if [[ "$line" =~ ^worktree\ (.+)$ ]]; then
worktree_path="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^branch\ refs/heads/(.+)$ ]]; then
worktree_branch="${BASH_REMATCH[1]}"
elif [[ -z "$line" ]]; then
if [[ -n "$worktree_branch" ]] && [[ "$worktree_branch" != "main" ]] && [[ "$worktree_branch" != "master" ]]; then
if git branch --merged main 2>/dev/null | grep -q "^\s*$worktree_branch$"; then
echo -e "${BLUE}Removing $worktree_branch...${NC}"
git worktree remove "$worktree_path" 2>/dev/null || true
fi
fi
worktree_path=""
worktree_branch=""
fi
done < <(git worktree list --porcelain; echo "")
echo -e "${GREEN}Cleanup complete${NC}"
else
echo "Cancelled"
fi
return 0
}
cmd_clean() {
echo -e "${BOLD}Checking for worktrees with merged branches...${NC}"
echo ""
local found_any=false
local worktree_path=""
local worktree_branch=""
while IFS= read -r line; do
if [[ "$line" =~ ^worktree\ (.+)$ ]]; then
worktree_path="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^branch\ refs/heads/(.+)$ ]]; then
worktree_branch="${BASH_REMATCH[1]}"
elif [[ -z "$line" ]]; then
# End of entry, check if merged
if [[ -n "$worktree_branch" ]] && [[ "$worktree_branch" != "main" ]] && [[ "$worktree_branch" != "master" ]]; then
if git branch --merged main 2>/dev/null | grep -q "^\s*$worktree_branch$"; then
found_any=true
echo -e " ${YELLOW}$worktree_branch${NC} (merged)"
echo " $worktree_path"
echo ""
fi
fi
worktree_path=""
worktree_branch=""
fi
done < <(git worktree list --porcelain; echo "")
if [[ "$found_any" == "false" ]]; then
echo -e "${GREEN}No merged worktrees to clean up${NC}"
return 0
fi
echo ""
echo -e "${YELLOW}Remove these worktrees? [y/N]${NC}"
read -r response
if [[ "$response" =~ ^[Yy]$ ]]; then
# Re-iterate and remove
while IFS= read -r line; do
if [[ "$line" =~ ^worktree\ (.+)$ ]]; then
worktree_path="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^branch\ refs/heads/(.+)$ ]]; then
worktree_branch="${BASH_REMATCH[1]}"
elif [[ -z "$line" ]]; then
if [[ -n "$worktree_branch" ]] && [[ "$worktree_branch" != "main" ]] && [[ "$worktree_branch" != "master" ]]; then
if git branch --merged main 2>/dev/null | grep -q "^\s*$worktree_branch$"; then
echo -e "${BLUE}Removing $worktree_branch...${NC}"
if ! git worktree remove "$worktree_path" 2>&1; then
echo -e "${RED}Warning: Failed to remove $worktree_path${NC}"
fi
fi
fi
worktree_path=""
worktree_branch=""
fi
done < <(git worktree list --porcelain; echo "")
echo -e "${GREEN}Cleanup complete${NC}"
else
echo "Cancelled"
fi
return 0
}

Uses git rev-parse --git-common-dir to resolve the main repo name
even when working in a linked worktree directory.
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 171 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Jan 8 22:34:46 UTC 2026: Code review monitoring started
Thu Jan 8 22:34:46 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 171
Thu Jan 8 22:34:46 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Thu Jan 8 22:34:48 UTC 2026: Codacy analysis completed with auto-fixes
Thu Jan 8 22:34:49 UTC 2026: Applied 2 automatic fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 171
  • VULNERABILITIES: 0

Generated on: Thu Jan 8 22:35:22 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.agent/scripts/terminal-title-helper.sh:
- Around line 134-152: The get_repo_name function fails in subdirectories
because git_common_dir can be a relative path; fix by converting git_common_dir
to an absolute directory before calling dirname/basename: after obtaining
git_common_dir in get_repo_name, cd into its directory (or use pushd) and use
pwd -P to get the absolute path (resolving symlinks), then compute
repo_path=$(dirname "$absolute_git_common_dir") or simply use the absolute
parent path for basename; remove the fragile fallback that checks for "." so the
function reliably returns the repository name from any subdirectory or worktree.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78a4b36 and dc06bba.

📒 Files selected for processing (1)
  • .agent/scripts/terminal-title-helper.sh
🧰 Additional context used
📓 Path-based instructions (1)
.agent/scripts/*.sh

⚙️ CodeRabbit configuration file

.agent/scripts/*.sh: Automation scripts - focus on:

  • Reliability and robustness
  • Clear logging and feedback
  • Proper exit codes
  • Error recovery mechanisms

Files:

  • .agent/scripts/terminal-title-helper.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis

- Use mktemp for safe temp file creation in increment_iteration
- Add Perl dependency check before promise extraction
- Fix aider duplicate prompt by using --message only (not stdin pipe)
- Add --yes flag to aider for non-interactive mode
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 171 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Jan 8 23:32:47 UTC 2026: Code review monitoring started
Thu Jan 8 23:32:47 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 171
Thu Jan 8 23:32:48 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Thu Jan 8 23:32:50 UTC 2026: Codacy analysis completed with auto-fixes
Thu Jan 8 23:32:50 UTC 2026: Applied 2 automatic fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 171
  • VULNERABILITIES: 0

Generated on: Thu Jan 8 23:33:25 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.agent/scripts/ralph-loop-helper.sh:
- Around line 519-534: The case branches for tools (opencode, claude, aider)
currently append "|| true" which hides failures; remove "|| true", run each
command while capturing its exit code ($?), and if non-zero call print_error
with a descriptive message including the tool name and exit code (and optionally
stderr via the output_file), then return 1 (fail-fast) or continue with a
warning depending on expected behavior; also ensure the aider branch still uses
--message "$full_prompt" (not stdin) and that the redirection to "$output_file"
captures stderr (e.g., > "$output_file" 2>&1) before checking the exit code so
missing binaries/permission/runtime errors are detected.
- Around line 434-518: The run_external_loop function currently does not verify
the requested tool exists before starting iterations; add a pre-loop validation
immediately after argument parsing (before creating output_file / trap) that
checks the tool executable (e.g., using command -v "$tool" >/dev/null 2>&1 or
test -x for a path) and calls print_error and returns non-zero if not found, so
the loop never starts with a missing binary; reference the run_external_loop
function and the local variable tool when implementing this check.
🧹 Nitpick comments (1)
.agent/scripts/ralph-loop-helper.sh (1)

153-254: Consider extracting duplicated argument parsing logic.

The argument parsing pattern for --max-iterations and --completion-promise is duplicated between setup_loop and run_external_loop (lines 441-477). While not critical, extracting this into a shared helper function would improve maintainability.

♻️ Optional refactor to reduce duplication

Create a shared argument parser:

parse_ralph_options() {
    local -n _max_iter=$1
    local -n _completion=$2
    local -n _remaining=$3
    
    while [[ $# -gt 3 ]]; do
        case $4 in
            --max-iterations)
                if [[ -z "${5:-}" ]]; then
                    print_error "--max-iterations requires a number argument"
                    return 1
                fi
                if ! [[ "$5" =~ ^[0-9]+$ ]]; then
                    print_error "--max-iterations must be a positive integer, got: $5"
                    return 1
                fi
                _max_iter="$5"
                shift 5 || return 0
                ;;
            --completion-promise)
                if [[ -z "${5:-}" ]]; then
                    print_error "--completion-promise requires a text argument"
                    return 1
                fi
                _completion="$5"
                shift 5 || return 0
                ;;
            *)
                _remaining+=("$4")
                shift 4 || return 0
                ;;
        esac
    done
}

Then use it in both functions to eliminate the duplication.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc06bba and 3297ffc.

📒 Files selected for processing (1)
  • .agent/scripts/ralph-loop-helper.sh
🧰 Additional context used
📓 Path-based instructions (1)
.agent/scripts/*.sh

⚙️ CodeRabbit configuration file

.agent/scripts/*.sh: Automation scripts - focus on:

  • Reliability and robustness
  • Clear logging and feedback
  • Proper exit codes
  • Error recovery mechanisms

Files:

  • .agent/scripts/ralph-loop-helper.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (9)
.agent/scripts/ralph-loop-helper.sh (9)

1-19: LGTM! Excellent error handling foundation.

The set -euo pipefail ensures the script exits on errors, unset variables, and pipeline failures, which is critical for reliability in automation scripts.


21-34: LGTM! Proper use of readonly constants.

The readonly declarations prevent accidental modification of critical paths and color codes throughout the script execution.


40-78: LGTM! Clear and consistent logging helpers.

The color-coded print functions with appropriate stderr/stdout routing provide excellent user feedback, which aligns with the "clear logging and feedback" requirement.


260-273: LGTM! Graceful error handling.

The function handles missing state files and corrupted iteration values elegantly with appropriate fallbacks.


320-349: LGTM! Proper dependency checking added.

The Perl dependency check (line 331) and warning message provide clear feedback when the required tool is missing. The fallback to NOT_COMPLETE is reasonable given the warning context.


355-380: LGTM! Safe temporary file handling.

The use of mktemp with explicit error handling (line 374) and portable sed pattern (avoiding -i flag) ensures cross-platform compatibility and safe atomic updates.


386-427: LGTM! Consistent getter interface with sensible defaults.

The functions return appropriate defaults when the state file is missing, preventing errors in calling code.


560-608: LGTM! Clean command dispatcher with proper error handling.

The case-based dispatcher handles all defined commands, provides appropriate help, and returns proper exit codes for unknown commands.


610-610: LGTM! Standard main invocation pattern.

ralph-loop-helper.sh:
- Add tool availability check before starting loop
- Replace || true with proper exit code capture and logging
- Log tool failures but continue loop (AI tools may exit non-zero)

terminal-title-helper.sh:
- Convert git-common-dir to absolute path for subdirectory support
- Use realpath with cd/pwd fallback for portability

worktree-helper.sh:
- Add get_default_branch() to detect main/master dynamically
- Replace hardcoded 'main' with default branch detection
- Support repos using 'master' or custom default branches
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 171 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Jan 8 23:43:09 UTC 2026: Code review monitoring started
Thu Jan 8 23:43:09 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 171
Thu Jan 8 23:43:10 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Thu Jan 8 23:43:12 UTC 2026: Codacy analysis completed with auto-fixes
Thu Jan 8 23:43:12 UTC 2026: Applied 2 automatic fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 171
  • VULNERABILITIES: 0

Generated on: Thu Jan 8 23:43:44 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
.agent/scripts/worktree-helper.sh (2)

59-78: Hardcoded remote name reduces robustness.

Line 62 assumes the remote is named origin. Repositories with differently named remotes (e.g., upstream, custom names) will skip the symbolic-ref detection and fall back to the local branch checks. While the fallback chain ensures the function still returns a value, the primary detection method is less robust than it could be.

💡 Optional enhancement to detect default remote dynamically
 get_default_branch() {
     # Try to get from remote HEAD
     local default_branch
-    default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
+    # Detect the default remote (usually origin, but could be different)
+    local default_remote
+    default_remote=$(git remote | head -1)
+    if [[ -n "$default_remote" ]]; then
+        default_branch=$(git symbolic-ref "refs/remotes/${default_remote}/HEAD" 2>/dev/null | sed "s@^refs/remotes/${default_remote}/@@")
+    fi
     
     if [[ -n "$default_branch" ]]; then
         echo "$default_branch"

398-420: Error suppression reduces transparency.

Line 409 uses || true to silence failures from git worktree remove, which prevents users from seeing why a removal might have failed (uncommitted changes, locked worktree, permission issues, etc.). While this ensures the loop continues, it provides no feedback when individual removals fail.

♻️ Enhanced error handling with user feedback
         if [[ "$response" =~ ^[Yy]$ ]]; then
+            local failed_count=0
+            local success_count=0
             # Re-iterate and remove
             while IFS= read -r line; do
                 if [[ "$line" =~ ^worktree\ (.+)$ ]]; then
                     worktree_path="${BASH_REMATCH[1]}"
                 elif [[ "$line" =~ ^branch\ refs/heads/(.+)$ ]]; then
                     worktree_branch="${BASH_REMATCH[1]}"
                 elif [[ -z "$line" ]]; then
                     if [[ -n "$worktree_branch" ]] && [[ "$worktree_branch" != "$default_branch" ]]; then
                         if git branch --merged "$default_branch" 2>/dev/null | grep -q "^\s*$worktree_branch$"; then
                             echo -e "${BLUE}Removing $worktree_branch...${NC}"
-                            git worktree remove "$worktree_path" 2>/dev/null || true
+                            if git worktree remove "$worktree_path" 2>&1; then
+                                ((success_count++))
+                            else
+                                echo -e "${YELLOW}  Failed to remove (may have uncommitted changes)${NC}"
+                                ((failed_count++))
+                            fi
                         fi
                     fi
                     worktree_path=""
                     worktree_branch=""
                 fi
             done < <(git worktree list --porcelain; echo "")
             
-            echo -e "${GREEN}Cleanup complete${NC}"
+            echo ""
+            echo -e "${GREEN}Cleanup complete${NC}"
+            if [[ $success_count -gt 0 ]]; then
+                echo -e "  Removed: $success_count worktree(s)"
+            fi
+            if [[ $failed_count -gt 0 ]]; then
+                echo -e "  ${YELLOW}Failed: $failed_count worktree(s)${NC}"
+            fi
         else
             echo "Cancelled"
         fi
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3297ffc and 66f2815.

📒 Files selected for processing (3)
  • .agent/scripts/ralph-loop-helper.sh
  • .agent/scripts/terminal-title-helper.sh
  • .agent/scripts/worktree-helper.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • .agent/scripts/ralph-loop-helper.sh
🧰 Additional context used
📓 Path-based instructions (1)
.agent/scripts/*.sh

⚙️ CodeRabbit configuration file

.agent/scripts/*.sh: Automation scripts - focus on:

  • Reliability and robustness
  • Clear logging and feedback
  • Proper exit codes
  • Error recovery mechanisms

Files:

  • .agent/scripts/worktree-helper.sh
  • .agent/scripts/terminal-title-helper.sh
🧠 Learnings (1)
📚 Learning: 2025-12-22T01:24:53.937Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/AGENTS.md:0-0
Timestamp: 2025-12-22T01:24:53.937Z
Learning: Follow all security protocols and working directory specifications defined in ~/Git/aidevops/AGENTS.md

Applied to files:

  • .agent/scripts/terminal-title-helper.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (6)
.agent/scripts/worktree-helper.sh (6)

127-192: Excellent safety checks and user feedback.

The cmd_add function demonstrates robust error handling with multiple validation layers: branch parameter check, git repo verification, existing worktree detection, and path conflict prevention. The comprehensive success message with usage examples (lines 177-190) provides excellent user experience.


194-244: Well-structured porcelain format parser.

The state machine approach (lines 206-241) correctly handles git's porcelain output with clear state transitions. The merged-branch detection (lines 224-230) integrates well with get_default_branch(), and visual markers provide good UX. Porcelain format is designed to be stable, so this parsing approach is appropriate.


246-290: Strong safety guardrails prevent common mistakes.

The defensive checks for main worktree removal (lines 270-276) and in-worktree removal prevention (lines 278-283) demonstrate careful attention to user safety. The dual resolution of target by path or branch name (lines 255-268) provides good flexibility.


292-328: Comprehensive status reporting.

The status command provides excellent visibility into the current worktree context, including type detection (main vs linked) and helpful guidance to list all worktrees when multiple exist.


330-356: Smart switch command with auto-creation.

The switch command elegantly handles both existing worktrees (display path) and missing ones (delegate to add), providing a seamless user experience for quick branch context switching.


425-480: Outstanding documentation and examples.

The embedded help provides comprehensive coverage of commands, usage patterns, directory structure explanation, and important notes. The examples (lines 452-465) are practical and immediately actionable.

Separate realpath and cd/pwd into distinct steps with explicit
empty check, ensuring failure propagates correctly if both fail.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 8, 2026

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 171 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Jan 8 23:48:47 UTC 2026: Code review monitoring started
Thu Jan 8 23:48:47 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 171
Thu Jan 8 23:48:48 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Thu Jan 8 23:48:50 UTC 2026: Codacy analysis completed with auto-fixes
Thu Jan 8 23:48:50 UTC 2026: Applied 2 automatic fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 171
  • VULNERABILITIES: 0

Generated on: Thu Jan 8 23:49:22 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@marcusquinn marcusquinn merged commit f339313 into main Jan 9, 2026
9 checks passed
@marcusquinn marcusquinn deleted the feature/ralph-loop-plugin branch January 9, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant