git-workflows
Use when working with git operations, PRs, or code reviews - enforces modern agentic git workflows with multi-agent consensus review using contextd for memory, context folding, and learning capture
What this skill does
# Git Workflows
Modern agentic git workflow enforcement with multi-agent consensus review. Integrates deeply with contextd for cross-session learning, context folding, and remediation tracking.
---
## Parallel Development with Git Worktrees
### Why Worktrees for AI Agents
- Multiple agents can work simultaneously without file conflicts
- Each agent gets isolated working directory
- Shared .git folder = efficient storage
- Industry standard for parallel AI development (2024-2025)
### Directory Structure
```
~/projects/
├── my-project/ # Main worktree (main branch)
└── my-project-worktrees/ # All linked worktrees
├── feature-auth/ # Agent A
├── fix-database/ # Agent B
└── refactor-api/ # Agent C
```
### Core Commands
| Task | Command |
|------|---------|
| Create worktree | `git worktree add -b <branch> <path>` |
| List all | `git worktree list` |
| Lock (portable storage) | `git worktree lock --reason "msg" <path>` |
| Unlock | `git worktree unlock <path>` |
| Remove properly | `git worktree remove <path>` |
| Cleanup stale | `git worktree prune -v` |
| Fix broken links | `git worktree repair [<path>...]` |
### Worktree Lifecycle for Agents
1. **Pre-work:** `git worktree add -b feature/task ../worktrees/task`
2. **During:** Agent works in isolated directory
3. **Completion:** `git worktree remove ../worktrees/task`
4. **Cleanup:** `git worktree prune -v`
### Worktree Quick Reference Card
```bash
# === SETUP ===
git worktree add -b <branch> ../worktrees/<name> # Create
git worktree list # List all
git worktree list --porcelain # Machine-readable
# === DURING WORK ===
cd ../worktrees/<name> # Enter worktree
git status # Check state
git worktree lock --reason "active" <path> # Prevent removal
# === COMPLETION ===
git worktree unlock <path> # Unlock first
git worktree remove <path> # Remove properly
git worktree prune -v # Clean stale refs
# === RECOVERY ===
git worktree repair # Fix broken links
git worktree repair <path>... # Fix specific worktrees
```
### Dependency Management in Worktrees
| Scenario | Solution |
|----------|----------|
| Shared node_modules | Use workspace root: `npm install` from main |
| Go modules | `go work init` + `go work use <worktrees>` |
| Python venv | Create per-worktree: `python -m venv .venv` |
| Docker builds | Mount worktree as volume |
### Anti-Patterns
| Anti-Pattern | Why Bad | Correct Approach |
|--------------|---------|------------------|
| `rm -rf worktree` | Corrupts Git tracking | `git worktree remove` |
| Two agents, same files | Merge conflicts | Scope to non-overlapping files |
| Moving folder manually | Breaks gitdir link | `git worktree move` or `repair` |
| 20+ simultaneous worktrees | Unmanageable | Create, complete, remove |
### Official Git Warning
> "Multiple checkout in general is still experimental, and the support for submodules is incomplete. It is NOT recommended to make multiple checkouts of a superproject."
### File Overlap Prevention
- Scope agent work to non-overlapping modules/directories
- Two agents touching same files = guaranteed conflicts
- Plan task decomposition before spawning agents
### Worktree + Background Agent Pattern
Combine worktrees with Task tool for true parallel development:
```bash
# 1. Create worktrees for each agent
git worktree add -b feature/auth ../worktrees/auth
git worktree add -b feature/api ../worktrees/api
git worktree add -b feature/ui ../worktrees/ui
# 2. Launch agents in parallel (each in own worktree)
Task(
subagent_type: "general-purpose",
prompt: "cd ../worktrees/auth && implement auth module",
run_in_background: true
)
Task(
subagent_type: "general-purpose",
prompt: "cd ../worktrees/api && implement API layer",
run_in_background: true
)
Task(
subagent_type: "general-purpose",
prompt: "cd ../worktrees/ui && implement UI components",
run_in_background: true
)
# 3. Collect and merge
TaskOutput(task_id: "auth-id", block: true)
TaskOutput(task_id: "api-id", block: true)
TaskOutput(task_id: "ui-id", block: true)
# 4. Merge branches
git merge feature/auth feature/api feature/ui
# 5. Cleanup
git worktree remove ../worktrees/auth
git worktree remove ../worktrees/api
git worktree remove ../worktrees/ui
```
### Worktree-Aware Consensus Review
When reviewing changes across worktrees:
```
1. Each worktree gets its own review cycle
2. Cross-worktree dependencies detected via git diff
3. Integration review after individual passes
4. Merge conflicts flagged before human review
```
---
## Core Principles
1. **Flexible Trigger, Full Traceability** - Any work trigger acceptable, all changes traceable via commit/PR metadata
2. **Agent-Assisted, Human-Owned** - Agents propose, humans approve; AI code never ships without human sign-off
3. **Trunk-Based, Short-Lived** - Branches <24h encouraged, squash merge only, auto-delete after merge
4. **Consensus Before Human Review** - Multi-agent consensus gate before human reviewers engaged
5. **Learning-Enhanced** - contextd integration optional; file-based fallback when MCP unavailable
---
## Multi-Agent Consensus Review
### The Review Council
| Agent | Focus | Veto Power | Budget |
|-------|-------|------------|--------|
| **Security** | Auth, injection, secrets, OWASP | Yes | 8192 |
| **Vulnerability** | CVEs, deps, supply chain | Yes | 8192 |
| **Code Quality** | Logic, complexity, patterns, tests | Yes | 8192 |
| **Documentation** | README, comments, API docs, CHANGELOG | Yes | 4096 |
| **User Persona** | UX impact, breaking changes, API ergonomics | Yes | 4096 |
### Consensus Rules
- **All agents have veto power** on findings in their domain
- Use `--ignore-vetos` flag to override (requires justification)
- **100% consensus** required: all Critical/High/Medium resolved
- Low findings: auto-create issues if <3, author triage if ≥3
---
## contextd Integration (Optional)
### When contextd MCP is Available
| Feature | Tool | Benefit |
|---------|------|---------|
| Pre-flight search | `semantic_search`, `memory_search` | Learn from past reviews |
| Context isolation | `branch_create`, `branch_return` | Parallel agent execution |
| Learning capture | `memory_record`, `remediation_record` | Cross-session knowledge |
| Checkpoints | `checkpoint_save`, `checkpoint_resume` | Resumable sessions |
### When contextd is NOT Available
| Feature | Fallback | Location |
|---------|----------|----------|
| Review findings | JSON files | `.claude/consensus-reviews/PR-XXX.json` |
| Past patterns | Local search | Grep/Glob on previous reviews |
| Audit trail | Markdown logs | `.claude/consensus-reviews/audit.md` |
### Detection
```
# Check for contextd
ToolSearch("contextd")
# If available: use mcp__contextd__* tools
# If not: write to .claude/consensus-reviews/
```
---
## Workflow Phases
### Phase 1: Pre-Flight (ReasoningBank)
**Optional: If contextd available, gather additional context:**
```
1. mcp__contextd__semantic_search(
query: "code patterns in [changed files]",
project_path: "."
)
→ Understand codebase context
2. mcp__contextd__memory_search(
project_id: "<project>",
query: "PR review patterns [area]"
)
→ Retrieve past review strategies
3. mcp__contextd__remediation_search(
query: "common issues in [file types]",
tenant_id: "<tenant>",
include_hierarchy: true
)
→ Pre-load known problem patterns
4. mcp__contextd__checkpoint_save(
session_id: "<session>",
project_path: ".",
name: "review-start-PR-XXX",
description: "Starting consensus review",
summary: "5-agent review of PR #XXX",
context: "[PR description, files changed]",
full_state: "[complete PR context]",
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.