Skip to content

chore: add worktree setup template + sync CHANGELOG#163

Merged
ANcpLua merged 1 commit intomainfrom
chore/worktree-template
Mar 7, 2026
Merged

chore: add worktree setup template + sync CHANGELOG#163
ANcpLua merged 1 commit intomainfrom
chore/worktree-template

Conversation

@ANcpLua
Copy link
Owner

@ANcpLua ANcpLua commented Mar 7, 2026

Adds tooling/templates/persistent-agent-worktree-setup.md as a reference template for persistent multi-agent worktree setups. Syncs local CHANGELOG edits.

Summary by CodeRabbit

  • Documentation

    • Added reusable prompt template and comprehensive guide for setting up a persistent multi-agent worktree environment with role-specific descriptions and repository architecture constraints.
  • Chores

    • Added automated setup script for managing worktrees with idempotent configuration, conflict detection, and status verification.

Copilot AI review requested due to automatic review settings March 7, 2026 01:27
@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 introduces a valuable resource for developers by providing a comprehensive template for configuring persistent multi-agent worktree environments. This template streamlines the setup process for AI agents like Claude and Codex, ensuring consistency and adherence to architectural constraints. Additionally, the project's changelog has been synchronized to reflect this new addition, improving documentation.

Highlights

  • New Worktree Setup Template: A new template, tooling/templates/persistent-agent-worktree-setup.md, was added to provide a comprehensive reference for setting up persistent multi-agent worktree environments for Claude and Codex, including detailed roles and a setup script.
  • Changelog Update: The CHANGELOG.md file was updated to include an entry for the newly added persistent agent worktree setup template, ensuring documentation is synchronized with the new feature.
Changelog
  • CHANGELOG.md
    • Added a new entry for tooling/templates/persistent-agent-worktree-setup.md, describing it as a reusable prompt template for role-based Claude/Codex worktree setup.
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

coderabbitai bot commented Mar 7, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds documentation for setting up a persistent multi-agent worktree environment, including agent role definitions, repository architecture constraints, and per-worktree configuration specifications. A changelog entry documents the new template resource.

Changes

Cohort / File(s) Summary
Changelog Entry
CHANGELOG.md
Documents the addition of a new reusable prompt template for persistent agent worktree setup.
Agent Worktree Setup Template
tooling/templates/persistent-agent-worktree-setup.md
New documentation template defining six agent roles (collector, generator, schema, investigator, architect, gardener) with scopes and focus areas, repository architecture constraints across three layers, per-worktree configuration requirements, and setup specifications.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 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 accurately describes the main changes: adding a worktree setup template and synchronizing the CHANGELOG.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/worktree-template

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.

@ANcpLua ANcpLua merged commit 145aeb4 into main Mar 7, 2026
13 of 16 checks passed
@ANcpLua ANcpLua deleted the chore/worktree-template branch March 7, 2026 01:29
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2eb0cac54

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

path="$worktrees_dir/$name"
b=$(git -C "$path" rev-parse --abbrev-ref HEAD)
printf "%s | %s | %s\n" "$name" "${status[$name]}" "$path"
printf " AGENTS.md: %s\n" "$( [[ -f \"$path/AGENTS.md\" ]] && echo exists || echo missing )"

Choose a reason for hiding this comment

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

P2 Badge Remove escaped quotes in summary file checks

The file checks in the summary always evaluate to missing because " is used inside a command substitution that is already within double quotes, so the backslashes become part of the [[ -f ... ]] expression and the tested path includes literal quote characters. Running the generated setup-worktrees.sh shows AGENTS.md, CLAUDE.md, and .codex/agent.md as missing even when they were created, which breaks the script’s verification output and can cause false failure triage.

Useful? React with 👍 / 👎.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new reference template under tooling/templates/ describing how to set up persistent multi-agent git worktrees (including a sample setup-worktrees.sh), and updates the root changelog to record the addition.

Changes:

  • Added tooling/templates/persistent-agent-worktree-setup.md (worktree setup template + embedded bash script).
  • Updated CHANGELOG.md to include the new template under [Unreleased] → Added.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
tooling/templates/persistent-agent-worktree-setup.md New worktree setup template + sample script for generating per-worktree instruction files.
CHANGELOG.md Documents the new template in the Unreleased “Added” section.

Comment on lines +32 to +48
- Layer 1: Schema generation
- `eng/build/SchemaGenerator.cs`
- Layer 2: Roslyn source generator
- `src/qyl.servicedefaults.generator/`
- Layer 3: Runtime instrumentation
- `src/qyl.servicedefaults/`
- `src/qyl.collector/`

Layers must never be conflated.

## Agent roles

`agent-collector`
- Role: OTLP collector maintainer
- Scope: `src/qyl.collector`
- Focus: OTLP ingestion, DuckDB batching, SSE streaming lifecycle
- Rules: minimal diffs; never modify generators or schema code
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The “Architecture constraints” section references eng/build/SchemaGenerator.cs and src/qyl.* paths that do not exist in this repository. This makes the template inaccurate for users running it here; either generalize these constraints, or explicitly label this template as intended for a different repo layout and replace the paths with placeholders.

Suggested change
- Layer 1: Schema generation
- `eng/build/SchemaGenerator.cs`
- Layer 2: Roslyn source generator
- `src/qyl.servicedefaults.generator/`
- Layer 3: Runtime instrumentation
- `src/qyl.servicedefaults/`
- `src/qyl.collector/`
Layers must never be conflated.
## Agent roles
`agent-collector`
- Role: OTLP collector maintainer
- Scope: `src/qyl.collector`
- Focus: OTLP ingestion, DuckDB batching, SSE streaming lifecycle
- Rules: minimal diffs; never modify generators or schema code
This template assumes a three-layer architecture for telemetry-related code. Adapt the concrete paths and modules to match your repository layout.
- Layer 1: Schema generation (build-time schema tools)
- Layer 2: Source generator(s) (compile-time code generation)
- Layer 3: Runtime instrumentation and collector services
Layers must never be conflated: schema tools, generators, and runtime code live in separate modules or directories.
## Agent roles
`agent-collector`
`agent-collector`
- Role: OTLP collector maintainer
- Scope: Runtime collector / ingestion layer (e.g., your `collector` service or equivalent path)
- Focus: OTLP ingestion, batching/persistence, streaming lifecycle
- Rules: minimal diffs; never modify generator or schema layers

Copilot uses AI. Check for mistakes.

## Execution rules

- Use only `bash`, `git`, and filesystem operations.
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

Execution rules say “Use only bash, git, and filesystem operations”, but the script relies on awk for parsing git worktree list --porcelain. Either allow awk explicitly in the rules, or rewrite the parsing to pure bash/git so the template is self-consistent.

Suggested change
- Use only `bash`, `git`, and filesystem operations.
- Use only `bash`, `git`, `awk`, and filesystem operations.

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +132
role_contents_common='\
## Repository architecture constraints

Layer 1: Schema generation
- `eng/build/SchemaGenerator.cs`
- NUKE build emits models, enums, scalars, and DuckDB DDL

Layer 2: Roslyn source generator
- `src/qyl.servicedefaults.generator/`
- 7 incremental pipelines that emit compile-time interceptors

Layer 3: Runtime instrumentation
- `src/qyl.servicedefaults/`
- `src/qyl.collector/`

Layers must never be conflated.
'
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

role_contents_common is assigned as a multi-line single-quoted string that begins with a literal \ character (role_contents_common='\ …). That leading backslash will be written into every generated AGENTS.md and appears unintentional; remove it or switch to a heredoc-style assignment to avoid stray characters.

Copilot uses AI. Check for mistakes.
Comment on lines +205 to +220
cat > "$path/AGENTS.md" <<EOF_AGENTS
# AGENTS.md for $role

${role_contents_common}

$(get_agent_section "$role")

## Required verification
- dotnet build
- dotnet test
EOF_AGENTS

mkdir -p "$path/.codex"
printf 'Read and follow AGENTS.md in this worktree.\n' > "$path/CLAUDE.md"
printf 'Read and follow AGENTS.md in this worktree.\n' > "$path/.codex/agent.md"
}
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The script overwrites AGENTS.md and CLAUDE.md in each worktree with minimal content. In this repository, CLAUDE.md/AGENTS.md are human-maintained and contain critical operational instructions, so following this template here would erase them on the worktree/* branches; consider writing to repo-specific filenames (e.g., WORKTREE_AGENTS.md) or appending a role section instead of replacing the files.

Copilot uses AI. Check for mistakes.
Comment on lines +231 to +233
mkdir -p "$worktrees_dir"
declare -A status

Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

This template script uses declare -A status, which requires Bash 4+. On macOS (default /bin/bash is often 3.2), this will fail even though the template targets generic “bash”; consider avoiding associative arrays or explicitly documenting the required bash version.

Copilot uses AI. Check for mistakes.

### Added

- **`tooling/templates/persistent-agent-worktree-setup.md`**: Added a reusable prompt template for role-based Claude/Codex worktree setup with `AGENTS.md` as the single source of truth and thin `CLAUDE.md`/`.codex/agent.md` pointer files
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The new changelog entry is a single very long line (likely >120 chars), which will trip markdownlint MD013 in this repo’s configuration. Please wrap it across multiple lines (e.g., break after the colon and indent continuation lines) to keep lint output clean.

Suggested change
- **`tooling/templates/persistent-agent-worktree-setup.md`**: Added a reusable prompt template for role-based Claude/Codex worktree setup with `AGENTS.md` as the single source of truth and thin `CLAUDE.md`/`.codex/agent.md` pointer files
- **`tooling/templates/persistent-agent-worktree-setup.md`**:
Added a reusable prompt template for role-based Claude/Codex worktree
setup with `AGENTS.md` as the single source of truth and thin
`CLAUDE.md`/`.codex/agent.md` pointer files

Copilot uses AI. Check for mistakes.

### Added

- **`tooling/templates/persistent-agent-worktree-setup.md`**: Added a reusable prompt template for role-based Claude/Codex worktree setup with `AGENTS.md` as the single source of truth and thin `CLAUDE.md`/`.codex/agent.md` pointer files
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The changelog entry describes AGENTS.md as the single source of truth with thin CLAUDE.md pointers, but in this repository CLAUDE.md is the authoritative, auto-loaded instruction set and is explicitly human-maintained. Consider clarifying in the entry (and/or template) that this worktree setup is intended for other repos, or adjust the template so it doesn’t conflict with this repo’s established instruction model.

Suggested change
- **`tooling/templates/persistent-agent-worktree-setup.md`**: Added a reusable prompt template for role-based Claude/Codex worktree setup with `AGENTS.md` as the single source of truth and thin `CLAUDE.md`/`.codex/agent.md` pointer files
- **`tooling/templates/persistent-agent-worktree-setup.md`**: Added a reusable prompt template (for downstream repos) for role-based Claude/Codex worktree setup with `AGENTS.md` as the single source of truth and thin `CLAUDE.md`/`.codex/agent.md` pointer files; in this repository, `CLAUDE.md` remains the authoritative, auto-loaded instruction set

Copilot uses AI. Check for mistakes.
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 a new template for setting up a multi-agent worktree environment and updates the CHANGELOG accordingly. The template includes a comprehensive bash script to automate the process. My review focuses on the new script, where I've identified a correctness bug in the final summary report and a portability issue with the use of non-standard awk features. I've provided suggestions to fix these issues to improve the script's reliability and compatibility across different systems.

Note: Security Review has been skipped due to the limited scope of the PR.

Comment on lines +278 to +280
printf " AGENTS.md: %s\n" "$( [[ -f \"$path/AGENTS.md\" ]] && echo exists || echo missing )"
printf " CLAUDE.md: %s\n" "$( [[ -f \"$path/CLAUDE.md\" ]] && echo exists || echo missing )"
printf " .codex/agent.md: %s\n" "$( [[ -f \"$path/.codex/agent.md\" ]] && echo exists || echo missing )"

Choose a reason for hiding this comment

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

high

The file existence checks in the summary section are incorrect. The escaped quotes \" in [[ -f \"$path/...\" ]] cause the test to look for a file path that literally contains double quotes, which will always fail. This results in the script incorrectly reporting that files are missing even when they exist. The backslashes should be removed to correctly test the file paths.

Suggested change
printf " AGENTS.md: %s\n" "$( [[ -f \"$path/AGENTS.md\" ]] && echo exists || echo missing )"
printf " CLAUDE.md: %s\n" "$( [[ -f \"$path/CLAUDE.md\" ]] && echo exists || echo missing )"
printf " .codex/agent.md: %s\n" "$( [[ -f \"$path/.codex/agent.md\" ]] && echo exists || echo missing )"
printf " AGENTS.md: %s\n" "$( [[ -f \"$path/AGENTS.md\" ]] && echo exists || echo missing )"\n printf " CLAUDE.md: %s\n" "$( [[ -f \"$path/CLAUDE.md\" ]] && echo exists || echo missing )"\n printf " .codex/agent.md: %s\n" "$( [[ -f \"$path/.codex/agent.md\" ]] && echo exists || echo missing )"

git worktree list --porcelain | awk -v target="$target" '
$1 == "worktree" {path = $2}
path == target {found = 1}
END {exit found ? 0 : 1}

Choose a reason for hiding this comment

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

medium

The awk script uses the ternary operator ? :. This is a GNU awk (gawk) extension and is not portable to other awk implementations, such as the default one on macOS. To ensure the script runs correctly on different systems, it's best to use a standard if/else construct.

Suggested change
END {exit found ? 0 : 1}
END {if (found) exit 0; else exit 1}


if git worktree list --porcelain | awk -v branch="refs/heads/$branch" '
$1 == "branch" && $2 == branch {found = 1}
END {exit found ? 0 : 1}

Choose a reason for hiding this comment

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

medium

Similar to the other awk command in this script, the use of the ternary operator ? : here is a non-portable GNU awk extension. It should be replaced with a standard if/else to ensure compatibility with other awk implementations.

Suggested change
END {exit found ? 0 : 1}
END {if (found) exit 0; else exit 1}

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.

2 participants