worktree-setup

A worktree setup command that reconnects environment files, secrets, and configuration from the main Git repository to a separate worktree. A worktree is another working directory linked to the same repository.

In plain words
What is it for?
Use it to link files such as .env, .secret, and .npmrc, preview what would be linked with a dry run, and verify the resulting symbolic links.
Why use it?
It restores missing shared setup files when automatic session setup failed or files were added after the worktree was created.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/teamspwk/nova/worktree-setup
Clone the repo
git clone --depth 1 https://github.com/TeamSPWK/nova

Made for: Claude Code.

Per session 42 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,107 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00042 $0.01107
Opus 5 $0.00021 $0.00553
Sonnet 5 $0.00008 $0.00221
Haiku 4.5 $0.00004 $0.00111

Measured yesterday against content hash 6416cb54aba1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

worktree-setup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/worktree-setup.md · 103 lines

How it starts

The opening of the file, as written. The whole thing — 103 lines — stays where its author put it; the contents beside it link to each section on GitHub.

현재 worktree에서 메인 레포의 환경 파일을 즉시 다시 연결한다.

Role

너는 Nova의 환경 기둥 핸들러다. worktree 진입 후 환경변수·시크릿이 제대로 연결됐는지 확인하고, 누락되면 즉시 링크를 복구한다.

언제 사용하나

  • worktree에서 작업하려는데 .env, .secret/, .npmrc가 보이지 않을 때
  • SessionStart 훅이 어떤 이유로 실패했거나 메인 레포에 나중에 파일이 추가된 경우
  • /nova:worktree-setup --dry-run으로 어떤 파일이 링크될지 미리 보고 싶을 때

Execution

  1. 현재 위치 확인

    git worktree list
    pwd
    
    • 현재 디렉토리가 메인 레포면 "메인 레포에서는 링크 불필요" 안내 후 종료
    • worktree가 아니면 (단일 clone) "worktree 환경이 아닙니다" 안내 후 종료
  2. hooks/worktree-setup.sh 실행

    NOVA_WORKTREE_DEBUG=1 bash "$CLAUDE_PLUGIN_ROOT/hooks/worktree-setup.sh"
    
    • NOVA_WORKTREE_DEBUG=1로 어떤 파일이 링크/skip됐는지 상세 로그 출력
    • 멱등하므로 여러 번 실행해도 안전
  3. 결과 확인

    ls -la .env .env.local .env.development .secret .npmrc 2>/dev/null
    
    • 심볼릭 링크가 제대로 걸려있는지 확인
    • readlink로 링크 대상 경로 확인 (macOS: readlink file, Linux: readlink -f file)
  4. 사용자에게 결과 보고

    🔗 Worktree 환경 셋업 결과
    
    메인 레포: <경로>
    현재 worktree: <경로>
    
    링크됨:
      ✓ .env → ../main/.env
      ✓ .secret/ → ../main/.secret/
    
    스킵:
      - .npmrc (메인에 없음)
      - .env.local (이미 존재)
    
    📝 오버라이드 필요 시: .claude/worktree-sync.json 생성
    

--dry-run 플래그

사용자가 --dry-run을 전달하면:

  1. hooks/worktree-setup.sh를 실행하지 않는다
  2. 대신 메인 레포의 .env, .env.local, .env.development, .secret/, .npmrc 존재 여부만 확인하고 "링크 예정 / 메인에 없음 / 이미 존재"로 분류해 출력

오버라이드 가이드

기본 대상(5종) 외의 파일을 링크하려면 메인 레포에 .claude/worktree-sync.json을 생성한다:

{
  "links": [".env", ".env.local", "config/secrets.json", ".envrc"]
}
  • links가 존재하면 기본값 대체(교체 방식)
  • 절대 경로(/...)와 상위 이동(..)은 무시됨

환경 변경은 설정 파일 직접 수정 금지. 환경변수/CLI 플래그 우선 사용 (§9 환경 안전 규칙).

분기 ref 설정 (CC v2.1.133+)

이 커맨드는 셋업(메인 레포 시크릿 링크)만 담당한다. 워크트리가 어느 ref에서 분기할지(worktree.baseRef)는 Claude Code 설정 영역이다.

{ "worktree": { "baseRef": "head" } }
  • head (기본 권장) — 로컬 unpushed 커밋 포함
  • freshorigin/<default>에서 시작

상세는 skills/worktree-setup/SKILL.md의 "분기 ref 선택" 섹션 참조.

Notes

Read the full file on GitHub · 103 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 103 lines · 42 tokens per session scan A 6416cb54aba1

Subscribe to this mod's changes

worktree-setup is a command published in the GitHub repository TeamSPWK/nova (2 stars, last pushed 2d ago), licensed MIT. It adds 42 tokens to every session and 1,107 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.