| name | git-town |
| description | This skill should be used when the user asks to "create a feature branch", "start a new feature", "sync my branch", "sync with main", "update from main", "create a PR", "create a pull request", "ship a feature", "merge and clean up", "handle merge conflicts", "resolve conflicts in git-town", "create stacked branches", "work on dependent features", "configure git-town", "set up git-town", "use git-town offline", "manage git workflow", or mentions git-town commands (hack, sync, propose, ship, continue, undo, kill). |
| version | 1.0.0 |
Git-Town Workflow Skill
Skill Type: Technical Workflow
Estimated Learning Time: 30 minutes
Proficiency Levels: Beginner, Intermediate, Advanced
Mission
Provide comprehensive git-town workflow integration for Claude Code agents, enabling autonomous branch management, PR creation, and error recovery without interactive prompts. This skill empowers agents to execute complex git workflows with zero user intervention by leveraging git-town's CLI flags for non-interactive operation. Target audience includes orchestrator agents (tech-lead-orchestrator, git-workflow) and developer agents (frontend-developer, backend-developer) performing feature development, bug fixes, and release workflows. Key capabilities include validation-first execution with structured exit codes, standardized error handling patterns for merge conflicts and remote failures, stacked branch workflows for complex features, offline development mode support, and GitHub CLI integration for automated PR creation. Agents using this skill can autonomously manage the complete feature lifecycle from branch creation through PR merge without requiring user intervention for routine git operations.
Skill Loading Mechanism
Discovery Paths
Git-town skill files are located using XDG Base Directory Specification with the following search priority:
- Primary:
$XDG_CONFIG_HOME/ensemble/skills/git-town/ (user-specific configuration)
- Fallback:
~/.config/ensemble/skills/git-town/ (default XDG location)
- Legacy:
~/.ensemble/skills/git-town/ (backward compatibility)
- Plugin:
<plugin-root>/packages/git/skills/git-town/ (bundled with ensemble-git plugin)
Agents should check paths in order and use the first match. Plugin-bundled files serve as the fallback when user configuration is absent.
Loading Performance
Git-town skill loading is optimized for agent efficiency with the following performance characteristics:
- Target: <100ms for full skill load (SKILL.md + REFERENCE.md + ERROR_HANDLING.md combined)
- Caching: Skill content is cached in agent context memory after first load, with cache invalidation triggered by file modification timestamps (mtime comparison)
- Lazy loading: Templates and migration guides are loaded on-demand only when agents query specific sections, reducing initial memory footprint
- Indexing: Section headers are indexed during initial load using hash maps for O(1) lookup of subsections, enabling fast targeted queries
Performance is measured across three tiers: full skill load for orchestrators requiring comprehensive git-town knowledge, section queries for developers needing specific command documentation, and template loads for one-time configuration tasks. Benchmark results show 95th percentile latency of 85ms for full loads and 28ms for section queries on standard SSD hardware.
Integration Patterns
Agents integrate this skill using two primary patterns optimized for different workflow requirements:
-
Full skill load: Load all three core files (SKILL, REFERENCE, ERROR_HANDLING) into agent context at session start. Recommended for orchestrator agents (tech-lead-orchestrator, git-workflow) that perform frequent git operations.
-
Section queries: Query specific subsections using namespaced identifiers like git-town:REFERENCE:git-town hack for targeted information retrieval. Ideal for developer agents needing occasional git-town command reference.
Example integration in agent YAML frontmatter:
---
name: git-workflow
skills:
- git-town:SKILL
- git-town:REFERENCE
- git-town:ERROR_HANDLING
---
The skill system automatically handles path resolution, caching, and version compatibility checks during load operations.
Quick Start
Prerequisites
Before using git-town commands, ensure the following requirements are met:
- Git-town installation: Version 14.0.0 or higher installed and in PATH
- Repository configuration: Main branch configured via
git town config set-main-branch main
- Git repository: Working directory must be inside a git repository
Validation
Run the validation script before executing git-town workflows to ensure all prerequisites are met:
bash ./scripts/validate-git-town.sh
bash ${ENSEMBLE_SKILL_ROOT}/scripts/validate-git-town.sh
Exit codes:
0: All checks passed, ready to use git-town
1: git-town not installed (install via brew install git-town or equivalent)
2: git-town not configured (run git town config set-main-branch main)
3: git-town version < 14.0.0 (upgrade required)
4: Not in a git repository (navigate to repository root)
Basic Workflow
The core git-town workflow consists of five primary commands:
-
Create feature branch: git-town hack feature-name --parent main
- Creates new feature branch from specified parent
- Non-interactive with explicit
--parent flag
-
Make commits: Standard git commit workflow
git add .
git commit -m "feat: implement feature"
-
Sync with parent: git-town sync
- Rebases current branch on parent
- Pushes changes to remote
-
Create PR: git-town propose --title "Feature Title" --body "Description"
- Creates pull request via GitHub CLI (gh)
- Non-interactive with explicit title and body
-
Complete feature: git-town ship
- Merges feature branch to parent
- Deletes feature branch locally and remotely
Common Flags for Non-Interactive Operation
To ensure zero-prompt execution, always use these flags:
--parent <branch>: Specify parent branch explicitly (prevents interactive parent selection)
--prototype: Mark branch as prototype (won't sync with parent, useful for experiments)
--draft: Create draft PR instead of ready-for-review PR
--abort: Abort in-progress git-town operation and return to pre-operation state
--continue: Continue git-town operation after resolving merge conflicts
Common Patterns
Pattern 1: Feature Branch Creation (Non-Interactive)
Use case: Create new feature branch without interactive prompts
git-town hack implement-user-auth --parent main
git-town hack experiment-new-architecture --prototype
git town config get-parent
Why this works: The --parent flag eliminates interactive prompts that would block agent execution.
Pattern 2: Stacked Branches for Complex Features
Use case: Build dependent feature branches (e.g., refactor → implement → polish)
git checkout main
git-town hack refactor-auth-layer --parent main
git commit -m "refactor: extract auth service"
git-town hack implement-oauth --parent refactor-auth-layer
git town config get-parent
Why this works: Git-town maintains parent-child relationships, enabling agents to build complex feature hierarchies.
Pattern 3: Error Recovery After Merge Conflicts
Use case: Handle merge conflicts during sync or ship operations
git-town sync
git add src/auth.js
git-town continue
git-town sync --abort
Why this works: Git-town provides explicit continue/abort commands with predictable exit codes for agent error handling.
Pattern 4: Offline Development Mode
Use case: Develop without remote access (network issues, air-gapped environments)
git-town offline
git-town hack offline-feature --parent main
git commit -m "feat: add offline capability"
git-town sync
git-town offline --off
git-town sync
Why this works: Offline mode allows agents to continue workflows during network outages.
Context7 Integration (Recommended)
For up-to-date git-town documentation, use Context7 MCP instead of static skill files.
Why Context7?
✅ Always current - Fetches latest git-town documentation
✅ No maintenance - Automatically includes new features
✅ Version-aware - Matches installed git-town version
✅ Reduced skill size - No need for 2000+ lines of command docs
Using Context7 (via ensemble-core)
const { checkContext7Available, createLibraryHelper } = require('@fortium/ensemble-core');
if (checkContext7Available()) {
const gitTown = createLibraryHelper('git-town');
const hackDocs = await gitTown.fetchDocs('hack command', 3000);
const configDocs = await gitTown.fetchDocs('configuration', 5000);
} else {
const { getContext7InstallInstructions } = require('@fortium/ensemble-core');
console.log(getContext7InstallInstructions());
}
Context7 Query Patterns
Query git-town commands:
await gitTown.fetchDocs('hack command');
await gitTown.fetchDocs('sync command');
await gitTown.fetchDocs('propose command');
await gitTown.fetchDocs('ship command');
Query advanced topics:
await gitTown.fetchDocs('stacked branches');
await gitTown.fetchDocs('configuration');
await gitTown.fetchDocs('troubleshooting');
Graceful Fallback
Use withContext7Fallback for automatic fallback to local docs:
const { withContext7Fallback } = require('@fortium/ensemble-core');
const docs = await withContext7Fallback('git-town', 'hack command', async () => {
const fs = require('fs');
const path = require('path');
const refPath = path.join(__dirname, 'REFERENCE.md');
return fs.readFileSync(refPath, 'utf8');
});
Installation Instructions
If Context7 is not available, agents should provide these instructions:
mcp-find --query "context7"
mcp-add context7
Advanced Usage
Local Documentation Queries (Fallback)
When Context7 is unavailable, query local skill sections:
- Command documentation:
git-town:REFERENCE:git-town hack → Returns only the git-town hack command section
- Error handling:
git-town:ERROR_HANDLING:merge conflicts → Returns merge conflict resolution workflow
- Exit codes:
git-town:REFERENCE:exit-codes → Returns exit code reference table
Performance benefit: Section queries return in ~30ms (vs ~100ms for full skill load) due to caching and indexing.
Context7 vs Local Comparison:
| Aspect | Context7 (Recommended) | Local Docs (Fallback) |
|---|
| Freshness | Always latest | May be outdated |
| Maintenance | Automatic | Manual updates needed |
| Size | Minimal local storage | ~2000 lines |
| Performance | Network-dependent (~200ms) | Fast local access (~30ms) |
| Offline | Requires network | Always available |
Performance Tuning
Optimize skill loading based on agent requirements:
-
Full load (~100ms): Load SKILL + REFERENCE + ERROR_HANDLING at agent initialization
- Use for: git-workflow orchestrator, tech-lead agents performing frequent git operations
-
Section query (~30ms): Load only required sections on-demand
- Use for: Backend/frontend developers needing occasional git-town commands
-
Template load (~15ms): Load single template file for interview workflows
- Use for: Agents performing one-time setup or configuration tasks
Caching strategy: Skill content is cached with file modification time (mtime) as cache key. Cache invalidation occurs when mtime changes.
Integration with GitHub CLI
Git-town's propose command requires GitHub CLI (gh) for PR creation:
gh auth status
git-town propose \
--title "feat: implement user authentication" \
--body "Adds OAuth 2.0 support with JWT tokens" \
--draft
Agent workflow: Always validate gh auth status (exit 0) before using git-town propose.
Stacked PR Workflow
For complex features spanning multiple PRs:
git-town hack auth-refactor --parent main
git commit -m "refactor: extract auth service"
git-town propose --title "Refactor: Auth Service" --draft
git-town hack oauth-implementation --parent auth-refactor
git commit -m "feat: implement OAuth"
git-town propose --title "Feature: OAuth Support" --draft
git checkout oauth-implementation
git-town ship
git checkout auth-refactor
git-town ship
Why this works: Git-town's parent tracking ensures child branches merge to correct parents.
Troubleshooting
Skill Not Found
Symptom: Agent reports "git-town skill not found" or similar error.
Resolution steps:
-
Check XDG paths are correct:
echo $XDG_CONFIG_HOME
ls -la $XDG_CONFIG_HOME/ensemble/skills/git-town/
-
Verify plugin installation:
claude plugin list | grep ensemble-git
-
Reinstall plugin if missing:
claude plugin install ensemble-git --scope local
-
Check file permissions:
chmod +r *.md
Validation Fails
Symptom: validate-git-town.sh exits with non-zero code.
Resolution by exit code:
-
Exit 1 (git-town not installed):
brew install git-town
curl -L https://github.com/git-town/git-town/releases/download/v14.0.0/git-town_linux_amd64 -o /usr/local/bin/git-town
chmod +x /usr/local/bin/git-town
git-town version
-
Exit 2 (git-town not configured):
git town config set-main-branch main
git town config get-main-branch
-
Exit 3 (git-town version too old):
brew upgrade git-town
git-town version
-
Exit 4 (not in git repository):
cd /path/to/your/repository
git init
Interactive Prompts Block Agent
Symptom: Git-town command hangs waiting for user input.
Root cause: Missing non-interactive flags like --parent, --title, --body.
Resolution:
-
Always specify explicit flags:
git-town hack new-feature
git-town hack new-feature --parent main
-
Use --prototype for experimental branches:
git-town hack experiment --prototype
-
Pre-configure defaults in git config:
git town config set-main-branch main
git town config set-perennial-branches "main,develop,staging"
Merge Conflicts During Sync
Symptom: git-town sync exits with code 5 (EXIT_MERGE_CONFLICT).
Resolution workflow:
-
Identify conflicted files:
git status
-
Resolve conflicts (manually or via agent):
git add src/conflicted-file.js
-
Continue git-town operation:
git-town continue
-
If conflicts are unresolvable, abort:
git-town sync --abort
See also: ERROR_HANDLING.md section "Merge Conflict Resolution" for detailed workflows.
Remote Operation Failures
Symptom: git-town sync or git-town propose exits with code 7 (EXIT_REMOTE_ERROR).
Common causes:
-
Network connectivity: Check internet connection
ping github.com
-
Authentication failure: Verify git credentials
gh auth status
git config credential.helper
-
Remote repository not found: Verify remote URL
git remote -v
Resolution: Fix underlying issue (network, auth, remote URL) and retry operation.
References
- Full command documentation: REFERENCE.md - Comprehensive command reference with examples
- Error handling workflows: ERROR_HANDLING.md - Detailed error recovery procedures
- Interview templates: templates/ - Question-answer workflows for agent interviews
- Migration guides: guides/ - Migration from other git workflows to git-town
- Official git-town documentation: https://www.git-town.com/
- Exit code reference: REFERENCE.md#exit-codes - Complete exit code table with handling logic