claude-md-memory

dredd-us 的头像作者 dredd-us

中央CLAUDE.md文件,将项目指南自动注入系统提示,通过一致的上下文在多跳推理中实现10%的准确性提升。用于存储库范围的上下文、编码标准执行、项目指南或架构文档。由Claude Code CLI自动加载。在"project context"、"coding standards"、"CLAUDE.md"、"project guidelines"、"repo documentation"时触发。

📖 中文导读:中央CLAUDE.md文件,将项目指南自动注入系统提示,通过一致的上下文在多跳推理中实现10%的准确性提升。用于存储库范围的上下文、编码标准执行、项目指南或架构文档。由Claude Code CLI自动加载。在"project context"、"coding standards"、"CLAUDE.md"、"project guidelines"、"repo documentation"时触发。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: claude-md-memory description: Central CLAUDE.md file with project guidelines auto-injected into system prompt, achieving 10% accuracy lift in multi-hop reasoning through consistent context. Use for repo-wide context, coding standards enforcement, project guidelines, or architecture documentation. Auto-loaded by Claude Code CLI. Triggers on "project context", "coding standards", "CLAUDE.md", "project guidelines", "repo documentation".

CLAUDE.md Memory Injection

Purpose

Central CLAUDE.md file with project guidelines injected into system prompt, achieving 10% accuracy lift in multi-hop reasoning.

When to Use

  • Establishing repo-wide context
  • Enforcing coding standards
  • Documenting project architecture
  • Providing consistent guidelines
  • Team onboarding
  • Cross-file consistency

Core Instructions

CLAUDE.md Structure

Create CLAUDE.md in repository root:

# Project: Your Project Name

## Overview
Brief project description and goals.

## Architecture

### Directory Structure

src/ services/ # Business logic models/ # Data models routes/ # API endpoints utils/ # Helper functions tests/ # Co-located with code


## Coding Standards

- **Language**: TypeScript with strict mode
- **Style**: ESLint + Prettier
- **Testing**: Jest, 80% coverage minimum
- **Commits**: Conventional Commits format

## Common Patterns

### Error Handling
```typescript
try {
  const result = await operation();
  return result;
} catch (error) {
  logger.error(error);
  throw new AppError('Operation failed', error);
}

API Routes

router.post('/resource',
  validate(schema),
  authenticate,
  async (req, res) => {
    // Handler logic
  }
);

Project-Specific

  • Environment: .env for secrets
  • Database: PostgreSQL with TypeORM
  • API: RESTful, OpenAPI documented
  • Deploy: GitHub Actions → Cloud Run

File Conventions

  • Components: PascalCase (UserProfile.tsx)
  • Utils: camelCase (formatDate.ts)
  • Tests: *.test.ts (co-located)
  • Config: kebab-case (api-config.ts)

Common Commands

npm run dev       # Start development server
npm test          # Run tests
npm run lint      # Check linting
npm run build     # Production build

References


### Auto-Injection

Claude Code CLI automatically:
1. Detects `CLAUDE.md` in repository root
2. Loads content into system prompt
3. Injects for every session
4. Maintains consistency across interactions

No manual loading required!

### Benefits

**10% accuracy improvement** in:
- Multi-hop reasoning
- Cross-file consistency
- Following project patterns
- Respecting conventions

**Consistency:**
- Same standards across team
- Automated enforcement
- Self-documenting project
- Onboarding acceleration

## Example Impact

**Without CLAUDE.md:**
```typescript
// Inconsistent patterns
function getUserData(id) {  // Wrong: no types
  return db.query("SELECT * FROM users WHERE id = " + id);  // Wrong: SQL injection risk
}

With CLAUDE.md:

// Follows project standards
async function getUserData(id: string): Promise<User> {
  return await db.users.findOne({ where: { id } });
}

Best Practices

Keep it Focused

  • Essential guidelines only
  • Not a full documentation site
  • Quick reference format
  • Link to detailed docs

Update Regularly

  • Reflect current practices
  • Remove outdated info
  • Version with Git
  • Review in PRs

Team Collaboration

  • Discuss changes in PRs
  • Consensus on standards
  • Document exceptions
  • Keep it living document

Template Sections

Essential:

  • Project overview
  • Architecture basics
  • Coding standards
  • Common patterns

Optional:

  • Deployment process
  • Testing strategy
  • Security guidelines
  • Performance tips

Performance

  • 10% accuracy lift in multi-hop reasoning
  • Consistent pattern adherence
  • Reduced questions about standards
  • Faster onboarding

Version

v1.0.0 (2025-10-23) - Based on context injection patterns