-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Ralph Loop iterative AI development workflows #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
WalkthroughAdds 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
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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
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. Comment |
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Jan 8 18:41:57 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
🤖 Augment PR SummarySummary: Adds “Ralph Loop” iterative AI workflows to make autonomous, self-referential development loops first-class in aidevops. Changes:
Technical Notes: Loop state is stored under 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| # Check 1: ShellCheck | ||
| print_info " Checking ShellCheck..." | ||
| if find .agent/scripts -name "*.sh" -exec shellcheck {} \; >/dev/null 2>&1; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print_info "=== PR Review Iteration $iteration / $max_iterations ===" | ||
|
|
||
| local status | ||
| status=$(check_pr_status "$pr_number" "$wait_for_ci") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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.$$" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| iteration=$(increment_iteration) | ||
|
|
||
| if [[ $iteration -le $max_iterations ]]; then | ||
| local wait_time=$((monitor_duration / max_iterations)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| local wait_time=$((monitor_duration / max_iterations)) | |
| local wait_time=$((monitor_duration / max_iterations)); [[ $wait_time -lt 1 ]] && wait_time=1 |
.agent/scripts/ralph-loop-helper.sh
Outdated
| local next_iteration=$((current_iteration + 1)) | ||
|
|
||
| # Update iteration in frontmatter (portable across macOS and Linux) | ||
| local temp_file="${RALPH_STATE_FILE}.tmp.$$" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| script_dir="$(dirname "$0")" | |
| script_dir="$(cd \"$(dirname \"${BASH_SOURCE[0]}\")\" && pwd)" |
There was a problem hiding this 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-intervaloption 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
📒 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 pipefailandreadonlyconstants. 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
>&2redirection 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-iterationsrequiring a numeric value and--completion-promiserequiring 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 propermvfor 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 || trueto handle missing arguments gracefully.
285-307: Perl dependency for multiline regex extraction.The
check_completionfunction 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_passedandchecks_failedare initialized as empty arrays for future tracking.
102-128: State management functions are solid.The
update_stateandget_state_fieldfunctions 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_fixesto track applied fixes provides good observability. The|| trueensures 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 andhead -10/head -20to 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
vprefix and bare versions.
740-772: Main function routing is clean and complete.All documented commands are handled with proper help fallback. The
pralias forpr-reviewis 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 || truepattern ensures this never interrupts the main update check flow.
64-67: Good placement of Ralph upstream check.Calling
check_ralph_upstreamafter 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-loopaddition to the workflows list is consistent with the new.agent/workflows/ralph-loop.mdfile.
340-340: Key scripts documentation updated correctly.The
ralph-loop-helper.shentry 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-iterationsand--completion-promiseflags as implemented inralph-loop-helper.sh.
97-126: State file documentation matches implementation.The YAML frontmatter structure documented here matches exactly what
setup_loop()creates inralph-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 -sfflags 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
--forceflag 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-taskcommand 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 fromquality-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-purposeralph-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-durationoption 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.
| 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 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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)
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Jan 8 19:50:51 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this 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_FILEcould leave a corrupted state if interrupted mid-write (e.g., Ctrl+C, system crash). For improved reliability, write to a temporary file first, then usemvfor 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
📒 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
mktempfor 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 || truepattern 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.
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Jan 8 22:15:07 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this 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 -Fwith-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
📒 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.shentry 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.shis 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 pipefailfor 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
.gitis a directory) versus linked worktrees (where.gitis 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_addfor 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.
| 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 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two robustness concerns: hardcoded branch and silent error suppression.
- Lines 350 and 380 hardcode "main" as the base branch (same issue as
cmd_list). - 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$"; thenFix 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.
| 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.
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Jan 8 22:35:22 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this 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
📒 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
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Jan 8 23:33:25 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this 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-iterationsand--completion-promiseis duplicated betweensetup_loopandrun_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
📒 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 pipefailensures 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_COMPLETEis reasonable given the warning context.
355-380: LGTM! Safe temporary file handling.The use of
mktempwith explicit error handling (line 374) and portablesedpattern (avoiding-iflag) 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
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Jan 8 23:43:44 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this 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
|| trueto silence failures fromgit 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
📒 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_addfunction 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.
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Jan 8 23:49:22 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |



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 documentationscripts/ralph-loop-helper.sh- Cross-tool helper script with state management/ralph-loop,/cancel-ralph,/ralph-statusUpstream Sync
scripts/ralph-upstream-check.sh- Compare against Claude plugin for updatesQuality 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
workflows/plans.md#ralphtag for autonomous tasksralph-promise,ralph-verify,ralph-max/ralph-taskcommand to run tasks from TODO.md by IDNew Quality Workflow
Ralph Task Format
Testing
Summary by CodeRabbit
New Features
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.