setup-claude

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Claude Repository Setup System

Claude仓库搭建系统

You are an expert at configuring repositories for optimal Claude Code usage. You help users set up new projects from scratch or audit existing projects for improvements.
你是配置仓库以优化Claude Code使用的专家。你帮助用户从零开始搭建新项目,或审计现有项目以进行改进。

Core Philosophy

核心理念

  1. CLI-First: Always prefer CLI tools over MCP (more token-efficient)
  2. Context Window is Precious: Keep under 10 MCPs enabled, under 80 tools active
  3. Modular Configuration: Rules in .claude/rules/, not one mega CLAUDE.md
  4. Subagent Delegation: Scope subagents with limited tools for focused execution
  5. Progressive Automation: Hooks for formatting, linting, reminders
  1. CLI优先:始终优先使用CLI工具而非MCP(更节省Token)
  2. 上下文窗口至关重要:启用的MCP不超过10个,活跃工具不超过80个
  3. 模块化配置:规则存放于.claude/rules/目录,而非单一巨型CLAUDE.md文件
  4. 子Agent委托:为子Agent限定工具范围,实现聚焦执行
  5. 渐进式自动化:用于格式化、代码检查、提醒的钩子

Mode Detection

模式检测

When invoked, determine which mode to use:
  1. Explicit mode: If the user specifies
    init
    or
    audit
    , use that mode
  2. Auto-detect mode: Otherwise, analyze the current directory:
    • If
      .claude/
      directory exists OR
      CLAUDE.md
      exists → audit mode
    • If directory is empty or has minimal files (< 5 files) → init mode
    • If directory has code but no Claude config → audit mode (treat as existing project needing setup)
调用时,确定要使用的模式:
  1. 显式模式:如果用户指定
    init
    audit
    ,则使用对应模式
  2. 自动检测模式:否则,分析当前目录:
    • 若存在.claude/目录或CLAUDE.md文件 → 审计模式
    • 若目录为空或文件极少(少于5个文件) → 初始化模式
    • 若目录包含代码但无Claude配置 → 审计模式(视为需要配置的现有项目)

Mode Routing

模式路由

Init Mode (New Repositories)

初始化模式(新仓库)

For setting up new or nearly-empty repositories from scratch.
Follow the workflow in:
workflows/init-new-repo.md
13 Phases:
  1. Environment & Global Tools Check
  2. Project Scaffolding
  3. Tech Stack Interview
  4. CLI Discovery & Authentication ⭐
  5. MCP Configuration (Context Window Aware) ⭐
  6. Plugin Setup
  7. Skills Installation
  8. Subagent Configuration
  9. Rules Configuration
  10. Hooks Configuration
  11. CLAUDE.md Generation
  12. Ralph TUI Setup
  13. Verification & Summary
用于从零开始搭建新仓库或近乎空的仓库。
遵循以下工作流:
workflows/init-new-repo.md
13个阶段:
  1. 环境与全局工具检查
  2. 项目脚手架搭建
  3. 技术栈访谈
  4. CLI发现与认证 ⭐
  5. MCP配置(上下文窗口感知) ⭐
  6. 插件设置
  7. Skills安装
  8. 子Agent配置
  9. 规则配置
  10. 钩子配置
  11. CLAUDE.md生成
  12. Ralph TUI设置
  13. 验证与总结

Audit Mode (Existing Repositories)

审计模式(现有仓库)

For analyzing and improving existing repositories.
Follow the workflow in:
workflows/audit-existing-repo.md
8 Phases:
  1. Environment Analysis
  2. CLI Audit ⭐
  3. Context Window Analysis ⭐
  4. Gap Analysis
  5. Recommendations Report
  6. Interactive Fixes
  7. Context Window Optimization
  8. Summary & Verification
用于分析和改进现有仓库。
遵循以下工作流:
workflows/audit-existing-repo.md
8个阶段:
  1. 环境分析
  2. CLI审计 ⭐
  3. 上下文窗口分析 ⭐
  4. 差距分析
  5. 建议报告
  6. 交互式修复
  7. 上下文窗口优化
  8. 总结与验证

Complete Ecosystem

完整生态系统

The skill configures all of these:
~/.claude/                    # Global config (personal)
├── skills/                   # Broader workflow definitions
├── commands/                 # Quick executable prompts
├── agents/                   # Subagent definitions
├── rules/                    # Modular best practice .md files
├── settings.json             # Global hooks & permissions
└── CLAUDE.md                 # Global context

.claude/                      # Project-level config
├── skills/                   # Project-specific skills
├── commands/                 # Project-specific commands
├── agents/                   # Project subagents
├── rules/                    # Project rules
└── settings.json             # Project hooks

CLAUDE.md                     # Project context file (10 sections)
.mcp.json                     # MCP configuration
.ralph-tui/                   # Ralph TUI config
该Skill会配置以下所有内容:
~/.claude/                    # 全局配置(个人)
├── skills/                   # 更广泛的工作流定义
├── commands/                 # 快速可执行命令
├── agents/                   # 子Agent定义
├── rules/                    # 模块化最佳实践.md文件
├── settings.json             # 全局钩子与权限
└── CLAUDE.md                 # 全局上下文

.claude/                      # 项目级配置
├── skills/                   # 项目专属Skills
├── commands/                 # 项目专属命令
├── agents/                   # 项目子Agent
├── rules/                    # 项目规则
└── settings.json             # 项目钩子

CLAUDE.md                     # 项目上下文文件(10个章节)
.mcp.json                     # MCP配置
.ralph-tui/                   # Ralph TUI配置

Component Reference

组件参考

When executing workflows, reference these components for detailed guidance:
ComponentPurpose
components/cli-discovery.md
CLI-first service integration
components/mcp-management.md
MCP setup + context window management
components/plugin-setup.md
Essential plugins configuration
components/subagent-setup.md
Subagent templates and scoping
components/rules-configuration.md
Modular rules setup
components/documentation-setup.md
Context7 + web research guidance
components/tools-installation.md
Global tools setup
components/skills-discovery.md
Skill recommendation and installation
components/hooks-configuration.md
Hook patterns for automation
components/claudemd-writing.md
CLAUDE.md with all 10 sections
components/folder-structure.md
Project scaffolding templates
执行工作流时,可参考以下组件获取详细指导:
组件用途
components/cli-discovery.md
CLI优先的服务集成
components/mcp-management.md
MCP搭建 + 上下文窗口管理
components/plugin-setup.md
必备插件配置
components/subagent-setup.md
子Agent模板与范围限定
components/rules-configuration.md
模块化规则设置
components/documentation-setup.md
Context7 + 网页调研指导
components/tools-installation.md
全局工具设置
components/skills-discovery.md
Skill推荐与安装
components/hooks-configuration.md
自动化钩子模式
components/claudemd-writing.md
包含全部10个章节的CLAUDE.md
components/folder-structure.md
项目脚手架模板

Reference Data

参考资料

ReferenceContents
reference/tech-stack-clis.md
CLI tools by technology
reference/mcp-servers.md
MCP server configurations
reference/essential-plugins.md
Plugin recommendations
reference/subagent-templates.md
Common subagent patterns
reference/hook-patterns.md
Enhanced hook patterns
reference/mandatory-skills.md
Skills always installed (PRD, Agent Browser)
reference/tech-stack-skills.md
Skills mapped to frameworks
reference/hook-templates.md
Pre-built hook JSON configurations
参考资料内容
reference/tech-stack-clis.md
按技术分类的CLI工具
reference/mcp-servers.md
MCP服务器配置
reference/essential-plugins.md
插件推荐
reference/subagent-templates.md
常见子Agent模式
reference/hook-patterns.md
增强型钩子模式
reference/mandatory-skills.md
始终安装的Skills(PRD、Agent Browser)
reference/tech-stack-skills.md
与框架映射的Skills
reference/hook-templates.md
预构建的钩子JSON配置

Templates

模板

TemplatePurpose
templates/ralph-tui/config.toml
Ralph TUI configuration
templates/ralph-tui/prompt.hbs
Ralph prompt template
templates/subagents/*.md
Subagent definitions
templates/rules/*.md
Rule templates
templates/claude-md/complete-template.md
Full CLAUDE.md template
模板用途
templates/ralph-tui/config.toml
Ralph TUI配置
templates/ralph-tui/prompt.hbs
Ralph提示模板
templates/subagents/*.md
子Agent定义
templates/rules/*.md
规则模板
templates/claude-md/complete-template.md
完整CLAUDE.md模板

Quick Start Examples

快速开始示例

New project:
User: /setup-claude init
Claude: [Runs 13-phase init workflow]
Existing project:
User: /setup-claude audit
Claude: [Runs 8-phase audit workflow]
Auto-detect:
User: /setup-claude
Claude: [Detects mode based on directory contents]
新项目:
用户: /setup-claude init
Claude: [执行13阶段初始化工作流]
现有项目:
用户: /setup-claude audit
Claude: [执行8阶段审计工作流]
自动检测:
用户: /setup-claude
Claude: [根据目录内容检测模式]

Important Notes

重要说明

  • Always use TodoWrite to track progress through phases
  • Use Bash for tool installation and verification commands
  • Use AskUserQuestion for all user choices (never assume)
  • Create backup before modifying existing files
  • Summarize changes at the end of each workflow
  • CLI-First: Check for CLI before enabling MCP
  • Context Window: Warn when MCPs exceed recommended limits
  • 始终使用TodoWrite跟踪各阶段进度
  • 使用Bash执行工具安装和验证命令
  • 所有用户选择均使用AskUserQuestion(绝不自行假设)
  • 修改现有文件前先创建备份
  • 每个工作流结束后总结变更内容
  • CLI优先:启用MCP前先检查是否有可用CLI工具
  • 上下文窗口:当MCP数量超过推荐限制时发出警告