AgentSkillsCN

project-init

通过自动识别技术栈并提出澄清性问题,自动生成专属于项目的 CLAUDE.md 文件。适用于新项目启动时,或当项目尚无 CLAUDE.md 文件时使用。

SKILL.md
--- frontmatter
name: project-init
description: Generate a project-specific CLAUDE.md file by auto-detecting tech stack and asking clarifying questions. Use when starting work on a new project or when a project lacks a CLAUDE.md.

Project Init Skill

Generate a comprehensive, project-specific CLAUDE.md file that helps Claude understand and work effectively with your codebase.

When to Use

  • Starting work on a new project that lacks a CLAUDE.md
  • User asks to "set up Claude for this project" or "create project instructions"
  • User says "project init" or "/project-init"
  • Onboarding to an existing codebase

Process

Phase 1: Auto-Detection

Scan the project root for configuration files to detect the tech stack:

FileIndicates
package.jsonNode.js project - check for framework (Next.js, Express, etc.)
pyproject.toml or setup.pyPython project - check for framework (Django, FastAPI, Flask)
Cargo.tomlRust project
go.modGo project
composer.jsonPHP project
GemfileRuby project
tsconfig.jsonTypeScript enabled
docker-compose.ymlDocker-based deployment
DockerfileContainerized
.env.exampleEnvironment variables used

Also scan for:

  • src/ or app/ structure
  • tests/ or __tests__/ directory
  • Database files (prisma/schema.prisma, alembic/, migrations/)
  • CI/CD files (.github/workflows/, .gitlab-ci.yml)

Phase 2: Extract Information

From detected files, extract:

  1. Commands - from package.json scripts, Makefile, pyproject.toml
  2. Dependencies - key frameworks and libraries
  3. Structure - folder organization
  4. Environment - required env vars from .env.example

Phase 3: Fill Gaps (Interactive)

Ask the user about things that can't be auto-detected:

  1. Project purpose - "What does this project do in one sentence?"
  2. Key patterns - "Any specific patterns or conventions I should follow?"
  3. Do's and Don'ts - "Anything I should avoid doing in this codebase?"
  4. Deployment - "How is this deployed?" (if not obvious)

Use AskUserQuestion tool for this phase.

Phase 4: Generate CLAUDE.md

Create CLAUDE.md in the project root with these sections:

markdown
# [Project Name]

## Overview
[Auto-detected or user-provided description]

## Tech Stack
| Layer | Technology |
|-------|------------|
| Language | [detected] |
| Framework | [detected] |
| Database | [detected or N/A] |
| Testing | [detected] |

## Getting Started
```bash
# [Commands extracted from package.json/Makefile/etc.]

Commands

CommandDescription
[extracted commands]

Architecture

code
[Folder structure visualization]

Environment Variables

[From .env.example or ask user]

Key Patterns

[User-provided or common patterns for the stack]

Notes for Claude

Do

  • [Project-specific guidelines]
  • Follow existing code patterns
  • Add tests for new functionality

Don't

  • Hardcode credentials or secrets
  • Skip error handling
  • [User-provided don'ts]

Generated by project-init skill

code

## Output

1. Show detected information summary
2. Ask clarifying questions (Phase 3)
3. Generate CLAUDE.md
4. Show the user what was created
5. Ask if they want to customize anything

## Examples

### Node.js/TypeScript Project

Detected: Node.js + TypeScript + Next.js + Prisma + PostgreSQL Commands: dev, build, start, test, lint, db:migrate Structure: src/app/, src/components/, src/lib/, prisma/

code

### Python/FastAPI Project

Detected: Python 3.11 + FastAPI + SQLAlchemy + PostgreSQL Commands: dev (uvicorn), test (pytest), lint (ruff) Structure: app/, tests/, alembic/

code

### Mixed Full-Stack

Detected: Python backend (FastAPI) + React frontend (Vite) Backend: /backend - Python, FastAPI, SQLAlchemy Frontend: /frontend - TypeScript, React, Vite

code

## Tips

- If the project is a monorepo, detect and document each package/service
- Look for README.md for additional context
- Check for existing CLAUDE.md and offer to enhance rather than replace
- Respect .gitignore patterns when scanning