repo-best-practices-bootstrap
Skill4 starsChanged 10 months agoMITView on GitHub
Use when setting up new repositories or auditing existing ones for security and best practice compliance. Covers branch protection, secret scanning, CI/CD security, documentation, and agent enablement.
- Deletes or force-pushes
- 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
- persona-switchingSkill
- process-skill-routerSkill
- quality-gate-enforcementSkill
- release-tagging-planSkill
- 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
35 rules. About 0 are common, 28 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈28
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Ensure repositories have appropriate security and best practice features configured and enabled.
- Distinctive: line 20
Use this matrix to select the appropriate bootstrapping skill:
- Distinctive: line 46
Only need quality tooling (use automated-standards-enforcement)
- Distinctive: line 76
Write access to the target repository
- Distinctive: line 106
Run platform detection script
- Distinctive: line 107
Verify CLI tool is installed and authenticated
- Distinctive: line 108
If Bitbucket, inform user that manual configuration is required
- Very specific: line 112
Check for .repo-bootstrap.yml in repository root
- Very specific: line 116
Create .repo-bootstrap.yml with empty opt-outs
- Distinctive: line 122
Only individual features within a category can be opted out.
- Distinctive: line 131
If Yes: Proceed with configuration (Step 4)
- Distinctive: line 132
If No/Skip: Record opt-out with reason (Step 3a)
- Distinctive: line 141
When a user declines a feature:
- Distinctive: line 191
WARNING: Do NOT enable signed commits in branch protection until setup is verified.
- Distinctive: line 193
When user selects "Yes" to signed commits, guide them through setup interactively:
- Distinctive: line 207
Ask: "Do you have a GPG key configured for signing commits?"
- Distinctive: line 213
Add to platform (GitHub Settings > SSH and GPG keys)
- Distinctive: line 221
If Yes: Verify configuration:
- Very specific: line 230
Add blocking check to .husky/pre-commit:
- Very specific: line 249
Create .husky/pre-push to detect commits with invalid or missing signatures:
- Distinctive: line 331
After core configuration, offer multi-identity workflow setup:
- Distinctive: line 335
Check if persona-switching is already configured:
- Distinctive: line 349
Ask user: "Enable multi-identity workflow?" (Y/n)
- Very specific: line 364
Verify Setup: - Test use_persona and show_persona commands
- Distinctive: line 378
No justification required (optional feature).
- Distinctive: line 382
After persona-switching setup completes (or is declined), continue with Step 5.
- Distinctive: line 389
If lint-staged configured → Add linting job to CI
- Distinctive: line 390
If prettier configured → Add format check to CI
- Distinctive: line 391
If secretlint configured → Add secret scanning to CI
- Distinctive: line 394
Verify enforcement: Ensure same rules apply locally and in CI
- Distinctive: line 401
Document any items that could not be configured automatically
- Distinctive: line 415
When a feature is opted out, document the reason via ADR (preferred) or opt-out file.
- Very specific: line 419
Preferred: Use ADRs in docs/decisions/ to document opt-out decisions with full context.
- Very specific: line 421
Alternative: If ADRs are not used, store opt-outs in .repo-bootstrap.yml:
- Distinctive: line 434
Commit the opt-out documentation to persist decisions across sessions.
≈ “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
Repo Best Practices Bootstrap
Overview
Ensure repositories have appropriate security and best practice features configured and enabled. Applicable to both greenfield (new repository) and brownfield (existing repository) projects.
REQUIRED: superpowers:verification-before-completion
Bootstrapping Skills Decision Matrix
Use this matrix to select the appropriate bootstrapping skill:
| If You Need To... | Use This Skill |
| Start a new project from scratch | greenfield-baseline |
| Add/audit quality tooling (linting, tests, SAST) | automated-standards-enforcement |
| Add/audit repo security (branch protection, secret scanning) | repo-best-practices-bootstrap (this) |
Skill Scope Comparison
| Aspect | greenfield-baseline | automated-standards-enforcement | repo-best-practices-bootstrap |
| Primary Focus | Project foundation | Quality tooling | Repo security/compliance |
| Project State | New (no existing code) | New or existing | New or existing |
| Outputs | Repo structure, CI/CD, docs | Linting, tests, SAST config | Branch rules, secrets config |
| Triggers | Entry point for new projects | Auto-triggered or standalone | Invoke directly |
Invocation Context
- Greenfield projects: Invoke after greenfield-baseline establishes structure
- Brownfield projects: Invoke directly for security audit
- Compliance checks: Invoke directly for audit against checklist
Do NOT Use This Skill When
- Starting a brand new project without structure (use greenfield-baseline first)
- Only need quality tooling (use automated-standards-enforcement)
- Repository security already configured and passing audit
Categories covered:
- Repository Security - Branch protection, signed commits, secret scanning, vulnerability alerts
- CI/CD Security - Actions permissions, OIDC deployments, artifact signing, supply chain security
- Code Quality Gates - Required reviews, status checks, linting, no direct commits
- Documentation Baseline - README, CONTRIBUTING, LICENSE, SECURITY
- Agent Enablement - CLAUDE.md, AGENTS.md, skills bootstrap, pre-commit hooks
- Development Standards - .editorconfig, .gitignore, .gitattributes, pre-commit config
- Project Management - Project board linking, kanban/sprint workflow configuration
- Standard Tooling - husky, prettier, markdownlint, lint-staged, local secret scanning
- Multi-Identity Workflow (Optional) - Persona-switching for role-based commits and GPG signing
When to Use
- Setting up new repository (greenfield)
- Auditing existing repository (brownfield)
- User asks to "bootstrap", "secure", or "audit" a repository
- Compliance check requested
- Onboarding a repository to this skill library
Prerequisites
- Git CLI installed and authenticated
- Platform CLI installed and authenticated:
- GitHub:
ghCLI - Azure DevOps:
az reposCLI - GitLab:
glabCLI
- GitHub:
- Write access to the target repository
Platform Detection
Detect the platform from the git remote URL:
REMOTE_URL=$(git config --get remote.origin.url)
if [[ "$REMOTE_URL" =~ github\.com ]]; then
PLATFORM="github"
CLI_TOOL="gh"
elif [[ "$REMOTE_URL" =~ dev\.azure\.com|visualstudio\.com ]]; then
PLATFORM="azuredevops"
CLI_TOOL="az repos"
elif [[ "$REMOTE_URL" =~ gitlab\.com|gitlab\. ]]; then
PLATFORM="gitlab"
CLI_TOOL="glab"
elif [[ "$REMOTE_URL" =~ bitbucket\.org ]]; then
PLATFORM="bitbucket"
CLI_TOOL="manual" # No CLI support in MVP
fiSee Platform Detection for full detection logic and CLI requirements.
Core Workflow
Step 1: Platform Detection
- Run platform detection script
- Verify CLI tool is installed and authenticated
- If Bitbucket, inform user that manual configuration is required
Step 2: Load or Initialize Configuration
- Check for
.repo-bootstrap.ymlin repository root - If file exists: Parse opt-out categories and features, skip opted-out items
- If file does not exist (new repo):
- Inform user: "No bootstrap configuration found. I'll guide you through setup."
- Create
.repo-bootstrap.ymlwith empty opt-outs - Proceed to guided configuration (Step 3)
Step 3: Guided Configuration
MANDATORY: Walk through ALL 8 categories. Categories cannot be skipped. Only individual features within a category can be opted out.
For each category, interactively guide the user through configuration:
- Present the category and explain its purpose
- Check current state using platform CLI
- For each unconfigured feature:
- Explain what it does and why it matters
- Ask user: "Would you like to configure this? (Yes/No/Skip)"
- If Yes: Proceed with configuration (Step 4)
- If No/Skip: Record opt-out with reason (Step 3a)
- For paid features without free tier:
- Present free/open-source alternatives (see Cost Considerations)
- Offer to configure the alternative instead
See Checklist for the complete checklist with platform-specific commands.
Step 3a: Record Opt-Out Decision
When a user declines a feature:
- Ask for reason: "Why are you skipping this? (brief explanation)"
Record in
.repo-bootstrap.yml:opt_out: features: - feature-name # Reason: user explanationCreate ADR if significant: For security-related opt-outs, create an Architecture Decision Record in
docs/decisions/:# ADR-NNN: Skip [Feature Name] ## Status Accepted ## Context [Why this decision was made] ## Decision We will not implement [feature] because [reason]. ## Consequences [What this means for the project]
Step 4: Configure Features
For each feature the user wants to configure:
- Guide through options: Present configuration choices with recommendations
- Use platform CLI to enable/configure the feature
- Create files from templates and prompt user to customize:
- CODEOWNERS: "Who should be listed as code owners?"
- Branch protection: "What status checks should be required?"
- Dependabot: "Which package ecosystems do you use?"
- Commit changes with descriptive message referencing the feature
See templates in templates/ directory for documentation and configuration files.
Signed Commits (Special Handling)
WARNING: Do NOT enable signed commits in branch protection until setup is verified.
When user selects "Yes" to signed commits, guide them through setup interactively:
Step A: Check current GPG setup
# Check if GPG is installed
gpg --version
# Check for existing keys
gpg --list-secret-keys --keyid-format=longStep B: Guide through setup if needed
Ask: "Do you have a GPG key configured for signing commits?"
- If No: Guide through playbook steps:
- Generate key:
gpg --full-generate-key(RSA 4096, matching email) - Get key ID:
gpg --list-secret-keys --keyid-format=long - Export public key:
gpg --armor --export KEY_ID - Add to platform (GitHub Settings > SSH and GPG keys)
Configure git:
git config --global user.signingkey KEY_ID git config --global commit.gpgsign true
- Generate key:
If Yes: Verify configuration:
git config --get user.signingkey git config --get commit.gpgsign
Step C: Add git hook verification
Add blocking check to .husky/pre-commit:
# Require GPG commit signing to be configured
if [ "$(git config --get commit.gpgsign)" != "true" ]; then
echo ""
echo "❌ ERROR: GPG commit signing is not enabled"
echo " All commits must be cryptographically signed."
echo ""
echo " To enable signed commits:"
echo " 1. Follow the setup guide: docs/playbooks/enable-signed-commits.md"
echo " 2. Configure git: git config --global commit.gpgsign true"
echo " 3. Ensure your GPG key is added to GitHub"
echo ""
echo "ℹ️ To bypass (not recommended): git commit --no-verify"
exit 1
fiCreate .husky/pre-push to detect commits with invalid or missing signatures:
# Check for unsigned or invalid commits before pushing
# Valid signatures: G (Good), U (Good but untrusted)
# Invalid: N (None), B (Bad), E (Error), R (Revoked), X/Y (Expired)
REMOTE="$1"
URL="$2"
# Detect the default branch dynamically
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
if [ -z "$DEFAULT_BRANCH" ]; then
DEFAULT_BRANCH="main"
fi
while read local_ref local_sha remote_ref remote_sha; do
# Skip branch deletions and tag pushes
if [ "$local_sha" = "0000000000000000000000000000000000000000" ]; then
continue
fi
if echo "$local_ref" | grep -q '^refs/tags/'; then
continue
fi
if [ "$remote_sha" = "0000000000000000000000000000000000000000" ]; then
# New branch - check commits since divergence from default branch
merge_base=$(git merge-base "origin/$DEFAULT_BRANCH" "$local_sha" 2>/dev/null)
if [ -n "$merge_base" ]; then
range="$merge_base..$local_sha"
else
range="$local_sha~50..$local_sha"
fi
else
range="$remote_sha..$local_sha"
fi
# Check for any non-valid signatures
invalid=$(git log --format="%H %G?" "$range" 2>/dev/null | grep -vE " [GU]$" | cut -d' ' -f1)
if [ -n "$invalid" ]; then
echo ""
echo "❌ ERROR: Found commits with invalid or missing signatures"
echo ""
echo "To fix, rebase and re-sign your commits:"
echo ""
echo " git rebase origin/$DEFAULT_BRANCH --exec 'git commit --amend --no-edit -S'"
echo " git push --force-with-lease"
echo ""
echo "See: docs/playbooks/enable-signed-commits.md"
echo ""
echo "ℹ️ To bypass (not recommended): git push --no-verify"
exit 1
fi
done
exit 0Step D: Test before enabling branch protection
# Create test commit
git commit --allow-empty -m "test: verify GPG signing"
# Verify signature
git log --show-signature -1Step E: Enable branch protection only after test passes
# GitHub
gh api repos/OWNER/REPO/branches/main/protection/required_signatures -X POSTGenerate docs/playbooks/enable-signed-commits.md from template for future reference.
See Signed Commits Playbook Template.
Step 4a: Persona-Switching Integration (Optional)
After core configuration, offer multi-identity workflow setup:
Detection
Check if persona-switching is already configured:
# Check for existing playbook
if [ -f "docs/playbooks/persona-switching.md" ]; then
echo "Persona-switching already configured - skipping"
# Report as "already configured" in summary
else
# Proceed to prompt
fiPrompt
Ask user: "Enable multi-identity workflow?" (Y/n)
- Default: No (persona-switching is optional)
- If Yes: Chain to persona-switching skill setup flow
- If No: Record opt-out and continue
If Enabled
Chain to persona-switching skill setup flow:
- Role Discovery - Parse existing
docs/roles/*.mdor use defaults - Security Profile Configuration - Map personas to GitHub accounts
- Generate Artifacts:
docs/playbooks/persona-switching.md- Repository playbook~/.config/<repo-name>/persona-config.sh- User's shell config
- Verify Setup - Test
use_personaandshow_personacommands
See persona-switching skill for full setup flow.
If Declined
Record opt-out in .repo-bootstrap.yml:
opt_out:
features:
- persona-switching # optional - user declinedNo justification required (optional feature).
Continue Bootstrap
After persona-switching setup completes (or is declined), continue with Step 5.
Step 5: Generate CI/CD Workflow
IMPORTANT: Pre-commit hooks can be bypassed. CI/CD enforcement is mandatory.
- Mirror pre-commit rules in CI/CD:
- If lint-staged configured → Add linting job to CI
- If prettier configured → Add format check to CI
- If secretlint configured → Add secret scanning to CI
- Generate workflow file from template (
.github/workflows/ci.yml) - Configure branch protection to require CI checks pass before merge
- Verify enforcement: Ensure same rules apply locally and in CI
See CI/CD Templates for workflow templates.
Step 6: Verify Configuration
- Re-run checklist to verify all selected items are now compliant
- Document any items that could not be configured automatically
- Run CI workflow to verify it passes
- Report final compliance status
Opt-Out Mechanism
Users can opt out of specific features within a category. Opt-outs are respected during checklist execution and do not generate gaps.
IMPORTANT: Categories cannot be skipped. All 8 categories must be presented to the user. Only individual features can be opted out.
Feature opt-out: Skip a specific feature (with documented reason)
When a feature is opted out, document the reason via ADR (preferred) or opt-out file.
Opt-Out Persistence
Preferred: Use ADRs in docs/decisions/ to document opt-out decisions with full context.
Alternative: If ADRs are not used, store opt-outs in .repo-bootstrap.yml:
# .repo-bootstrap.yml
# Repository bootstrap configuration
# See: skills/repo-best-practices-bootstrap/SKILL.md
opt_out:
features:
- signed-commits # Reason: team not using GPG keys
- artifact-signing # Reason: not publishing artifactsCommit the opt-out documentation to persist decisions across sessions.
Cost Considerations
Some features require paid plans. The checklist indicates cost for each feature.
See Cost Considerations for:
- Features requiring paid plans
- Free alternatives for each paid feature
- Platform-specific pricing notes
See Also
- Checklist - Complete checklist with platform-specific commands
- Platform Detection - Detection logic and CLI requirements
- Cost Considerations - Paid features and free alternatives
- skills-first-workflow AGENTS Template - Template for AGENTS.md file
Minimum Viable Bootstrap Profile
The minimum viable set of practices to bootstrap a repository.
See Minimum Viable Bootstrap Profile.
Automated Feature Checks
Automated checks that detect which practices/features are already present.
See Automated Feature Checks.
Red Flags - STOP
These statements indicate bootstrap anti-patterns:
| Thought | Reality |
| "We'll add security later" | Security debt compounds; configure branch protection and scanning from day one |
| "Pre-commit hooks are enough" | Hooks can be bypassed; CI/CD enforcement is mandatory |
| "Secret scanning isn't needed yet" | One leaked secret is one too many; enable scanning immediately |
| "Documentation can wait" | README and CONTRIBUTING attract contributors; invest early |
| "Skip signed commits, it's complex" | Verified commits prevent impersonation; follow the playbook |
| "We don't need all these checks" | Document opt-outs with justification; don't silently skip |
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.

