Part of Unit 1 — Local-mode empty-folder unblock (P0) from the auto-research master plan.
Scope
Prepend an idempotent git init + empty commit guard to the create_worktree step's cmd: block in research.yaml so that the recipe can run in a folder with no pre-existing .git directory. Local mode is expected to set up a local git repo automatically; the user retains the decision about whether to push to a remote afterward.
Rationale
Without this, the recipe fails at the first execution step in an empty folder — git worktree add requires an existing git repo. autoskillit init does not run git init. This is the primary blocker preventing a user from opening Claude Code in an empty folder and running the research recipe cold.
Files
src/autoskillit/recipes/research.yaml (step create_worktree, cmd block around line 208; note block around line 249)
Proposed change
Prepend to the existing cmd block:
if [ ! -d .git ]; then
git init -q && git commit --allow-empty -m "autoskillit: init for research recipe" -q;
fi &&
Update the note block to document that the step auto-initializes a git repo when needed.
Acceptance criteria
Relevant context diagram (C.8 — empty-folder timeline excerpt)
t=0 $ cd /home/talon/runx1t1-research (empty folder)
t=0 $ claude (Tier 1 session opens)
t=1 /autoskillit:order research task="..." output_mode=local
│
▼
PHASE 2 ── WORKTREE CREATION
create_wkt. ── run_cmd →
↳ ✖ FAILS unless this guard is applied (needs .git)
↳ ✓ With guard: git init runs first, then git worktree add
↳ creates ../worktrees/research-{timestamp}/
Hand-off notes
An empty initial commit is required because git worktree add -b needs at least one commit to branch from. Do not reorder any existing commands. See also Work Item 1.2 for the complementary push_branch fix — both must land together for local mode to work end-to-end in empty folders.
Dependencies
From master plan: .autoskillit/temp/runx1t1-preflight.md §11, Unit 1 + §11.5.1
Addendum (2026-05-03 codebase audit)
The fix location described above is incorrect for the current codebase. The create_worktree step (line 206 of research.yaml) no longer has an inline cmd: block with bash commands. It delegates entirely to an external shell script:
cmd: "bash scripts/recipe/create_worktree.sh '${{ inputs.source_dir }}' '${{ inputs.task }}' ..."
The git-init guard must be added inside scripts/recipe/create_worktree.sh (before line 17, which runs git -C "$SOURCE_DIR" worktree add ...), not prepended to the YAML cmd: value.
Test file correction: tests/recipe/test_bundled_recipes.py no longer exists. The bundled-recipe tests were split into per-recipe files. The correct target is tests/recipe/test_bundled_recipes_research.py or tests/recipe/test_research_recipe_diag.py.
Step line number: The create_worktree step is at line 206 (not 208 as originally stated — minor drift).
Part of Unit 1 — Local-mode empty-folder unblock (P0) from the auto-research master plan.
Scope
Prepend an idempotent
git init + empty commitguard to thecreate_worktreestep'scmd:block inresearch.yamlso that the recipe can run in a folder with no pre-existing.gitdirectory. Local mode is expected to set up a local git repo automatically; the user retains the decision about whether to push to a remote afterward.Rationale
Without this, the recipe fails at the first execution step in an empty folder —
git worktree addrequires an existing git repo.autoskillit initdoes not rungit init. This is the primary blocker preventing a user from opening Claude Code in an empty folder and running the research recipe cold.Files
src/autoskillit/recipes/research.yaml(stepcreate_worktree, cmd block around line 208; note block around line 249)Proposed change
Prepend to the existing cmd block:
Update the note block to document that the step auto-initializes a git repo when needed.
Acceptance criteria
create_worktree.githas NO behavior change (idempotency verified)task test-checkpassesRelevant context diagram (C.8 — empty-folder timeline excerpt)
Hand-off notes
An empty initial commit is required because
git worktree add -bneeds at least one commit to branch from. Do not reorder any existing commands. See also Work Item 1.2 for the complementarypush_branchfix — both must land together for local mode to work end-to-end in empty folders.Dependencies
From master plan:
.autoskillit/temp/runx1t1-preflight.md§11, Unit 1 + §11.5.1Addendum (2026-05-03 codebase audit)
The fix location described above is incorrect for the current codebase. The
create_worktreestep (line 206 of research.yaml) no longer has an inlinecmd:block with bash commands. It delegates entirely to an external shell script:The git-init guard must be added inside
scripts/recipe/create_worktree.sh(before line 17, which runsgit -C "$SOURCE_DIR" worktree add ...), not prepended to the YAMLcmd:value.Test file correction:
tests/recipe/test_bundled_recipes.pyno longer exists. The bundled-recipe tests were split into per-recipe files. The correct target istests/recipe/test_bundled_recipes_research.pyortests/recipe/test_research_recipe_diag.py.Step line number: The
create_worktreestep is at line 206 (not 208 as originally stated — minor drift).