Initialize Repository
Initialize a new git repository with comprehensive .gitignore, root shared agent instructions, GitHub remote, and branch protection.
Usually run automatically from mp-project-register step 3 (read-and-follow) when a
project has no .git/ yet.
Instructions
Check for existing git repo: If .git/ already exists, inform the user and abort.
Run the init script: Execute the initialization script:
node ${CLAUDE_PLUGIN_ROOT}/../mp/scripts/init-repo.mjs
Create .mpx/ structure: Use ${CLAUDE_PLUGIN_ROOT}/../mp/skills/shared/PROJECT_DOC_TEMPLATES.md as the single source for .mpx/CONTEXT.md and .mpx/DECISIONS.md. Preserve any existing file that already contains substantive planning, research, or prior grilling output. Create only files that are missing or still untouched placeholders, reproducing the canonical scaffold exactly and replacing the project-name placeholder in newly created files. Before committing, verify that each file contains either preserved substantive content or a newly created canonical scaffold. Then run exactly:
git add .mpx/CONTEXT.md .mpx/DECISIONS.md
git commit -m "docs: initialize project documentation"
This separate commit is needed because init-repo.mjs commits before .mpx/ exists.
Ask repo visibility: Ask the user whether the GitHub repo should be private (default/recommended) or public.
Create GitHub repo and push:
- Rename default branch to
main: git branch -m master main (if needed)
- Create GitHub repo using the current directory name:
gh repo create <repo-name> --private|--public --source=. --push
- Create and push
dev branch:git checkout -b dev && git push -u origin dev
- Set
dev as the default branch:gh api repos/{owner}/{repo} -X PATCH --field default_branch=dev
Set up branch protection on both main and dev:
gh api repos/{owner}/{repo}/branches/{branch}/protection -X PUT --input - <<'EOF'
{
"required_status_checks": {"strict": false, "contexts": ["checks"]},
"enforce_admins": true,
"required_pull_request_reviews": {"required_approving_review_count": 0},
"restrictions": null
}
EOF
- If protection fails with HTTP 403 (GitHub Free plan limitation on private repos), warn the user but continue without aborting. Suggest they upgrade to Pro or make the repo public to enable branch protection later.
Report results: Show the user what was created or preserved:
- Local structure (
.git/, .gitignore, .gitattributes, .editorconfig, AGENTS.md when absent and otherwise preserved, CLAUDE.md when absent and otherwise preserved, .mpx/)
- GitHub repo URL
- Branch setup (
main + dev, default = dev)
- Branch protection status (applied or skipped)
What Gets Created
project/
├── .git/
├── .gitignore # Comprehensive multi-language
├── .gitattributes # Line ending normalization
├── .editorconfig # Editor consistency settings
├── AGENTS.md # Created when absent; otherwise preserved
├── CLAUDE.md # Created when absent; otherwise preserved
└── .mpx/
├── CONTEXT.md # Domain language, feature index, constraints
└── DECISIONS.md # Settled architectural decisions
GitHub:
├── Remote repo (private or public)
├── Branches: main, dev (default)
└── Branch protection on main + dev (if plan supports it)
Notes
.gitignore is copied from templates/gitignore.template — deterministic, no LLM generation
- Project-specific ignores (e.g., Obsidian's
main.js, data.json) should be appended after init
.mpx/ is intentionally NOT ignored — requirements and decisions should be versioned
- Branch protection requires GitHub Pro for private repos; skill degrades gracefully on Free plan
dev is always the default branch — development happens there, main is for stable/releases
- Required status check
checks is a placeholder; actual CI workflow added separately
1---2name: init-repo3description: Initializes a git repo, pushes it to GitHub, and sets up branch protection.4---56# Initialize Repository78Initialize a new git repository with comprehensive .gitignore, root shared agent instructions, GitHub remote, and branch protection.910Usually run automatically from `mp-project-register` step 3 (read-and-follow) when a11project has no `.git/` yet.1213## Instructions14151. **Check for existing git repo**: If `.git/` already exists, inform the user and abort.16172. **Run the init script**: Execute the initialization script:1819 ```bash20 node ${CLAUDE_PLUGIN_ROOT}/../mp/scripts/init-repo.mjs21 ```22233. **Create `.mpx/` structure**: Use `${CLAUDE_PLUGIN_ROOT}/../mp/skills/shared/PROJECT_DOC_TEMPLATES.md` as the single source for `.mpx/CONTEXT.md` and `.mpx/DECISIONS.md`. Preserve any existing file that already contains substantive planning, research, or prior grilling output. Create only files that are missing or still untouched placeholders, reproducing the canonical scaffold exactly and replacing the project-name placeholder in newly created files. Before committing, verify that each file contains either preserved substantive content or a newly created canonical scaffold. Then run exactly:2425 ```bash26 git add .mpx/CONTEXT.md .mpx/DECISIONS.md27 git commit -m "docs: initialize project documentation"28 ```2930 This separate commit is needed because `init-repo.mjs` commits before `.mpx/` exists.31324. **Ask repo visibility**: Ask the user whether the GitHub repo should be **private** (default/recommended) or **public**.33345. **Create GitHub repo and push**:35 - Rename default branch to `main`: `git branch -m master main` (if needed)36 - Create GitHub repo using the current directory name:37 ```bash38 gh repo create <repo-name> --private|--public --source=. --push39 ```40 - Create and push `dev` branch:41 ```bash42 git checkout -b dev && git push -u origin dev43 ```44 - Set `dev` as the default branch:45 ```bash46 gh api repos/{owner}/{repo} -X PATCH --field default_branch=dev47 ```48496. **Set up branch protection** on both `main` and `dev`:50 ```bash51 gh api repos/{owner}/{repo}/branches/{branch}/protection -X PUT --input - <<'EOF'52 {53 "required_status_checks": {"strict": false, "contexts": ["checks"]},54 "enforce_admins": true,55 "required_pull_request_reviews": {"required_approving_review_count": 0},56 "restrictions": null57 }58 EOF59 ```60 - If protection fails with HTTP 403 (GitHub Free plan limitation on private repos), **warn the user** but continue without aborting. Suggest they upgrade to Pro or make the repo public to enable branch protection later.61627. **Report results**: Show the user what was created or preserved:63 - Local structure (`.git/`, `.gitignore`, `.gitattributes`, `.editorconfig`, `AGENTS.md` when absent and otherwise preserved, `CLAUDE.md` when absent and otherwise preserved, `.mpx/`)64 - GitHub repo URL65 - Branch setup (`main` + `dev`, default = `dev`)66 - Branch protection status (applied or skipped)6768## What Gets Created6970```71project/72├── .git/73├── .gitignore # Comprehensive multi-language74├── .gitattributes # Line ending normalization75├── .editorconfig # Editor consistency settings76├── AGENTS.md # Created when absent; otherwise preserved77├── CLAUDE.md # Created when absent; otherwise preserved78└── .mpx/79 ├── CONTEXT.md # Domain language, feature index, constraints80 └── DECISIONS.md # Settled architectural decisions8182GitHub:83├── Remote repo (private or public)84├── Branches: main, dev (default)85└── Branch protection on main + dev (if plan supports it)86```8788## Notes8990- `.gitignore` is copied from `templates/gitignore.template` — deterministic, no LLM generation91- Project-specific ignores (e.g., Obsidian's `main.js`, `data.json`) should be appended after init92- `.mpx/` is intentionally NOT ignored — requirements and decisions should be versioned93- Branch protection requires GitHub Pro for private repos; skill degrades gracefully on Free plan94- `dev` is always the default branch — development happens there, `main` is for stable/releases95- Required status check `checks` is a placeholder; actual CI workflow added separately