Version 4.0

Claude Code Project Setup

Programmer's Guide for AI-Assisted Development

by Shelly Palmer

Overview

The setup-claude-project.sh script creates an optimized, language-agnostic project structure for development with Claude Code. Version 4.0 takes advantage of mature Claude Code features: hooks, modular rules, path-specific loading, auto-memory, and agent teams.

What This Script Does

Philosophy: v4.0 embraces Claude Code's mature feature set. Hooks replace manual warnings, modular rules replace monolithic docs, auto-memory replaces session logs, and agent teams replace loop plugins. Your CLAUDE.md stays lean and project-specific.

Quick Start

Installation

# Download the script
curl -O https://raw.githubusercontent.com/s220284/claude-code-setup/main/setup-claude-project.sh

# Make it executable
chmod +x setup-claude-project.sh

# Run it
./setup-claude-project.sh MyProject "A web application for task management"

# Or run interactively
./setup-claude-project.sh

After Setup

# Navigate to your project
cd MyProject

# Customize rules for your language
edit .claude/rules/code-style.md
edit .claude/rules/testing.md

# Let Claude analyze your codebase
claude
> /init

# Claude automatically loads CLAUDE.md and rules at session start
Pro Tip: Run /init after setup to let Claude analyze your codebase and generate additional project-specific instructions that complement the scaffolded rules.

What's New in v4.0

New Hooks System

Scaffolded PostToolUse hook auto-fixes shell script line endings and permissions. Notification hook sends macOS alerts when Claude needs attention.

New Modular Rules

.claude/rules/ directory with path-specific YAML frontmatter. Rules load automatically when working in matching directories.

New Auto-Memory

Claude Code's built-in memory handles session continuity. SESSION_LOG.md and CONTINUATION_GUIDE.md are no longer needed.

New Agent Teams

Agent teams (experimental) are the new direction for multi-agent workflows, replacing loop-based plugins like ralph-loop.

New Language-Agnostic

All Python-specific references removed. Generic placeholders work with any tech stack — customize for your language.

New Skill Frontmatter

Skills now use YAML frontmatter (name, description, user-invocable) for proper registration with Claude Code.

Files Changed in v4.0

Change Details
Removed SESSION_LOG.md Auto-memory handles session continuity
Removed CONTINUATION_GUIDE.md Generic content Claude already knows
Removed ralph-loop plugin Agent teams are the new direction
Added .claude/rules/ Modular, path-specific rule files
Added .claude/settings.local.json Personal overrides, gitignored
Added Hooks in settings.json PostToolUse shell fixer, Notification alerts
Result: Leaner project scaffold that leverages Claude Code's mature features. CLAUDE.md is under 100 lines, focused entirely on project-specific guidance.

Files Created

v4.0 creates a focused set of files, each with a clear purpose:

Core Documentation

CLAUDE.md Required

Purpose: Main session reference — auto-loaded by Claude Code

Contains (~80 lines):

  • Cloud-first development warning
  • Engineering requirements (Three Pillars)
  • Modular documentation references (@import syntax)
  • Session continuity with auto-memory note
  • Project structure diagram
  • Available skills & plugins table

PROJECT_STATE.md Required

Purpose: Current system status snapshot

Tracks component health, production state, critical files, recent changes, and known issues. Update after completing features.

Configuration

.claude/settings.json

Purpose: Shared project configuration — permissions, hooks, and MCP servers

{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "permissions": {
    "allow": ["Bash(git status)", "Bash(git diff *)", "Bash(git log *)"],
    "deny": ["Read(.env)", "Read(.env.*)"]
  },
  "hooks": {
    "PostToolUse": [{ "matcher": "Write", "hooks": [{ "type": "command", "command": "..." }] }],
    "Notification": [{ "matcher": "", "hooks": [{ "type": "command", "command": "..." }] }]
  }
}

.claude/settings.local.json New

Purpose: Personal overrides (gitignored)

Add your own permissions, MCP servers, or hook overrides without affecting the shared configuration.

Rules

.claude/rules/code-style.md New

Purpose: Code conventions scoped to src/**

Uses paths: YAML frontmatter so rules only load when working on source files.

.claude/rules/testing.md New

Purpose: Testing standards scoped to tests/**

Uses paths: YAML frontmatter so rules only load when working on test files.

Skills

.claude/skills/commit/SKILL.md

Purpose: Commit workflow skill with YAML frontmatter

Now includes name, description, and user-invocable: true frontmatter for proper skill registration.

CI/CD

.github/workflows/ci.yml

Purpose: Language-agnostic CI pipeline template

Contains TODO placeholders for your language-specific setup, install, and test commands.

Hooks

Claude Code's hook system lets you run commands automatically in response to events. Hooks are configured in .claude/settings.json and execute shell commands when triggered.

How Hooks Work

Hooks fire on specific events during a Claude Code session:

Event When It Fires Use Cases
PreToolUse Before a tool executes Validation, blocking dangerous operations
PostToolUse After a tool executes Auto-formatting, file fixing, notifications
Notification When Claude sends a notification System alerts, sound cues, integrations

Each hook entry has a matcher (which tool or pattern to match) and an array of hook commands to run.

Scaffolded Hooks

Shell Script Fixer (PostToolUse)

Matcher: Write

Automatically fixes CRLF line endings and sets executable permissions on .sh files whenever Claude writes one. This replaces the manual "Critical: Shell Script Line Endings" warning from v3.0.

{
  "matcher": "Write",
  "hooks": [{
    "type": "command",
    "command": "jq -r '.tool_input.file_path // empty' | xargs -I{} sh -c 'case \"{}\" in *.sh) sed -i \"\" \"s/\\r$//\" \"{}\" && chmod +x \"{}\" ;; esac'"
  }]
}

Notification Alert (Notification)

Matcher: "" (matches all notifications)

Sends a macOS notification when Claude Code needs your attention, so you can work in other apps while waiting.

{
  "matcher": "",
  "hooks": [{
    "type": "command",
    "command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"' 2>/dev/null || true"
  }]
}

Adding More Hooks

To add your own hooks, edit .claude/settings.json and add entries to the appropriate event array. Examples of useful custom hooks:

Tip: Use .claude/settings.local.json for personal hooks that shouldn't be shared with the team (e.g., sound alerts or personal notification preferences).

Rules

The .claude/rules/ directory contains modular rule files that Claude loads automatically. Rules can be scoped to specific file paths using YAML frontmatter.

How Rules Work

  1. Place .md files in .claude/rules/
  2. Claude loads all rules at session start
  3. Rules with paths: frontmatter only activate when working on matching files
  4. Rules without frontmatter apply globally

Path-Specific Rules

Use YAML frontmatter with paths: to scope rules to specific directories:

---
paths:
  - "src/**"
---

# Code Style

- Use consistent naming conventions
- Keep functions focused
- Use environment variables for configuration

This rule only loads when Claude is working on files matching src/**.

Scaffolded Rules

.claude/rules/code-style.md

Scope: src/**

Language-agnostic code conventions: naming, function design, configuration, security. Customize for your specific language and framework.

.claude/rules/testing.md

Scope: tests/**

Testing standards: coverage targets, test patterns, mocking strategy. Customize for your test framework.

Adding More Rules

Create new .md files in .claude/rules/ for different concerns:

# Example: .claude/rules/api-design.md
---
paths:
  - "src/api/**"
  - "src/routes/**"
---

# API Design Rules

- Use RESTful conventions
- Always validate request bodies
- Return consistent error formats
- Include pagination for list endpoints
Tip: Reference rules from CLAUDE.md using @import .claude/rules/code-style.md syntax to make the relationship explicit.

Global Plugins & Skills

v4.0 documents available global plugins directly in CLAUDE.md. These are pre-installed capabilities you can use across all projects.

Available Global Plugins

Plugin Skills/Agents Purpose
commit-commands /commit, /commit-push-pr, /clean_gone Git workflow automation
feature-dev /feature-dev Guided feature development
pr-review-toolkit /review-pr, code-reviewer, silent-failure-hunter, type-design-analyzer Comprehensive PR review
frontend-design /frontend-design Production-grade UI development

Agent Teams

New Agent Teams (Experimental)

Agent teams are Claude Code's new direction for multi-agent workflows. They replace loop-based plugins like ralph-loop with a more structured approach to background processing and parallel agent coordination.

Agent teams allow you to define specialized agents that work together on complex tasks, each with their own tools and context. This is an experimental feature — check the Claude Code documentation for the latest status.

Skill Shortcuts

Common workflow commands available in any project:

Task Skill
Commit changes /commit
Commit, push, and create PR /commit-push-pr
Review a PR /review-pr
Build a UI component /frontend-design
Clean deleted remote branches /clean_gone
Note: The Playwright MCP server is also available for browser automation, testing, and screenshots.

Development Workflow

The Three Pillars

Every production code change MUST include ALL THREE:

1. Tests

  • Run your test suite, aim for >80% coverage
  • Test success AND failure paths
  • Mock external dependencies

2. Documentation

  • Docstrings/comments for public APIs
  • Comments for complex logic only

3. Git Commits

  • Conventional commit format
  • Co-Authored-By footer
  • Descriptive messages
NO EXCEPTIONS. NO SHORTCUTS. This discipline is what makes AI-assisted development reliable and maintainable.

Session Continuity

v4.0 relies on Claude Code's auto-memory for session continuity. Claude automatically remembers context from previous sessions without manual logging.

Manual Tracking (Optional)

For projects that need explicit status tracking, PROJECT_STATE.md provides a system status snapshot. Update it after completing features or deployments.

Simplified: No more SESSION_LOG.md or CONTINUATION_GUIDE.md. Auto-memory handles what those files used to do, and Claude already knows generic workflows like "how to fix a bug."

Cloud-First Development

Never Hardcode Local Paths

Use relative paths or environment variables. All code must work in containers.

# WRONG
path = "/Users/username/projects/myapp"

# CORRECT
path = env_var("APP_ROOT", "/app")  # Use your language's equivalent

Quick Reference

Project Structure

MyProject/
├── CLAUDE.md                  # Main session reference (~80 lines)
├── CLAUDE.local.md            # Personal overrides (gitignored)
├── PROJECT_STATE.md           # System status
├── src/                       # Source code
├── tests/                     # Test files
├── docs/                      # Documentation
├── scripts/                   # Utility scripts
├── .claude/
│   ├── settings.json          # Permissions, hooks, MCP config
│   ├── settings.local.json    # Personal overrides (gitignored)
│   ├── rules/                 # Modular rule files
│   │   ├── code-style.md      # Code conventions (src/**)
│   │   └── testing.md         # Testing standards (tests/**)
│   ├── hooks/                 # Custom hook scripts
│   └── skills/
│       └── commit/
│           └── SKILL.md       # Commit skill (with frontmatter)
└── .github/
    └── workflows/
        └── ci.yml             # CI pipeline template

Key Files

File Purpose Committed
CLAUDE.md Main instructions (auto-loaded) Yes
CLAUDE.local.md Personal overrides No
.claude/settings.json Shared config, hooks, permissions Yes
.claude/settings.local.json Personal config overrides No
.claude/rules/*.md Modular, path-specific rules Yes

Resources