Skip to content

docs: add feature branch scenario guidance to pre-edit workflow#148

Merged
marcusquinn merged 1 commit intomainfrom
feature/agent-workflow-compliance-docs
Jan 21, 2026
Merged

docs: add feature branch scenario guidance to pre-edit workflow#148
marcusquinn merged 1 commit intomainfrom
feature/agent-workflow-compliance-docs

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Jan 21, 2026

Summary

  • Add exit code 3 for 'on feature branch in main repo' scenario
  • Update AGENTS.md with table of exit codes and required actions
  • Add guidance for when already on a feature branch (not just main → feature)

Problem

The agent review identified that the workflow documentation didn't clearly address:

  • What to do when already on a feature branch
  • Whether personal development branches should be treated differently
  • Whether small tasks warrant their own worktree/branch

Solution

  1. New exit code 3: Distinguishes "on feature branch in main repo" from "on main" (exit 1)
  2. AGENTS.md updates:
    • Table of all exit codes with required actions
    • Feature branch scenarios section explaining when warnings appear
    • Small tasks exception for quick fixes on current branch
  3. Script updates:
    • Loop mode handles feature branch scenarios
    • Interactive mode presents numbered options for feature branch warnings

Testing

  • ShellCheck passes on modified script
  • Script correctly identifies worktree vs main repo
  • Exit codes work as documented

Summary by CodeRabbit

Release Notes

  • Documentation

    • Expanded pre-edit git check guidelines with detailed exit code handling and comprehensive scenario-based workflows
    • Added interactive prompts and user options for branch validation
    • Introduced manual fallback procedures and self-verification guidance
  • Enhancement

    • Improved branch validation workflow with clearer error handling and explicit user decision points

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

- Add exit code 3 for 'on feature branch in main repo' scenario
- Update AGENTS.md with table of exit codes and required actions
- Add guidance for when already on a feature branch (not just main → feature)
- Document why feature branches in main repo are problematic
- Add small tasks exception for quick fixes on current branch
- Update loop mode to handle feature branch scenarios

Addresses agent review finding that workflow didn't clearly address:
- What to do when already on a feature branch
- Whether personal dev branches should be treated differently
- Whether small tasks warrant their own worktree/branch
@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 improves the pre-edit-check.sh workflow by providing clearer guidance and automated handling for scenarios where developers are working on feature branches directly within the main repository. It aims to prevent common issues arising from not using Git worktrees for feature development, thereby promoting safer and more efficient development practices, especially for AI agents interacting with the codebase.

Highlights

  • New Exit Code for Feature Branches: Introduced a new exit code (3) for the pre-edit-check.sh script, specifically for when a user is on a feature branch within the main repository, indicating a potential workflow issue.
  • Enhanced Documentation for Agents: Enhanced AGENTS.md documentation with a comprehensive table of all script exit codes (0, 1, 2, 3) and their corresponding required actions for AI agents, improving clarity on how to respond to different script outcomes.
  • Detailed Feature Branch Guidance: Added detailed guidance in AGENTS.md for handling feature branch scenarios, including the rationale for using worktrees, explanations of when warnings appear, and an exception for small, quick fixes that might not warrant a separate worktree.
  • Script Logic Updates: Updated the pre-edit-check.sh script to implement the new exit code 3 logic, providing distinct behaviors for loop mode (auto-decision for docs-only or warning for code tasks) and interactive mode (presenting user with options to create a worktree, continue, or switch main back).
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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Walkthrough

Enhanced pre-edit-check workflow with expanded exit code semantics and interactive prompts. The documentation clarifies a four-code system (0, 1, 2, 3) with explicit handling rules; the script implements multi-mode logic for feature branches and worktrees with conditional user prompts and state-based decisions.

Changes

Cohort / File(s) Summary
Documentation Expansion
.agent/AGENTS.md
Replaced single-line "STOP - ON PROTECTED BRANCH" rule with comprehensive exit code table (0–3). Added explicit prompts for EXIT 3, manual check workflow, feature-branch scenarios, self-verification guidance, and tool-level enforcement sections to structure interactive edit workflows.
Script Logic Enhancement
.agent/scripts/pre-edit-check.sh
Implemented multi-mode stateful flow: docs-only tasks auto-continue with LOOP_DECISION (exit 0); code tasks emit warning with interactive options (exit 3); new worktree-creation path (exit 2). Replaced simple warning output with structured prompts and exit code semantics mapped to user decisions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🌿 A branch awaits, a choice to make—
Check thy path before the edit's break,
Exit codes now speak with gentle grace,
User prompts guide toward the safest place. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding feature branch scenario guidance to the pre-edit workflow documentation and script. It accurately reflects the primary intent of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@sonarqubecloud
Copy link

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 significantly improves the pre-edit check workflow by adding specific handling for scenarios where development is happening on a feature branch within the main repository, rather than a dedicated worktree. The introduction of exit code 3 and the detailed updates to AGENTS.md provide clear guidance for both automated agents and interactive users, which is a great enhancement. The script changes correctly implement this new logic. I have one minor suggestion to improve code maintainability in the shell script.

Comment on lines +173 to +184
if [[ "$LOOP_MODE" == "true" ]]; then
if is_docs_only "$TASK_DESC"; then
echo -e "${YELLOW}LOOP-AUTO${NC}: Docs-only task on feature branch, continuing"
echo "LOOP_DECISION=continue"
exit 0
else
# For code tasks, warn but continue (already on feature branch)
echo -e "${YELLOW}LOOP-AUTO${NC}: On feature branch in main repo (not ideal but continuing)"
echo "LOOP_DECISION=continue_warning"
exit 0
fi
fi

Choose a reason for hiding this comment

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

medium

For better maintainability, you can refactor this block to avoid duplicating the exit 0 call. Since both branches of the if is_docs_only conditional lead to an exit 0, you can move the exit statement outside and after the conditional.

Suggested change
if [[ "$LOOP_MODE" == "true" ]]; then
if is_docs_only "$TASK_DESC"; then
echo -e "${YELLOW}LOOP-AUTO${NC}: Docs-only task on feature branch, continuing"
echo "LOOP_DECISION=continue"
exit 0
else
# For code tasks, warn but continue (already on feature branch)
echo -e "${YELLOW}LOOP-AUTO${NC}: On feature branch in main repo (not ideal but continuing)"
echo "LOOP_DECISION=continue_warning"
exit 0
fi
fi
if [[ "$LOOP_MODE" == "true" ]]; then
if is_docs_only "$TASK_DESC"; then
echo -e "${YELLOW}LOOP-AUTO${NC}: Docs-only task on feature branch, continuing"
echo "LOOP_DECISION=continue"
else
# For code tasks, warn but continue (already on feature branch)
echo -e "${YELLOW}LOOP-AUTO${NC}: On feature branch in main repo (not ideal but continuing)"
echo "LOOP_DECISION=continue_warning"
fi
exit 0
fi

@github-actions
Copy link

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Wed Jan 21 22:59:21 UTC 2026: Code review monitoring started
Wed Jan 21 22:59:21 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 353
Wed Jan 21 22:59:21 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Wed Jan 21 22:59:23 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 353
  • VULNERABILITIES: 0

Generated on: Wed Jan 21 23:00:37 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@augmentcode
Copy link

augmentcode bot commented Jan 21, 2026

🤖 Augment PR Summary

Summary: This PR clarifies and extends the “pre-edit” git-branch workflow, especially when the main repo is already on a feature branch.

Changes:

  • Expanded .agent/AGENTS.md with an exit-code table (0–3) and explicit required agent actions.
  • Added guidance for feature-branch scenarios (main repo vs worktree) plus a small-task exception for continuing on the current branch.
  • Updated .agent/scripts/pre-edit-check.sh to emit exit code 3 in interactive mode for “main repo on feature branch”, while keeping loop-mode behavior non-blocking.

Technical Notes: Interactive mode exposes FEATURE_BRANCH_WARNING, and loop mode emits LOOP_DECISION to drive 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. 2 suggestions posted.

Fix All in Augment

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

| `0` | OK to proceed | Continue with edits |
| `1` | On protected branch (main/master) | STOP - present branch creation options |
| `2` | Loop mode: worktree needed | Auto-create worktree for code task |
| `3` | On feature branch in main repo | Present options to user (see below) |
Copy link

Choose a reason for hiding this comment

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

Exit code 3 is documented as the generic “feature branch in main repo” case, but pre-edit-check.sh --loop-mode currently exits 0 (with LOOP_DECISION=continue_warning) for that same scenario. Consider clarifying in the docs that exit 3 only occurs in interactive mode, so loop agents don’t incorrectly key off exit code alone.

Other Locations
  • .agent/AGENTS.md:76

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

# Exit codes:
# 0 - OK to proceed (on feature branch, or docs-only on main in loop mode)
# 1 - STOP (on protected branch, interactive mode)
# 0 - OK to proceed (on feature branch in worktree, or docs-only on main)
Copy link

Choose a reason for hiding this comment

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

The exit-code comment for 0 (“OK to proceed …”) doesn’t include the loop-mode case where you’re on a feature branch in the main repo and still exit 0 (via LOOP_DECISION=continue_warning). Consider updating the header comment to reflect that 0 can also mean “continue with warning” in loop mode.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

@marcusquinn marcusquinn merged commit bf1ad1d into main Jan 21, 2026
17 checks passed
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