Skip to content

Commit 4f7bd51

Browse files
yanglbmeclaude
andauthored
feat: add CLAUDE.md and AGENTS.md for AI coding assistants (#5220)
Add project guidance documentation for AI coding tools (Claude Code, Cursor, OpenCode, etc.) covering directory structure, solution patterns, code formatting, and development workflow. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 3515eb6 commit 4f7bd51

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@CLAUDE.md

CLAUDE.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to AI coding assistants (Claude Code, Cursor, OpenCode, etc.) when working with code in this repository.
4+
5+
## Repository Overview
6+
7+
This is [doocs/leetcode](https://github.com/doocs/leetcode) — a large collection of LeetCode, Coding Interviews, and other algorithm problem solutions, each implemented in multiple programming languages (Python, Java, C++, Go, TypeScript, Rust, C#, PHP, JavaScript, Kotlin, Swift, Scala, Ruby, Nim, Shell, SQL).
8+
9+
## Directory Structure
10+
11+
- **`solution/`** — Main LeetCode solutions, organized by problem number ranges (e.g., `0000-0099/`, `0100-0199/`). Each problem has its own directory (e.g., `0000-0099/0001.Two Sum/`) containing:
12+
- `README.md` / `README_EN.md` — Chinese/English problem descriptions
13+
- `Solution.{py,java,cpp,go,ts,cs,rs,...}` — Solution files in each language
14+
- Follow standard LeetCode class-based structure: `class Solution` with the method
15+
16+
- **`lcof/`** — 剑指 Offer (Coding Interviews, 2nd Edition) — problem directories named with Chinese titles
17+
- **`lcof2/`** — 剑指 Offer 专项突击版 (Coding Interviews, Special Edition)
18+
- **`lcci/`** — 程序员面试金典 (Cracking the Coding Interview, 6th Edition) — `01.01.Is Unique` format
19+
- **`lcp/`** — LeetCode Contest Problems
20+
- **`lcs/`** — LeetCode Contest (separate series)
21+
- **`basic/`** — Basic algorithm implementations (sorting algorithms like BubbleSort, QuickSort, etc.)
22+
23+
## Development Workflow
24+
25+
### Adding a New Solution
26+
27+
1. Create a new problem directory under the appropriate parent (e.g., `solution/0000-0099/0042.My Problem/`)
28+
2. Add `Solution.py`, `Solution.java`, `Solution.cpp`, `Solution.go`, `Solution.ts`, `Solution.rs`, `Solution.cs`, etc.
29+
3. Add `README.md` and `README_EN.md` with problem description and solution explanations
30+
4. Follow the existing templates in `solution/template.md` for README formatting
31+
5. All language solutions must implement the same algorithm logic
32+
33+
### Code Formatting
34+
35+
All code must be formatted before committing. The lint-staged hooks run automatically on pre-commit:
36+
37+
```bash
38+
# JavaScript/TypeScript/PHP/SQL/Markdown
39+
npx prettier --write "**/*.{js,ts,php,sql,md}"
40+
41+
# Python
42+
py -m black -S <file>
43+
44+
# C/C++/Java
45+
npx clang-format -i --style=file <file>
46+
47+
# Go
48+
gofmt -w <file>
49+
50+
# Rust
51+
rustfmt <file>
52+
```
53+
54+
Or run the full formatting script:
55+
56+
```bash
57+
python run_format.py
58+
```
59+
60+
### Installation
61+
62+
```bash
63+
npm install # Installs dev dependencies and triggers pip install for Python deps
64+
```
65+
66+
### CI/CD
67+
68+
GitHub Actions automatically run:
69+
70+
- **clang-format** lint on C/C++/Java files
71+
- **Black** lint on Python files
72+
- **Prettier** on JS/TS/PHP/SQL/Markdown files
73+
- **Deploy** workflow for the documentation site
74+
75+
## Solution Patterns
76+
77+
- Python solutions use `List` from typing (imported implicitly by LeetCode environment)
78+
- Go solutions include `package main` header (added/removed by formatting script)
79+
- PHP solutions include `<?php` header (added/removed by formatting script)
80+
- SQL solutions uppercase built-in function names (handled by `run_format.py`)
81+
- C# solutions contributed by [@kfstorm](https://github.com/kfstorm)
82+
83+
## Key Conventions
84+
85+
- Problem directories follow naming convention: `{NUMBER}.{Problem Name with Spaces}`
86+
- Each solution file is named `Solution.{ext}` (capital S)
87+
- README files use special HTML comment markers for templating (e.g., `<!-- problem:start -->`, `<!-- solution:start -->`)
88+
- Solutions should match the problem's required class/method signature from LeetCode

0 commit comments

Comments
 (0)