context-methodology
Knowledge about the context branch methodology for separating AI configuration from project code using git worktrees. Use when users ask about worktree structure, branch organization, or the separation of concerns pattern.
What this skill does
# Context Branch Methodology
This skill provides knowledge about the **context branch methodology** - a pattern for separating AI assistant configuration from project source code using git worktrees.
## The Problem
When using AI coding assistants like Claude Code, projects accumulate:
- `CLAUDE.md` files with instructions
- `.claude/` directories with settings, commands, agents
- Custom hooks and configurations
These files:
1. Clutter project history with AI-specific commits
2. Mix tooling concerns with business logic
3. Create noise in code reviews
4. May contain sensitive prompts or configurations
## The Solution
Use **two independent git histories** in the same repository:
### Branch Structure
| Branch | Purpose | Contains |
|--------|---------|----------|
| `context` | AI configuration | CLAUDE.md, .claude/, settings |
| `main`/`master` | Project code | Source code, tests, docs |
| `feature/*` | Development | Feature work (descends from main/master) |
### Directory Layout
```
bare-repo/
└── root/
├── context/ # context branch worktree
│ ├── CLAUDE.md # AI instructions
│ ├── .claude/ # Commands, agents, skills
│ ├── .gitignore # Contains: worktree/**/
│ └── worktree/ # All code worktrees here
│ ├── feature/
│ │ └── my-feature/ # Feature branch worktree
│ └── fix/
│ └── bug-123/ # Bugfix branch worktree
└── main/ # main/master branch (direct access, read-only)
```
### Key Insight
The `context` branch's `.gitignore` contains `worktree/**/`, so:
- Nested worktrees are invisible to context commits
- AI config and code remain in separate histories
- Claude Code runs from `context/`, sees both contexts
## Detecting the Default Branch
Repositories may use either `main` or `master` as their default branch. Always detect it:
```bash
# Method 1: From remote HEAD (most reliable if remote exists)
git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'
# Method 2: Check which branch exists locally
git branch -l main master 2>/dev/null | head -1 | tr -d '* '
# Method 3: Combined approach
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || git branch -l main master 2>/dev/null | head -1 | tr -d '* ')
```
## Workflow
### Creating a New Feature
```bash
# From the context worktree
cd root/context
# Detect default branch
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main")
# Create feature worktree from default branch
git worktree add -b feature/my-feature worktree/feature/my-feature $DEFAULT_BRANCH
# Work in the feature
cd worktree/feature/my-feature
# ... make changes ...
# Commit and push
git add . && git commit -m "feat: add feature"
git push -u origin feature/my-feature
# Create PR targeting default branch
gh pr create --base $DEFAULT_BRANCH
```
### Updating AI Configuration
```bash
# From context worktree (root/context)
# Edit CLAUDE.md or .claude/ files
git add .
git commit -m "context: update AI instructions"
git push origin context
```
## Rules
1. **Never edit `root/main/` or `root/master/` directly** - always use a worktree
2. **All code worktrees inside `worktree/`** - maintains the separation
3. **Feature branches from default branch** - not from `context`
4. **Context branch is orphan** - no shared history with main/master
5. **PRs target default branch** - context changes stay on context branch
## Benefits
- Clean project history (no AI config commits)
- Separate concerns (tooling vs code)
- Team flexibility (share context or keep personal)
- Easy experimentation (modify AI config without affecting code)
## Common Questions
**Q: How does Claude Code see both contexts?**
A: Claude runs from the `context/` directory, which contains both the AI config files AND the `worktree/` folder with code. The parent CLAUDE.md applies to nested directories.
**Q: Can I have multiple context branches?**
A: Yes! You could have `context-personal` and `context-team` for different configurations.
**Q: What if I need different AI config per feature?**
A: Each worktree can have its own `.claude/` that overrides or extends the parent context.
**Q: How do I migrate an existing repo?**
A: Use the `/context-init` command or the `worktree-manager` agent to set up the structure.
**Q: Does it work with both main and master?**
A: Yes! The commands auto-detect the default branch. You can also explicitly specify the base branch as an argument.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.