|
| 1 | +# LeetCode Repository Rules |
| 2 | + |
| 3 | +## Discussion Mode |
| 4 | + |
| 5 | +- **Discussion Mode**: Prefix prompt with "D:" to enter read-only discussion mode |
| 6 | +- In discussion mode: NO code updates, only read files and provide analysis/suggestions |
| 7 | +- Always start responses with "[Discussion Mode]" header when in discussion mode |
| 8 | +- Never exit discussion mode automatically - only when user uses "XD:" prefix |
| 9 | +- If user seems to want code changes, remind them to use "XD:" to exit discussion mode |
| 10 | +- **Exit Discussion**: Use "XD:" prefix to exit discussion mode and resume normal operations |
| 11 | + |
| 12 | +## Code Standards |
| 13 | + |
| 14 | +- Use snake_case for Python method names (following Python convention) |
| 15 | +- Always include type hints for function parameters and return types |
| 16 | +- Add return statements to satisfy type checkers even if unreachable |
| 17 | +- Follow the project's linting rules (black, isort, ruff, mypy) |
| 18 | + |
| 19 | +## Template Usage |
| 20 | + |
| 21 | +- **When user copies LeetCode problem**: Use `leetcode/_template/` to structure the question |
| 22 | +- Copy template files to new question directory: `leetcode/{question_name}/` |
| 23 | +- Replace template placeholders with actual problem details: |
| 24 | + - `{method_name}` - snake_case method name (e.g., `two_sum`) |
| 25 | + - `{ClassName}` - PascalCase class name (e.g., `TwoSum`) |
| 26 | + - `{parameters}` - method parameters with types |
| 27 | + - `{return_type}` - return type annotation |
| 28 | + - Test case placeholders with actual examples |
| 29 | +- Always use the template structure for consistency |
| 30 | + |
| 31 | +## File Structure |
| 32 | + |
| 33 | +Each LeetCode problem should have: |
| 34 | + |
| 35 | +- `README.md` - Problem description and examples |
| 36 | +- `solution.py` - Solution implementation |
| 37 | +- `tests.py` - Parametrized pytest tests with loguru logging |
| 38 | +- `__init__.py` - Empty file for Python package |
| 39 | + |
| 40 | +## Testing |
| 41 | + |
| 42 | +- Use `make test-question QUESTION=<question_name>` to run tests |
| 43 | +- Use `make test` to run all questions with coverage |
| 44 | +- Default question is set to `two_sum` in Makefile |
| 45 | +- Tests should cover all provided examples |
| 46 | +- Use loguru for beautiful logging in tests |
0 commit comments