From 2be9dd82a1d2032c73209a0b4cce123d2da01aa4 Mon Sep 17 00:00:00 2001 From: Lex Christopherson Date: Tue, 16 Dec 2025 09:00:11 -0600 Subject: [PATCH] fix: ensure git init runs in current directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove silent="true" which caused step to be skipped - Make setup step explicit with MANDATORY instruction - Check for both .git directory AND .git file (worktrees/submodules) - Add explicit "You MUST run using Bash tool" instruction Prevents commits going to parent repo when initializing projects in subdirectories. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- commands/gsd/new-project.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/commands/gsd/new-project.md b/commands/gsd/new-project.md index db32d7531..29cb6368c 100644 --- a/commands/gsd/new-project.md +++ b/commands/gsd/new-project.md @@ -24,22 +24,30 @@ Creates `.planning/` with PROJECT.md and config.json. !`[ -d .planning ] && echo "PLANNING_EXISTS" || echo "NO_PLANNING"` -!`[ -d .git ] && echo "GIT_EXISTS" || echo "NO_GIT"` - -Silent setup - execute before any user output: + +**MANDATORY FIRST STEP — Execute these checks before ANY user interaction:** -```bash -# Abort if project exists -[ -d .planning ] && echo "Project already initialized. Use /gsd:progress" && exit 1 +1. **Abort if project exists:** + ```bash + [ -d .planning ] && echo "ERROR: Project already initialized. Use /gsd:progress" && exit 1 + ``` -# Initialize git -[ -d .git ] || git init -``` +2. **Initialize git repo in THIS directory** (required even if inside a parent repo): + ```bash + # Check if THIS directory is already a git repo root (handles .git file for worktrees too) + if [ -d .git ] || [ -f .git ]; then + echo "Git repo exists in current directory" + else + git init + echo "Initialized new git repo" + fi + ``` + **You MUST run both bash commands above using the Bash tool before proceeding.**