Skip to content

Agent 提示词:CLAUDE.md 创建

Agent Prompt: CLAUDE.md creation

v2.0.14

System prompt for analyzing codebases and creating CLAUDE.md documentation files

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

开发命令

构建与测试

  • npm run build - 构建项目
  • npm testnpm run test - 运行所有测试
  • npm run test:watch - 在监视模式下运行测试
  • npm run test:coverage - 运行测试并生成覆盖率报告
  • npm run lint - 运行代码检查
  • npm run lint:fix - 自动修复可修复的代码问题

开发服务器

  • npm run dev - 启动开发服务器
  • npm start - 启动生产服务器

代码架构

核心架构模式

项目采用分层架构,主要包含以下层次:

  • 表现层 (Presentation Layer) - 处理用户界面和交互
  • 业务逻辑层 (Business Logic Layer) - 包含核心业务规则和用例
  • 数据访问层 (Data Access Layer) - 负责与数据存储交互

关键目录结构

  • src/components/ - 可复用的 UI 组件
  • src/hooks/ - 自定义 React hooks
  • src/services/ - API 服务和外部集成
  • src/utils/ - 工具函数和辅助方法
  • src/types/ - TypeScript 类型定义
  • src/config/ - 配置文件和常量

状态管理

项目使用 Context API 结合自定义 hooks 进行状态管理。主要状态容器位于 src/contexts/ 目录,每个上下文处理特定的业务领域状态。

API 集成

API 调用通过 src/services/ 中的服务类进行抽象。所有服务都遵循统一的错误处理模式,并使用 axios 实例进行 HTTP 请求。

配置系统

环境配置通过 .env 文件管理,配置值在 src/config/ 中验证和导出。不同环境(开发、测试、生产)有各自的配置策略。

开发规范

代码风格

  • 使用 ESLint 和 Prettier 进行代码格式化
  • 遵循项目特定的 TypeScript 配置规则
  • 组件使用函数式组件和 React hooks

测试策略

  • 单元测试使用 Jest 和 React Testing Library
  • 集成测试位于 __tests__ 目录
  • 测试文件与源代码文件保持相同目录结构

提交规范

项目使用 Conventional Commits 规范,提交信息应遵循以下格式:

type(scope): description

[optional body]

[optional footer]

重要注意事项

环境要求

  • Node.js 版本:参见 .nvmrcpackage.json 中的 engines 字段
  • 包管理器:使用 npm 或 yarn(根据 lock 文件确定)

依赖管理

  • 主要依赖在 package.json 中明确指定版本
  • 开发依赖与生产依赖严格分离
  • 定期更新依赖以保持安全性

构建配置

构建系统使用 Webpack/Vite(根据实际情况),配置位于项目根目录的相应配置文件中。自定义构建规则可在配置文件中找到。


英文原文 / English Original

Please analyze this codebase and create a CLAUDE.md file, which will be given to future instances of Claude Code to operate in this repository.

What to add:

  1. Commands that will be commonly used, such as how to build, lint, and run tests. Include the necessary commands to develop in this codebase, such as how to run a single test.
  2. High-level code architecture and structure so that future instances can be productive more quickly. Focus on the "big picture" architecture that requires reading multiple files to understand.

Usage notes:

  • If there's already a CLAUDE.md, suggest improvements to it.
  • When you make the initial CLAUDE.md, do not repeat yourself and do not include obvious instructions like "Provide helpful error messages to users", "Write unit tests for all new utilities", "Never include sensitive information (API keys, tokens) in code or commits".
  • Avoid listing every component or file structure that can be easily discovered.
  • Don't include generic development practices.
  • If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include the important parts.
  • If there is a README.md, make sure to include the important parts.
  • Do not make up information such as "Common Development Tasks", "Tips for Development", "Support and Documentation" unless this is expressly included in other files that you read.
  • Be sure to prefix the file with the following text:
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.