OpenAgentsControl: Command for Claude Code

.opencode/command/worktrees.md

worktrees is a command for Claude Code, OpenCode from darrenhinde/OpenAgentsControl. It costs 8 tokens per session (852 once invoked), scanned A, original, MIT.

A Git worktree manager for working on several branches in separate directories. A worktree is another working folder connected to the same Git repository.

In plain words
What is it for?
Use it to create worktrees for named branches or open pull requests, list existing worktrees, and clean them up.
Why use it?
It lets you work on multiple branches at once without repeatedly switching the contents of one folder.

Command for Claude CodeOpenCode

Written for Claude Code and OpenCode: $ARGUMENTS substitution, but also installed under .opencode/.

This is darrenhinde/OpenAgentsControl's own configuration. It tells Claude Code and OpenCode how to work on OpenAgentsControl itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything OpenAgentsControl configures →

About the project

OpenAgents Control is a framework that adds plan-first, approval-based coding workflows to OpenCode, an AI coding framework. Developers and teams use it to make agents follow shared coding patterns, work across several programming languages, and validate changes through testing and review. The catalogue includes its agents, skills, commands, plugin, and hook.

darrenhinde/OpenAgentsControl · 4,910 stars · on GitHub

Reuse

Borrowing it

Nothing to install: this file belongs to darrenhinde/OpenAgentsControl. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/darrenhinde/OpenAgentsControl/main/.opencode/command/worktrees.md
Clone the repo
git clone --depth 1 https://github.com/darrenhinde/OpenAgentsControl

Made for: Claude Code, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for worktrees

README.md
[![agentmods](https://agentmods.dev/badge/commands/darrenhinde/openagentscontrol/worktrees/github.svg)](https://agentmods.dev/commands/darrenhinde/openagentscontrol/worktrees)
Your own site
<a href="https://agentmods.dev/commands/darrenhinde/openagentscontrol/worktrees"><img src="https://agentmods.dev/badge/commands/darrenhinde/openagentscontrol/worktrees/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for worktrees

Your own site · 80×15
<a href="https://agentmods.dev/commands/darrenhinde/openagentscontrol/worktrees"><img src="https://agentmods.dev/badge/commands/darrenhinde/openagentscontrol/worktrees.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 8 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 852 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00008 $0.00852
Opus 5.5 $0.00003 $0.00341
Sonnet 5.5 $0.00002 $0.00170
Haiku 4.5 $0.00001 $0.00085

Measured 1mo ago against content hash 15e16fc3e375, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

worktrees scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.opencode/command/worktrees.md · 98 lines

How it starts

The opening of the file, as written. The whole thing — 98 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Git Worktree Management

You are a git workflow specialist. When provided with $ARGUMENTS, manage git worktrees to enable parallel development on multiple branches. Common arguments: "create", "list", "cleanup", or specific branch names.

Your Worktree Management Process:

Step 1: Assess Current State

  • Check if git worktrees are already in use with git worktree list
  • Verify GitHub CLI is available and authenticated for PR operations
  • Identify the main repository directory structure
  • Check for existing ./tree directory or similar worktree organization

Step 2: Execute Worktree Operations

Create Worktrees for All Open PRs

When $ARGUMENTS includes "prs" or "all":

  1. Run gh pr list --json headRefName,title,number to get open PRs
  2. For each PR branch:
    • Create directory structure: ./tree/[branch-name]
    • Execute git worktree add ./tree/[branch-name] [branch-name]
    • Handle branch names with slashes by creating nested directories
  3. Report successful worktree creation

Create Worktree for Specific Branch

When $ARGUMENTS specifies a branch name:

  1. Check if branch exists locally or remotely
  2. Create worktree at ./tree/[branch-name]
  3. If branch doesn't exist, offer to create it with git worktree add -b [branch-name] ./tree/[branch-name]

Create New Branch with Worktree

When $ARGUMENTS includes "new" and a branch name:

  1. Prompt for base branch (default: main/master)
  2. Create new branch and worktree simultaneously
  3. Set up proper tracking if needed

List and Status Check

When $ARGUMENTS includes "list" or "status":

  1. Show all current worktrees with git worktree list
  2. Check status of each worktree
  3. Identify any stale or problematic worktrees

Cleanup Operations

When $ARGUMENTS includes "cleanup":

  1. Identify branches that no longer exist remotely
  2. Remove corresponding worktrees safely
  3. Clean up empty directories in ./tree

Step 3: Present Worktree Report

📋 Worktree Management Results

🎯 Operation Summary

  • Command: [What operation was performed]
  • Target: [Specific branches or "all open PRs"]
  • Location: [Worktree directory structure used]

Read the full file on GitHub · 98 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 98 lines · 8 tokens per session scan A 15e16fc3e375

Subscribe to this mod's changes

worktrees is a command published in the GitHub repository darrenhinde/OpenAgentsControl (4,910 stars, last pushed 1mo ago), licensed MIT. It adds 8 tokens to every session and 852 once invoked, about $0.0000 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-14.