persona-switching
Skill4 starsChanged 10 months agoMITView on GitHub
Use when setting up multi-identity Git/GitHub workflows or when phase transitions require role-specific personas for commits and operations.
- Deletes or force-pushes
- Installs packages
- Commits and pushes
In this repository67 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agents-onboardingSkill
- agent-workitem-automationSkill
- architecture-testingSkill
- aspire-integration-testingSkill
- automated-standards-enforcementSkill
- best-practice-introductionSkill
- branching-strategy-and-conventionsSkill
- broken-windowSkill
- change-risk-rollbackSkill
- ci-cd-conformanceSkill
- component-boundary-ownershipSkill
- contract-consistency-validationSkill
- csharp-best-practicesSkill
- deployment-provenanceSkill
- documentation-as-codeSkill
- documentation-scaffoldSkill
- dotnet-bespoke-code-minimisationSkill
- dotnet-best-practicesSkill
- dotnet-domain-primitivesSkill
- dotnet-efcore-practicesSkill
- dotnet-healthchecksSkill
- dotnet-logging-serilogSkill
- dotnet-mapping-standardSkill
- dotnet-open-source-first-governanceSkill
- dotnet-source-generation-firstSkill
- dotnet-specification-patternSkill
- dotnet-testing-assertionsSkill
- environment-traceabilitySkill
- finishing-a-development-branch-iddSkill
- greenfield-baselineSkill
- impacted-scope-enforcementSkill
- incremental-change-impactSkill
- incremental-deploymentSkill
- innersource-governance-bootstrapSkill
- issue-driven-deliverySkill
- library-extraction-stabilisationSkill
- local-dev-experienceSkill
- markdown-authorSkill
- modern-csharp-coding-standardsSkill
- monorepo-orchestration-setupSkill
- observability-logging-baselineSkill
- pair-programmingSkill
- process-skill-routerSkill
- quality-gate-enforcementSkill
- release-tagging-planSkill
- repo-best-practices-bootstrapSkill
- repository-foundation-bootstrapSkill
- requirements-gatheringSkill
- runtime-tooling-validationSkill
- safe-brownfield-refactorSkill
- scoped-colocationSkill
- security-processesSkill
- selective-build-testSkill
- semantic-version-impactSkill
- session-awareSkill
- skills-first-workflowSkill
- static-analysis-securitySkill
- structured-review-workflowSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 10 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 28
Permissions: Write access to ~/.config/<repo-name>/ for shell config
- Distinctive: line 41
Check for existing persona configuration in target repo
- Distinctive: line 42
If missing: run Setup Flow (role discovery, security profile configuration, artifact generation)
- Very specific: line 44
Use use_persona <role> to switch to appropriate persona for current task
- Very specific: line 45
Verify switch with show_persona and gh auth status
- Very specific: line 51
Check for existing docs/playbooks/persona-switching.md in target repo
- Distinctive: line 52
If exists: Skill provides runtime guidance only
- Distinctive: line 53
If missing: Skill triggers setup flow first
- Distinctive: line 171
Before transitioning from Implementation to Verification:
- Distinctive: line 175
Only after specialist sign-off does work move to QA
- Distinctive: line 200
When branch protection rules require different accounts for PR creation and approval, use the two-account workflow.
- Very specific: line 361
Always use use_persona to switch (handles all config atomically)
- Distinctive: line 363
Use contributor profile for implementation work
- Distinctive: line 430
If persona switching fails or corrupts Git config:
- Very specific: line 445
If gh CLI is in wrong account:
- Distinctive: line 460
If completely corrupted, reset everything:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Persona-Switching
Overview
Enable repositories to adopt multi-identity Git/GitHub workflows where agents work under role-specific personas (e.g., "Claude (Backend Engineer)") while maintaining GPG signing integrity and appropriate permission levels.
Skill announcement: "Using persona-switching to [set up multi-identity workflow | switch to appropriate role | suggest persona for this phase]."
Prerequisites
- Shell: Bash or Zsh (Windows PowerShell not supported - see Limitations)
- GPG: Installed with keys configured for each identity email
- gh CLI: Installed and authenticated for each GitHub account
- Permissions: Write access to
~/.config/<repo-name>/for shell config
When to Use
| Trigger Type | Condition | Action |
| Explicit | User requests "set up personas" or "switch persona" | Full setup or quick switch |
| Bootstrap | repo-best-practices-bootstrap runs on target repo | Prompt: "Enable multi-identity workflow?" |
| Workflow | issue-driven-delivery phase transition | Suggest appropriate persona for phase |
| Role mismatch | Current persona doesn't match task context | Recommend persona switch |
Core Workflow
- Check for existing persona configuration in target repo
- If missing: run Setup Flow (role discovery, security profile configuration, artifact generation)
- Source the persona config script for current session
- Use
use_persona <role>to switch to appropriate persona for current task - Verify switch with
show_personaandgh auth status - Perform work under the switched persona identity
- Switch back to appropriate persona when task context changes
Detection Logic
- Check for existing
docs/playbooks/persona-switching.mdin target repo - If exists: Skill provides runtime guidance only
- If missing: Skill triggers setup flow first
Setup Flow
Step 1: Role Discovery
1. Check target repo for docs/roles/*.md
|-- Found: Parse frontmatter for role metadata
| Fallback to file content if no frontmatter
| Last resort: derive from filename
+-- Not found: Use reference personas as defaults
2. Present discovered/default personas to user
+-- User can add, remove, or rename
3. For each persona, prompt for security profile mapping
+-- Suggest based on role type (dev work vs elevated ops)Role file parsing priority:
- Frontmatter:
name:,title:, orrole:fields - Content: First H1 heading as role name
- Filename fallback:
tech-lead.md-> "Tech Lead"
Step 2: Security Profile Configuration
Configure N security profiles based on repository needs.
Default profiles (reference):
| Profile | Purpose | Typical Permissions |
contributor | Standard development work | Push to branches, create PRs |
maintainer | Elevated operations | Merge PRs, manage labels, close issues |
admin | Repository administration | Branch protection, settings, releases |
Configuration format:
security_profiles:
contributor:
github_account: "dev-bot-account"
email: "dev@company.com"
gpg_key: "ABC123..."
maintainer:
github_account: "lead-bot-account"
email: "lead@company.com"
gpg_key: "DEF456..."Step 3: Generate Artifacts
- Generate playbook:
docs/playbooks/persona-switching.md - Generate shell config:
~/.config/<repo-name>/persona-config.sh - Set file permissions:
chmod 600on shell config (contains account mappings) - Provide sourcing instructions for user's shell profile
Runtime Usage
Switching Personas
# Source the config (add to shell profile for persistence)
source ~/.config/<repo-name>/persona-config.sh
# Switch to a persona
use_persona backend-engineer
# Verify current persona
show_personaWhat use_persona Does
- Switches
ghCLI to correct GitHub account - Updates Git config:
user.name,user.email,user.signingkey - Verifies GPG key is available
- Reports success or failure with actionable message
Persona-to-Profile Mapping
Each persona maps to exactly one security profile:
| Persona | Default Profile | Rationale |
| Backend Engineer | contributor | Implementation work |
| Frontend Engineer | contributor | Implementation work |
| QA Engineer | contributor | Test development |
| Tech Lead | maintainer | Approvals, label management |
| Scrum Master | maintainer | Issue triage, workflow management |
| Security Engineer | contributor | Reviews (escalate to maintainer if needed) |
Ownership Model
Phase Ownership (issue-driven-delivery integration)
| Phase | Default Owner | Delegation Pattern |
| Refinement | Tech Lead | Invokes specialists for domain-specific input |
| Implementation | Domain expert (varies) | Invokes specialists for sub-tasks + pre-verification reviews |
| Verification | QA Engineer | Invokes Architecture/Security/Performance for expert reviews |
| Review/Approval | Tech Lead | Lightweight - work already validated |
Delegation Mechanics
| Situation | Mechanism | Rationale |
| Quick review (< 10 min) | Persona switch | Low overhead, stays in flow |
| Substantial sub-task | Sub-agent delegation | Parallel work, cleaner separation |
| Multi-domain work | Multiple sub-agents | Backend + Frontend simultaneously |
| Expert consultation | Persona switch | Brief input, owner retains context |
Rule of thumb: Switch for >3 commits in a role; delegate for single focused tasks.
"Dev Complete" Gate
Before transitioning from Implementation to Verification:
- Owner invokes relevant specialist personas for review
- Each specialist validates their domain concerns
- Only after specialist sign-off does work move to QA
This front-loads validation so final Review/Approval is a formality.
Workflow Integration
Automatic Suggestions
| Workflow Step | Persona Suggestion | Trigger |
| Step 3b (refinement start) | Tech Lead | state:refinement label added |
| Step 7a (implementation handoff) | Domain expert based on task | state:implementation label added |
| Step 8c (verification start) | QA Engineer | state:verification label added |
| Step 11 (role reviews) | Relevant specialists | Review request in workflow |
GPG Signing Compatibility
Persona switching preserves GPG validity because:
- GPG validates against email, not author name
- Each security profile has consistent email + GPG key pairing
- Author name changes ("Claude (Backend Engineer)") don't break signatures
Two-Account Review Workflow
When branch protection rules require different accounts for PR creation and approval, use the two-account workflow.
Rationale
Branch protection often requires:
- PR cannot be merged by the author
- Code owner approval required
- Commits must be signed
This creates a natural separation:
| Account | Profile | Operations |
| Contributor | contributor | Create branches, push commits, open PR |
| Maintainer | maintainer | Review PR, approve, merge |
Workflow Steps
Implementation Phase (contributor account)
↓
1. use_persona backend-engineer # contributor profile
2. Implement changes
3. Commit and push
4. Create PR (gh pr create)
↓
Review Phase (maintainer account)
↓
5. use_persona tech-lead # maintainer profile
6. Review PR (gh pr view, gh pr diff)
7. Approve PR (gh pr review --approve)
8. Merge PR (gh pr merge --squash)
↓
Resume (contributor account)
↓
9. use_persona backend-engineer # back to contributor
10. Continue with next taskAccount Switching Commands
# Switch to contributor for implementation
use_persona backend-engineer
gh auth status # Verify: contributor account
# Create PR
gh pr create --title "feat: description" --body "..."
# Switch to maintainer for review
use_persona tech-lead
gh auth status # Verify: maintainer account
# Review and merge
gh pr review <number> --approve --body "LGTM"
gh pr merge <number> --squash --delete-branch
# Switch back for next work
use_persona backend-engineerWhy Not Single Account?
Single-account workflows bypass important controls:
| Control | Two-Account | Single-Account |
| Self-merge prevention | ✅ Enforced by GitHub | ❌ Requires discipline |
| Audit trail | ✅ Clear author/approver | ⚠️ Same identity |
| Permission isolation | ✅ Least privilege | ❌ Elevated always |
| Code owner approval | ✅ Different code owner | ❌ Same person |
Integration with Pair Programming
The pair-programming skill uses two-account workflow automatically:
- Agent works as contributor during implementation
- Agent switches to maintainer for self-review (automated review loop)
- Human reviewer uses their account for final approval
- Agent (as maintainer) can merge after human approval
See skills/pair-programming/SKILL.md for complete workflow.
Common Mistakes
| Mistake | Impact | Prevention |
| Creating PR as maintainer | Can't approve own PR | Always create PR as contributor |
| Approving as contributor | Approval rejected | Switch to maintainer for reviews |
| Merging without switching | Merge fails or bypasses checks | Verify gh auth status first |
| Staying elevated after merge | Over-privileged for next task | Switch back to contributor |
Security Considerations
Credential Storage
- GPG keys: Stored in user's GPG keyring (managed by
gpg-agent) - GitHub tokens: Managed by
ghCLI (stored in~/.config/gh/hosts.yml) - Shell config: Contains account mappings but NO secrets
GPG Agent Caching
Configure gpg-agent for passphrase caching to avoid repeated prompts:
# ~/.gnupg/gpg-agent.conf
default-cache-ttl 3600
max-cache-ttl 7200Shell History
The use_persona command does NOT expose secrets in shell history.
Profile names are safe to log; actual credentials remain in secure storage.
File Permissions
Generated shell config MUST have restricted permissions:
chmod 600 ~/.config/<repo-name>/persona-config.shThis prevents other users from reading account mappings.
Limitations
Platform Compatibility
| Platform | Status | Notes |
| Linux | ✅ Supported | Native bash environment |
| macOS | ✅ Supported | Requires bash 4.0+ (brew install bash) |
| Windows (WSL2) | ✅ Supported | Use WSL2 with GPG4Win bridge |
| Windows (Git Bash) | ⚠️ Partial | Works but GPG integration complex |
| Windows (PowerShell) | ❌ Not Supported | Bash/Zsh shell required |
Windows Users: This skill requires a bash-compatible shell. Options:
- WSL2 (Recommended): Install WSL2 with Ubuntu, configure GPG passthrough
- Git Bash: Install Git for Windows, use bundled bash with GPG4Win
Other Limitations
- SSH signing: GPG-based signing only; SSH signing keys planned for future
- Platform scope: GitHub-focused; Azure DevOps/GitLab integration planned
- Bash version: Requires bash 4.0+ for associative arrays
Common Mistakes
Red flags - STOP:
- "I'll just change user.email manually" (breaks GPG signing)
- "Skip persona switch, it's a small change" (loses audit trail)
- "Use admin profile for everything" (violates least-privilege)
- "Commit as maintainer during implementation" (wrong permission level)
Correct approach:
- Always use
use_personato switch (handles all config atomically) - Switch to appropriate role even for small changes
- Use contributor profile for implementation work
- Elevate to maintainer only for approvals/merges
Evidence Requirements
Setup Evidence
- Playbook generated at
docs/playbooks/persona-switching.md - Shell config generated with
chmod 600permissions - GPG keys validated for all configured emails
use_personaandshow_personacommands tested
Runtime Evidence
- Persona switch logged in session
show_personaconfirms correct identitygh auth statusshows expected account- Test commit verifies GPG signature valid
Validation Commands
Verify Current Persona State
# Show current Git identity
git config user.name
git config user.email
git config user.signingkey
# Show current GitHub account
gh auth status
# Combined verification
show_personaTest GPG Signing
# Verify GPG key exists and can sign
echo "test" | gpg --clearsign --local-user "$(git config user.email)"
# Verify commit signing works
git commit --allow-empty -m "test: verify GPG signing" --gpg-sign
git log -1 --show-signature
git reset --hard HEAD~1 # Remove test commitValidate Persona Configuration
# Check persona config exists
ls -la ~/.config/<repo-name>/persona-config.sh
# Check file permissions (should be 600)
stat -c "%a" ~/.config/<repo-name>/persona-config.sh # Linux
stat -f "%Lp" ~/.config/<repo-name>/persona-config.sh # macOS
# List available personas
source ~/.config/<repo-name>/persona-config.sh
use_persona # With no argument, lists available personasRollback Procedure
Reset to Default Git Identity
If persona switching fails or corrupts Git config:
# Reset to default identity (from ~/.gitconfig)
git config --unset user.name
git config --unset user.email
git config --unset user.signingkey
# Verify reset
git config --global user.name # Should show global default
git config --global user.email # Should show global defaultReset GitHub CLI Auth
If gh CLI is in wrong account:
# List authenticated accounts
gh auth status
# Switch to correct account
gh auth switch --user <account-name>
# If account not listed, re-authenticate
gh auth loginEmergency Rollback (All Settings)
If completely corrupted, reset everything:
# 1. Clear local git config
git config --unset-all user.name
git config --unset-all user.email
git config --unset-all user.signingkey
# 2. Reset gh auth
gh auth logout --hostname github.com
gh auth login
# 3. Regenerate persona config
rm ~/.config/<repo-name>/persona-config.sh
# Re-run persona-switching setupReferences
references/persona-config-template.sh- Shell script templatereferences/playbook-template.md- Playbook template for target reposreferences/security-profiles.md- Profile configuration guidancereferences/delegation-patterns.md- When to switch vs delegatereferences/workflow-integration.md- issue-driven-delivery integration
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

