Skip to content
Skills Library
Programming · Tool integration

setup-multirepo-git

/setup-multirepo-git

Multi-repo git workflow rules and setup. Provides mgit wrapper for safe permission patterns across independent service repositories. Use when setting up a new multi-repo workspace or when working with multi-repo git operations.

Licence
MIT
Last repository change
24.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
5
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 24.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Multi-repo git workflow rules and setup. Provides mgit wrapper for safe permission patterns across independent service repositories. Use when setting up a new multi-repo workspace or when working with multi-repo git operations.

Original author description

Multi-repo git workflow rules and setup. Provides mgit wrapper for safe permission patterns across independent service repositories. Use when setting up a new multi-repo workspace or when working with multi-repo git operations.

How it works

  1. Multi-Repo Git Rules
  2. Setup Instructions
Original SKILL.md headings · 159 lines, 998 words
SKILL.md preview
---
name: setup-multirepo-git
description: Multi-repo git workflow rules and setup. Provides mgit wrapper for safe permission patterns across independent service repositories. Use when setting up a new multi-repo workspace or when working with multi-repo git operations.
allowed-tools: "Read,Write,Bash(git:*),Bash(ln:*),Bash(mkdir:*),Bash(cat:*),Bash(./scripts/mgit:*),Bash(readlink:*),AskUserQuestion"
model-tier: standard
model: sonnet
effort: high
version: "1.2.1"
author: "flurdy"
---

# Multi-Repo Git Workflow

This skill provides rules for working with multi-repo workspaces (multiple independent git repositories in one project directory) and a setup command for new projects.

## Multi-Repo Git Rules

These rules apply whenever working in a project that has a `.mgit.conf` file in its root.

### Always use mgit for service git operations

**Rule: Use `./scripts/mgit <subcommand> <service>` for all git operations on service repositories.** This wrapper runs `git -C` under the hood but puts the subcommand before the service, giving harness-specific permission policies a stable command prefix. The wrapper itself does not enforce approvals.

Use `root` or `.` as the service name for the root repo.

Never use `cd <service> && git ...` (bypasses the documented wrapper prefix). Never run bare `git add/status/commit` expecting it to pick up service files — that targets the root repo.

```bash
# CORRECT — invoke from the project root using the configured wrapper prefix
./scripts/mgit status my-service --short
./scripts/mgit diff my-service
./scripts/mgit add my-service src/main/MyFile.scala
./scripts/mgit commit my-service -m "fix: something"
./scripts/mgit log my-service --oneline -5

# CORRECT — root repo operations
./scripts/mgit status root --short
./scripts/mgit diff .
./scripts/mgit add root AGENTS.md
./scripts/mgit commit . -m "docs: update agents"

# WRONG for this workflow — bypasses the configured mgit prefix
git -C my-service status --short

# WRONG for this workflow — changes directory and bypasses mgit
cd my-service && git status --short

# WRONG — targets root repo, service folders are gitignored
git add my-service/src/main/MyFile.scala
git status  # only shows root repo changes
```

### Which repo does a file belong to?

Check the first path component after the project root:
- If it matches a service name listed in `.mgit.conf` → use `./scripts/mgit <subcommand> <service>`
- If it's a root-level file (AGENTS.md, docs/, scripts/, etc.) → use `./scripts/mgit <subcommand> root` (or `.`)

### Multiple services in one session

When committing changes across multiple services, run separate mgit commands for each service. Each service gets its own commit.

### Git best practices

- **Staging**: Never use `git add -A`. Add specific files instead.
- **Commits**: Keep commits small and focused. Use Conventional Commits style.
- **Remote**: Never `git push` or `git pull` automatically — ask first. `git fetch` is allowed.
- **Resets**: Do not `git reset --hard` or checkout the whole project.

## Setup Instructions

When invoked as `/setup-multirepo-git`, set up a new multi-repo workspace:

### Step 1: Discover services

Scan the project root for subdirectories that contain their own `.git/` directory:

```bash
# Find subdirectories with their own git repos
for dir in */; do
  [ -d "$dir/.git" ] && echo "${dir%/}"
done
```

Present the discovered list to the user for confirmation. They may want to add or remove entries.

### Step 2: Create .mgit.conf

Create a `.mgit.conf` file in the project root with the confirmed service list:

```ini
# Multi-repo workspace configuration
# Presence of this file marks the project root for mgit
services=service-a,service-b,service-c
```

### Step 3: Symlink the mgit script

Resolve installed resources once in Bash before linking or reading templates. A nonempty
`SKILLS_DIR` is authoritative: use an absolute path and never silently replace an invalid override.
Without it, prefer the canonical root; fall back to the Claude alias root only if this skill unit
is absent. Legacy Codex-only installations can set `SKILLS_DIR` explicitly; they are not auto-selected.

```bash
set -eu
if [[ -z "${SKILLS_DIR:-}" ]]; then
  SKILLS_DIR="$HOME/.agents/skills"
  if [[ ! -d "$SKILLS_DIR/setup-multirepo-git" ]]; then
    SKILLS_DIR="${CLAUDE_SKILLS_DIR:-${CLAUDE_HOME:-$HOME/.claude}/skills}"
  fi
fi
[[ "$SKILLS_DIR" = /* ]] || { echo "SKILLS_DIR must be absolute" >&2; exit 1; }
for resource in SKILL.md scripts/mgit templates/permissions.json templates/AGENTS-MGIT.md; do
  [[ -f "$SKILLS_DIR/setup-multirepo-git/$resource" && -r "$SKILLS_DIR/setup-multirepo-git/$resource" ]] || {
    echo "Missing setup-multirepo-git resource: $resource" >&2; exit 1;
  }
done
[[ -x "$SKILLS_DIR/setup-multirepo-git/scripts/mgit" ]] || { echo "mgit is not executable" >&2; exit 1; }
```

Missing resources stop setup; do not create dangling links or repair the shared installation here.
After installation-root changes, re-run the approved project setup rather than retargeting silently.
Keep the resolved root for steps 4–5 (shell calls may not share variables). Preview the exact paths;
create links only after setup approval and never overwrite an existing destination implicitly:

```bash
[[ ! -e scripts/mgit && ! -L scripts/mgit ]] || { echo "Destination exists: scripts/mgit" >&2; exit 1; }
mkdir -p scripts
ln -s "$SKILLS_DIR/setup-multirepo-git/scripts/mgit" scripts/mgit
```

Verify the symlink works:
```bash
./scripts/mgit status <first-service> --short
./scripts/mgit status root --short
```

Optionally link `scripts/mgit-status` the same way: a single-command status of root plus every
`.mgit.conf` service (or only the services passed as arguments), using `mgit` beside it.

### Step 4: Output permission patterns

Read `$SKILLS_DIR/setup-multirepo-git/templates/permissions.json` using the root validated in step 3.
The existing filename is retained for compatibility, but these are **Claude Code** `Bash(...)`
patterns, not portable permission configuration. Show the fragment for the user to review and merge
under `permissions` in their Claude settings; do not edit settings automatically.

The `allow` list includes `add`, `commit`, `stash`, and `fetch`: it is **not read-only**. Review those
choices against repository rules before adopting them. Codex uses its own sandbox/approval controls;
Pi core does not enforce this JSON or skill `allowed-tools`. Installed Pi policy extensions may add
controls; inspect their actual configuration rather than translating Claude syntax or assuming
approvals are enforced. Frontmatter and a wrapper prefix never replace user/repository authorization.

### Step 5: Output AGENTS.md block

Read `$SKILLS_DIR/setup-multirepo-git/templates/AGENTS-MGIT.md` using the root validated in step 3
and output it. If this is a new shell/tool context, reuse the verified absolute path or repeat the
read-only resource resolution; never fall back to a different root for templates.

Tell the user to include this block in their project's `AGENTS.md` file, customizing the service names and any project-specific details.

### Step 6: Confirm setup

Verify everything works:
1. `readlink scripts/mgit` — should show the symlink target
2. `./scripts/mgit status <service>` — should show git status for a service
3. `./scripts/mgit status root` — should show git status for the root repo
4. `./scripts/mgit status invalid-name` — should error with valid service list
Files in this package (5)
  • SKILL.md 7 KB
  • scripts/mgit 2 KB
  • scripts/mgit-status 1 KB
  • templates/AGENTS-MGIT.md 2 KB
  • templates/permissions.json 1 KB

Versions

The database has no other skills named setup-multirepo-git.

Database snapshot: 13.11.2026 · package version 1a04e2411449 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100kelin-multirepo
    多仓库老项目统筹:先画仓库与数据所有权地图,再选集成方式(API/事件优先,避免跨仓共享库表),用契约和部署顺序管理跨仓改动。用户说“多个仓库”“仓库太多太乱”“数据共库还是 API”“跨仓改造”时使用。
  • 100multirepo-ci-cd
    Diagnose a CI failure or roll a workflow out across many repos. Use when debugging a red check in a multi-repo org, promoting a shared reusable-*.yml, or re-triggering a PR after a @main fix.
  • 100setup
    One-time machine setup to work in a team GitHub repo - install git and gh, log in to GitHub, set git name/email, get access to and clone the repo. Use when someone says "set me up", "first time", "how do I get the repo", or git/gh isn't installed or authenticated.
  • 100git-repo-detection
    Detect GitHub repo owner/name from git remotes. Use when needing the owner/repo identifier for GitHub CLI or API calls, especially across multiple repos.
  • 95git-workflow
    Manage Git workflows including commits, branches, merges, and collaboration. Use when working with Git repositories, creating commits, managing branches, or resolving conflicts.
  • 95multi-repo-git-ops
    Manages git operations (branching, committing, pushing) across multi-repo systems with git submodules. Use this skill whenever the user wants to create a feature branch, commit changes, push code, sync submodules, or manage branches across the parent repo and service repos. Also…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.