AgentSkillsCN

Claude Code Project Setup

Claude Code 项目搭建

SKILL.md

Claude Code Project Setup

Best practices for configuring Claude Code in new and existing projects.

When to Use

  • Setting up a new project with Claude Code
  • Creating or updating CLAUDE.md files
  • Configuring .claude directory structure
  • Establishing project-specific conventions

CLAUDE.md Best Practices

Location and Priority

  1. Project root (/project/CLAUDE.md) - Project-specific instructions
  2. Home directory (~/CLAUDE.md) - Global preferences
  3. Parent directories - Inherited up the tree

Structure Template

markdown
# [Project Name]

## Overview
[One-line project description]

## Tech Stack
- [Framework/Language] - [Version]
- [Database]
- [Key dependencies]

## Project Structure

src/ ├── [key directory] - [purpose] └── [key directory] - [purpose]

code
## Development Commands
```bash
# Development
[command]

# Testing
[command]

# Building
[command]

Conventions

  • [Naming convention]
  • [Code style rule]
  • [Important pattern]

Common Tasks

[Task Name]

[Brief instructions]

code
### What to Include
- Tech stack with versions
- Key directories and their purposes
- Development commands
- Project-specific conventions
- Common tasks with instructions
- Integration details (APIs, services)

### What to Avoid
- Generic advice (put in ~/CLAUDE.md)
- Duplicating README content
- Implementation details that change frequently
- Sensitive information (use .env)

## .claude Directory Structure

.claude/ ├── settings.json # Project-specific settings ├── commands/ # Custom slash commands │ └── deploy.md # /project:deploy └── agents/ # Project-specific agents (if needed)

code
### settings.json Example

```json
{
  "model": "sonnet",
  "allowedTools": [
    "Bash(npm run *)",
    "Bash(cargo *)"
  ],
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "./scripts/validate.sh"
          }
        ]
      }
    ]
  }
}

Custom Commands

File: .claude/commands/[name].md

markdown
# Command Title

Brief description of what this command does.

## Steps
1. [Action to take]
2. [Action to take]

## Notes
- [Important consideration]

Naming Conventions

  • Use kebab-case: run-tests.md, deploy-staging.md
  • Prefix with scope for organization: db-migrate.md, api-test.md
  • Invoke with /project:[command-name]

Project Types

Rust Workspace

markdown
## Workspace Structure
- `crates/core` - Core library
- `crates/cli` - CLI binary
- `crates/shared` - Shared types

## Development
```bash
cargo build --workspace
cargo test --workspace
cargo clippy --workspace

Conventions

  • Workspace-level dependencies in root Cargo.toml
  • Each crate has own README.md
  • Features defined at workspace level
code
### Next.js App Router
```markdown
## Structure
- `app/` - Routes and pages
- `components/` - React components
- `lib/` - Utilities and helpers
- `actions/` - Server actions

## Development
```bash
bun dev
bun run lint
bun run typecheck

Conventions

  • Server Components by default
  • 'use client' only when needed
  • Server Actions for mutations
code
### Tauri App
```markdown
## Structure
- `src-tauri/` - Rust backend
- `src/` - Frontend (React/Svelte)

## Development
```bash
bun tauri dev
bun tauri build

IPC Commands

Commands defined in src-tauri/src/commands/ Frontend types in src/lib/commands.ts

code
## Troubleshooting

### CLAUDE.md Not Being Read
- Verify file is in project root or parent
- Check file permissions (readable)
- Ensure no syntax errors in markdown

### Settings Not Applied
- Project settings override global
- Check JSON syntax in settings.json
- Restart Claude Code after changes

### Commands Not Found
- Verify file is in `.claude/commands/`
- Check file extension is `.md`
- Use `/project:[name]` format