一键导入
setupdotclaude
Set up dotclaude in any project. Deep-scans the codebase, interviews the user, installs only justified components, customized to the stack.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Set up dotclaude in any project. Deep-scans the codebase, interviews the user, installs only justified components, customized to the stack.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Rebuild working context fast after /clear or a fresh session — reads the handoff note and the branch's changes, then summarizes where work stands. Add `handoff` to write the note before stopping.
Keep CLAUDE.md current and lean — capture this session's durable learnings into it (default), or `audit` it for stale commands, drift, and bloat. Enforces the line budget either way.
Take a GitHub issue from number to tested fix — read the issue and comments, reproduce, locate the cause, fix with a regression test, and prep a PR that closes it.
Review code changes or a pull request. Delegates to specialist agents (code quality, security, performance, silent failures, test quality, docs) in parallel.
Safely refactor code with test coverage as a safety net. Use `--diff` to simplify just the current working diff before committing.
Scan changes, commit, push, and create a PR. With confirmation at each step
| name | setupdotclaude |
| description | Set up dotclaude in any project. Deep-scans the codebase, interviews the user, installs only justified components, customized to the stack. |
| argument-hint | [optional: focus area like 'frontend' or 'backend'] |
| disable-model-invocation | true |
Set up dotclaude in this project with one governing principle: install nothing without evidence and consent. Every rule, hook, agent, and skill must be justified by something found in the codebase or explicitly requested by the user. When in doubt, leave it out — the user can always add more later; unused config costs tokens and trust forever.
CLAUDE.md must be at the project root (./CLAUDE.md), NOT inside .claude/. All other config files live inside .claude/.
Two modes, decided by what exists:
.claude/ content yet (whether the user will install from this plugin or has nothing at all)..claude/ already has settings, rules, skills, agents, or hooks (from a clone+copy, an earlier run, or hand-rolled). Same scan and interview, but Phase 4 becomes a gap analysis: add what's missing and justified, propose removing what's unjustified, never touch user-customized content without showing the change first.If $ARGUMENTS names a focus area (e.g. frontend), weight the scan and the proposals toward it.
Build an evidence table. Don't stop at manifests; read real code.
package.json, pyproject.toml, Cargo.toml, go.mod, Gemfile, composer.json, build.gradle, pom.xml, Makefile, Dockerfile) and CI workflows (.github/workflows/, .gitlab-ci.yml). Record the actual build/test/lint/dev commands and script names, not guesses.workspaces key, pnpm-workspace.yaml, lerna.json, nx.json, turbo.json, or multiple manifests at depth 2+. List the packages.src/, app/, lib/, packages/*/src, cmd/, internal/, ...). These become rule paths: globs later — record actual paths, never assume src/.jest.config.*, vitest.config.*, pytest.ini, conftest.py, playwright.config.*, ...), then open 2-3 real test files: runner, naming convention (*.test.ts vs test_*.py), test directory layout, assertion style, how much mocking they actually do..tsx/.jsx/.vue/.svelte files, component directories, framework and styling approach from dependencies.prisma/, alembic/, migrations/, db/migrate/, ...).docs/ directory or substantial .md files beyond the README.git symbolic-ref refs/remotes/origin/HEAD), commit message style (git log --oneline -20), whether PRs/gh are part of the workflow (remote on GitHub, gh installed).*.gen.ts, *_pb2.py, // Code generated)../CLAUDE.md, AGENTS.md, .cursorrules, .cursor/rules/, .github/copilot-instructions.md, current .claude/*. This is content to migrate, never to clobber.If the project is empty (no source files, no manifests): say so, offer only the minimal baseline (CLAUDE.md template + safety hooks + settings), and stop after installing it. "Re-run after adding code to customize."
Use AskUserQuestion (batch up to 4 questions per call; use multiSelect where choices aren't exclusive). Two rounds — enough to capture intent, not an interrogation.
Round 1 — confirm reality. First present a compact findings summary in text (stack, package manager, test runner, formatter, layout, git workflow, anything ambiguous). Then ask:
Round 2 — scope and taste.
CLAUDE.md + settings.json + the four safety hooks + code-quality.md. (Recommended for small projects or skeptics.)ship/pr-review need a git/PR workflow, fix-issue needs a GitHub remote with gh, tdd/test-writer need a working test runner, catchup/claude-md/debug-fix/explain/refactor/context-budget are universal. Preselect per evidence; let the user drop any.format-on-save — only offer if a formatter was detected.auto-test — warn plainly: runs the matching test file after every edit; only sensible with a fast suite.notify — OS notification when Claude needs attention. Personal taste.session-start — injects branch + dirty state, ~5-10 tokens/session. Cheap, default on.protect-files, scan-secrets, block-dangerous-commands, warn-large-files) are default-on in every size; only "Let me pick" can drop them.Produce a single plan table before touching anything. For every dotclaude component: Install? | Evidence | Cost class (always-loaded / path-scoped / invoked-only / hook—no context cost). Then a short "Not installing" list, each with a one-line reason. The plan is the contract: Phase 4 applies exactly this, nothing more.
Hard mapping rules (no exceptions without the user overriding):
| Component | Installs only if |
|---|---|
rules/frontend.md, agents/frontend-designer/ | Frontend files exist (Phase 1.5) |
rules/database.md | Migrations or ORM detected (1.6), paths: rewritten to the real migration dirs |
rules/security.md, rules/error-handling.md | Backend/API surfaces exist (1.6), paths: rewritten to the real dirs (with monorepo prefixes) |
rules/testing.md | A test suite actually exists |
agents/doc-reviewer/ | Docs exist (1.7) |
agents/code-reviewer/, agents/silent-failure-hunter/, agents/security-reviewer/, agents/performance-reviewer/ | Standard size and up |
agents/pr-test-analyzer/ | A test suite actually exists (1.4), Standard size and up |
hooks/format-on-save.sh | Formatter detected AND selected |
hooks/auto-test.sh | Test runner detected AND explicitly selected |
hooks/notify.sh, hooks/session-start.sh | Selected in Round 2 |
| Skills | Selected in Round 2 (only justified ones were offered) |
skills/setupdotclaude itself | Skip when running from the plugin ($CLAUDE_PLUGIN_ROOT set) — re-runs come from the plugin. Offer only in the clone flow. |
settings.json is never copied verbatim: its hooks section must wire only the hooks being installed, and permissions.allow must list only commands that exist in this project (real package manager, real script names; gh rules only if PRs are part of the workflow). Keep the deny rules for secrets as-is — those are universal.
Ask one final AskUserQuestion: approve the plan / adjust (loop back) / cancel. Do not proceed without approval.
Fresh mode (plugin install). Copy each approved file individually from $CLAUDE_PLUGIN_ROOT/template/ (the plugin bundles the full dotclaude template there). Copying per-file keeps folder READMEs and hooks/tests/ out automatically. Example shape:
mkdir -p .claude/rules .claude/hooks .claude/agents .claude/skills
cp "$CLAUDE_PLUGIN_ROOT/template/rules/code-quality.md" .claude/rules/
cp "$CLAUDE_PLUGIN_ROOT/template/hooks/protect-files.sh" .claude/hooks/ # ...one cp per approved file
cp -r "$CLAUDE_PLUGIN_ROOT/template/skills/debug-fix" .claude/skills/ # skills copy as directories
cp -r "$CLAUDE_PLUGIN_ROOT/template/agents/code-reviewer" .claude/agents/ # agents too (one dir per agent; scanned recursively)
chmod +x .claude/hooks/*.sh
Project-root files (never clobber):
[ -f ./CLAUDE.md ] || cp "$CLAUDE_PLUGIN_ROOT/template/CLAUDE.md" ./CLAUDE.md
[ -f ./CLAUDE.local.md.example ] || cp "$CLAUDE_PLUGIN_ROOT/template/CLAUDE.local.md.example" ./
touch .gitignore
grep -qxF 'CLAUDE.local.md' .gitignore || echo 'CLAUDE.local.md' >> .gitignore
If $CLAUDE_PLUGIN_ROOT is unset and there are no copied files to work with, tell the user to install via the marketplace (/plugin install setupdotclaude@dotclaude) or follow the clone flow at https://github.com/poshan0126/dotclaude.
Existing/clone mode. The user already has files. Apply the same plan as a diff:
.claude/README.md, CONTRIBUTING.md, LICENSE, .gitignore, CLAUDE.template.md, settings.local.json.example, folder READMEs, .claude-plugin/, hooks/tests/, plugins/, legacy scripts/). Confirm before each rm; list, don't surprise.Customize while installing (confirm each file's changes before writing):
> REPLACE: block. For each remaining section keep it only if the scan produced real content for it:| Section | Keep if... | Otherwise |
|---|---|---|
| Architecture | A non-obvious structural decision surfaced (1.3/1.12) | Delete — Claude can explore |
| Key Decisions | A WHY exists that would prevent a wrong fix | Delete |
| Domain Knowledge | Non-obvious terms surfaced (1.12 / Round 1) | Delete |
| Workflow | Project-specific quirks exist | Delete — generic lines duplicate code-quality.md |
| Don'ts | Project-specific don'ts exist (e.g. generated dirs from Round 1) | Delete |
Most projects end up with Commands plus three to five lines. A 10-line CLAUDE.md is healthy.
2. settings.json: generate hooks + permissions per the plan (above).
3. Rule paths: rewritten to the directories actually found, with monorepo package prefixes when applicable.
4. code-quality.md naming: change only if the sampled code (1.10) genuinely differs from the defaults.
5. block-dangerous-commands.sh: update the protected-branch regex if the default branch isn't main/master.
6. Migrate existing AI config (1.11): offer to fold .cursorrules / AGENTS.md / copilot-instructions content into CLAUDE.md or a rule. Never delete the originals without asking.
CLAUDE.md budget: count non-blank lines (grep -cv '^[[:space:]]*$' CLAUDE.md). Under 25 = PASS. 25-50 = WARN: list the longest sections, ask which to trim. Over 50 = FAIL: propose specific cuts and don't finish until ≤50.
Always-loaded estimate: CLAUDE.md + rules without paths:, chars/4. Report the number; over ~1000 tokens, propose the single biggest trim.
Mechanical checks: every hook wired in settings.json exists and is executable; every installed file parses (YAML frontmatter, JSON); nothing was installed beyond the approved plan; no rule duplicates what a hook already enforces.
Write the drift fingerprint so the setup stays tuned over time. If session-start.sh was installed:
[ -x .claude/hooks/session-start.sh ] && DOTCLAUDE_FINGERPRINT=1 .claude/hooks/session-start.sh > .claude/.dotclaude.json
This records a hash of the project's manifests. From then on, the session-start hook emits a one-line "config drift" nudge whenever the manifests change (new scripts, new framework, new package manager) — the signal to re-run this skill. Commit .claude/.dotclaude.json so the whole team shares the baseline. If session-start.sh was not installed, skip and instead tell the user to re-run /setupdotclaude manually after stack changes.
Summary: three lists — installed (with the evidence that justified each), skipped (with reason), customized (what changed). Budget verdict. Close with the maintenance cadence: "Re-run /setupdotclaude when the drift nudge appears, after adding a framework or test runner, or after a big restructuring — it runs as a gap analysis on an existing setup, so re-runs are cheap and only propose deltas." Tip: run /context-budget for the full per-turn breakdown.