environments-manager
Set up per-worktree environments for Claude Code, Cursor, or Codex. Use for worktree-ready repos, IDE environment config, worktree-up/down scripts, or dev.sh wiring.
- License 许可
- MIT
- 所属仓库
- zuzu59/z-skills
- 最近更新
- 2026-09-30
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- environments-manager
- description
- Set up per-worktree environments for Claude Code, Cursor, or Codex. Use for worktree-ready repos, IDE environment config, worktree-up/down scripts, or dev.sh wiring.
- user-invocable
- true
- disable-model-invocation
- true
02 资源文件 20
- 参考文档agents/openai.yaml355 B
- 资产文件assets/codex-icon.svg718 B
- 其他examples/claude/.worktreeinclude39 B
- 参考文档examples/claude/commands/dev.md172 B
- 参考文档examples/claude/commands/lint.md140 B
- 参考文档examples/claude/commands/test.md161 B
- 参考文档examples/claude/commands/typecheck.md196 B
- 参考文档examples/claude/settings.json448 B
- 其他examples/codex/environments/environment.toml504 B
- 参考文档examples/cursor/worktrees.json57 B
- 脚本examples/scripts/claude-worktree-create.sh3.1 KB
- 脚本examples/scripts/claude-worktree-remove.sh2.4 KB
- 脚本examples/scripts/dev.sh397 B
- 脚本examples/scripts/worktree-down.sh517 B
- 脚本examples/scripts/worktree-up.sh1.2 KB
- 参考文档references/claude.md8.8 KB
- 参考文档references/codex.md2.7 KB
- 参考文档references/convex.md6.3 KB
- 参考文档references/cursor.md3.1 KB
- 参考文档references/postgresql.md3.2 KB
03 SKILL.md 正文
Ask before writing. Use the host's question UI. Shared logic lives in scripts/*.sh; IDE configs only point at those files. Read a matching examples/ file before writing, then adapt.
- Ask what a fresh worktree should do (multi-select): copy ignored env files; install deps; isolate or seed a data backend; run codegen. Capture extra project steps in one follow-up.
- Ask the backend. PostgreSQL → postgresql.md. Convex → convex.md. None → skip isolation. Any other backend: research official docs and an in-repo example; do not guess CLI flags; summarize before editing.
- Ask which IDEs to wire (Claude Code, Cursor, Codex). Generate
scripts/once. Then load claude.md, cursor.md, and/or codex.md for linking config only.
Required files: scripts/worktree-up.sh, scripts/worktree-down.sh, scripts/dev.sh (all must end in .sh). Put them on the source checkout, not only the current worktree.
Resolve paths as WORKTREE_PATH="${CODEX_WORKTREE_PATH:-${CURSOR_WORKTREE_PATH:-$(pwd)}}" and SOURCE_PATH="${CODEX_SOURCE_TREE_PATH:-${ROOT_WORKTREE_PATH:-}}". Claude: use WorktreeCreate, never SessionStart; the wrapper adds the worktree then runs worktree-up.sh with ROOT_WORKTREE_PATH — see claude.md. Hook wrappers must survive a missing /dev/tty, a wrong default Node version, and CLI prompts.
worktree-up.sh is idempotent: set -euo pipefail, cd to the worktree, then the selected steps in order. Prefer .worktreeinclude for Claude env copy. Detect the lockfile for install. Read resource names from env/config or setup metadata; never invent them from branch names. Provide a reset escape hatch via <PROJECT>_RESET_<RESOURCE>=1.
worktree-down.sh cleans only resources this setup created. Missing tools: print one line and exit 0.
dev.sh picks a free port from ${DEV_PORT_START:-3910}. Never hardcode a port.
Never commit or log secrets. Never embed multi-line programs in IDE config. Never destroy or import production data unless the user set an override env var. Put this guard in any import/replay helper:
assert_non_prod_ref() {
case "$1" in
prod|prod:*|prod/*|production|production:*|production/*)
echo "refusing prod source: $1" >&2; exit 1 ;;
*prod*|*production*)
[ "${ALLOW_PROD_SOURCE:-0}" = "1" ] || { echo "looks like prod: $1" >&2; exit 1; } ;;
esac
}
Expose Dev, typecheck, unit tests, and lint through the IDE; add E2E only if cheap.
After writing: bash -n the three scripts, git status --short, and parse generated TOML/JSON when those files exist.
04 同仓库更多 Skills
writing-great-skills
Reference for writing and editing skills well — the vocabulary and principles that make a skill predictable.
use-style
Apply named visual style guides to landing pages, app shells, and UI. Use for $use-style, /useskill, list styles, or styles like ios-app, grid, vercel, black-grid, stripe, linear, raycast, gumroad, dusk, or luma.
use-goal
Use when the user asks to create, draft, set, start, or refine a Codex or Claude Code `/goal` objective for persistent multi-turn work.
use-fable
Orchestrator mode for Fable: Fable thinks, plans, and reviews while Codex CLI and subagents execute all heavy work. Use when the user invokes /use-fable, says 'use fable', 'fable mode', 'orchestrator mode', or wants to save Fable tokens/rate limits.
use-delegate
Delegation mode: the host agent (Claude or Codex) plans and reviews while heavy work runs on cheap executors: OpenCode Kimi K3, Codex GPT-5.6 terra/sol. Use when the user invokes /use-delegate, says 'use delegate', 'delegate mode', 'orchestrator mode', or wants to save tokens/rate limits.
use-artifacts
Create Claude-style local HTML artifacts under ~/.agents/artifacts. Use for plans, prototypes, visualizations, dashboards, diagrams, options, or substantial reusable content, with a portable local runtime and no Anthropic API.