claude-code-templates 1.14.12 → 1.14.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-claude-config.js +1 -0
- package/package.json +1 -2
- package/src/file-operations.js +239 -36
- package/src/index.js +347 -9
- package/templates/common/.claude/commands/git-workflow.md +0 -239
- package/templates/common/.claude/commands/project-setup.md +0 -316
- package/templates/common/.mcp.json +0 -41
- package/templates/common/CLAUDE.md +0 -109
- package/templates/common/README.md +0 -96
- package/templates/go/.mcp.json +0 -78
- package/templates/go/README.md +0 -25
- package/templates/javascript-typescript/.claude/commands/api-endpoint.md +0 -51
- package/templates/javascript-typescript/.claude/commands/debug.md +0 -52
- package/templates/javascript-typescript/.claude/commands/lint.md +0 -48
- package/templates/javascript-typescript/.claude/commands/npm-scripts.md +0 -48
- package/templates/javascript-typescript/.claude/commands/refactor.md +0 -55
- package/templates/javascript-typescript/.claude/commands/test.md +0 -61
- package/templates/javascript-typescript/.claude/commands/typescript-migrate.md +0 -51
- package/templates/javascript-typescript/.claude/settings.json +0 -142
- package/templates/javascript-typescript/.mcp.json +0 -80
- package/templates/javascript-typescript/CLAUDE.md +0 -185
- package/templates/javascript-typescript/README.md +0 -259
- package/templates/javascript-typescript/examples/angular-app/.claude/commands/components.md +0 -63
- package/templates/javascript-typescript/examples/angular-app/.claude/commands/services.md +0 -62
- package/templates/javascript-typescript/examples/node-api/.claude/commands/api-endpoint.md +0 -46
- package/templates/javascript-typescript/examples/node-api/.claude/commands/database.md +0 -56
- package/templates/javascript-typescript/examples/node-api/.claude/commands/middleware.md +0 -61
- package/templates/javascript-typescript/examples/node-api/.claude/commands/route.md +0 -57
- package/templates/javascript-typescript/examples/node-api/CLAUDE.md +0 -102
- package/templates/javascript-typescript/examples/react-app/.claude/commands/component.md +0 -29
- package/templates/javascript-typescript/examples/react-app/.claude/commands/hooks.md +0 -44
- package/templates/javascript-typescript/examples/react-app/.claude/commands/state-management.md +0 -45
- package/templates/javascript-typescript/examples/react-app/CLAUDE.md +0 -81
- package/templates/javascript-typescript/examples/react-app/agents/react-performance-optimization.md +0 -530
- package/templates/javascript-typescript/examples/react-app/agents/react-state-management.md +0 -295
- package/templates/javascript-typescript/examples/vue-app/.claude/commands/components.md +0 -46
- package/templates/javascript-typescript/examples/vue-app/.claude/commands/composables.md +0 -51
- package/templates/python/.claude/commands/lint.md +0 -111
- package/templates/python/.claude/commands/test.md +0 -73
- package/templates/python/.claude/settings.json +0 -153
- package/templates/python/.mcp.json +0 -78
- package/templates/python/CLAUDE.md +0 -276
- package/templates/python/examples/django-app/.claude/commands/admin.md +0 -264
- package/templates/python/examples/django-app/.claude/commands/django-model.md +0 -124
- package/templates/python/examples/django-app/.claude/commands/views.md +0 -222
- package/templates/python/examples/django-app/CLAUDE.md +0 -313
- package/templates/python/examples/django-app/agents/django-api-security.md +0 -642
- package/templates/python/examples/django-app/agents/django-database-optimization.md +0 -752
- package/templates/python/examples/fastapi-app/.claude/commands/api-endpoints.md +0 -513
- package/templates/python/examples/fastapi-app/.claude/commands/auth.md +0 -775
- package/templates/python/examples/fastapi-app/.claude/commands/database.md +0 -657
- package/templates/python/examples/fastapi-app/.claude/commands/deployment.md +0 -160
- package/templates/python/examples/fastapi-app/.claude/commands/testing.md +0 -927
- package/templates/python/examples/fastapi-app/CLAUDE.md +0 -229
- package/templates/python/examples/flask-app/.claude/commands/app-factory.md +0 -384
- package/templates/python/examples/flask-app/.claude/commands/blueprint.md +0 -243
- package/templates/python/examples/flask-app/.claude/commands/database.md +0 -410
- package/templates/python/examples/flask-app/.claude/commands/deployment.md +0 -620
- package/templates/python/examples/flask-app/.claude/commands/flask-route.md +0 -217
- package/templates/python/examples/flask-app/.claude/commands/testing.md +0 -559
- package/templates/python/examples/flask-app/CLAUDE.md +0 -391
- package/templates/ruby/.claude/commands/model.md +0 -360
- package/templates/ruby/.claude/commands/test.md +0 -480
- package/templates/ruby/.claude/settings.json +0 -146
- package/templates/ruby/.mcp.json +0 -83
- package/templates/ruby/CLAUDE.md +0 -284
- package/templates/ruby/examples/rails-app/.claude/commands/authentication.md +0 -490
- package/templates/ruby/examples/rails-app/CLAUDE.md +0 -376
- package/templates/rust/.mcp.json +0 -78
- package/templates/rust/README.md +0 -26
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"Bash",
|
|
5
|
-
"Edit",
|
|
6
|
-
"MultiEdit",
|
|
7
|
-
"Write",
|
|
8
|
-
"Bash(python:*)",
|
|
9
|
-
"Bash(pip:*)",
|
|
10
|
-
"Bash(pytest:*)",
|
|
11
|
-
"Bash(black:*)",
|
|
12
|
-
"Bash(isort:*)",
|
|
13
|
-
"Bash(flake8:*)",
|
|
14
|
-
"Bash(mypy:*)",
|
|
15
|
-
"Bash(django-admin:*)",
|
|
16
|
-
"Bash(flask:*)",
|
|
17
|
-
"Bash(uvicorn:*)",
|
|
18
|
-
"Bash(gunicorn:*)",
|
|
19
|
-
"Bash(git:*)"
|
|
20
|
-
],
|
|
21
|
-
"deny": [
|
|
22
|
-
"Bash(curl:*)",
|
|
23
|
-
"Bash(wget:*)",
|
|
24
|
-
"Bash(rm -rf:*)"
|
|
25
|
-
],
|
|
26
|
-
"defaultMode": "allowEdits"
|
|
27
|
-
},
|
|
28
|
-
"env": {
|
|
29
|
-
"BASH_DEFAULT_TIMEOUT_MS": "60000",
|
|
30
|
-
"BASH_MAX_OUTPUT_LENGTH": "20000",
|
|
31
|
-
"CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR": "1",
|
|
32
|
-
"PYTHONPATH": "."
|
|
33
|
-
},
|
|
34
|
-
"includeCoAuthoredBy": true,
|
|
35
|
-
"cleanupPeriodDays": 30,
|
|
36
|
-
"hooks": {
|
|
37
|
-
"PreToolUse": [
|
|
38
|
-
{
|
|
39
|
-
"matcher": "Bash",
|
|
40
|
-
"hooks": [
|
|
41
|
-
{
|
|
42
|
-
"type": "command",
|
|
43
|
-
"command": "jq -r '\"\\(.tool_input.command) - \\(.tool_input.description // \"No description\")\"' >> ~/.claude/bash-command-log.txt"
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"matcher": "Write",
|
|
49
|
-
"hooks": [
|
|
50
|
-
{
|
|
51
|
-
"type": "command",
|
|
52
|
-
"command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"); CONTENT=$(echo $STDIN_JSON | jq -r '.tool_input.content // \"\"); if [[ \"$FILE\" =~ \\.py$ ]] && echo \"$CONTENT\" | grep -q 'print('; then echo 'Warning: print() statements should be replaced with logging' >&2; exit 2; fi"
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"matcher": "Write",
|
|
58
|
-
"hooks": [
|
|
59
|
-
{
|
|
60
|
-
"type": "command",
|
|
61
|
-
"command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"'); if [[ \"$FILE\" == \"requirements.txt\" ]] || [[ \"$FILE\" == \"pyproject.toml\" ]] || [[ \"$FILE\" == \"setup.py\" ]]; then echo 'Checking for vulnerable dependencies...'; if command -v safety >/dev/null 2>&1; then safety check; elif command -v pip-audit >/dev/null 2>&1; then pip-audit; else echo 'No security audit tool found. Install safety or pip-audit'; fi; fi",
|
|
62
|
-
"timeout": 60
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
"PostToolUse": [
|
|
68
|
-
{
|
|
69
|
-
"matcher": "Write|Edit|MultiEdit",
|
|
70
|
-
"hooks": [
|
|
71
|
-
{
|
|
72
|
-
"type": "command",
|
|
73
|
-
"command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"'); if [[ \"$FILE\" =~ \\.py$ ]]; then black \"$FILE\" 2>/dev/null || echo 'Black formatting skipped (not installed)'; fi",
|
|
74
|
-
"timeout": 30
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"matcher": "Write|Edit|MultiEdit",
|
|
80
|
-
"hooks": [
|
|
81
|
-
{
|
|
82
|
-
"type": "command",
|
|
83
|
-
"command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"'); if [[ \"$FILE\" =~ \\.py$ ]]; then isort \"$FILE\" 2>/dev/null || echo 'isort skipped (not installed)'; fi",
|
|
84
|
-
"timeout": 30
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"matcher": "Write|Edit|MultiEdit",
|
|
90
|
-
"hooks": [
|
|
91
|
-
{
|
|
92
|
-
"type": "command",
|
|
93
|
-
"command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"'); if [[ \"$FILE\" =~ \\.py$ ]]; then RESULT=$(flake8 \"$FILE\" 2>&1); if [ $? -ne 0 ] && command -v flake8 >/dev/null 2>&1; then echo \"Flake8 linting issues found: $RESULT\" >&2; exit 2; fi; fi",
|
|
94
|
-
"timeout": 30
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"matcher": "Write|Edit|MultiEdit",
|
|
100
|
-
"hooks": [
|
|
101
|
-
{
|
|
102
|
-
"type": "command",
|
|
103
|
-
"command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"'); if [[ \"$FILE\" =~ \\.py$ ]]; then RESULT=$(mypy \"$FILE\" 2>&1); if [ $? -ne 0 ] && command -v mypy >/dev/null 2>&1; then echo \"MyPy type checking issues found: $RESULT\" >&2; exit 2; fi; fi",
|
|
104
|
-
"timeout": 30
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"matcher": "Write|Edit|MultiEdit",
|
|
110
|
-
"hooks": [
|
|
111
|
-
{
|
|
112
|
-
"type": "command",
|
|
113
|
-
"command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"'); if [[ \"$FILE\" =~ \\.py$ && \"$FILE\" != *\"test_\"* && \"$FILE\" != *\"_test.py\" ]]; then DIR=$(dirname \"$FILE\"); BASENAME=$(basename \"$FILE\" .py); for TEST_FILE in \"$DIR/test_$BASENAME.py\" \"$DIR/${BASENAME}_test.py\" \"tests/test_$BASENAME.py\"; do if [ -f \"$TEST_FILE\" ]; then echo \"Running tests for $TEST_FILE...\"; if command -v pytest >/dev/null 2>&1; then pytest \"$TEST_FILE\" -v; elif python -m pytest \"$TEST_FILE\" 2>/dev/null; then python -m pytest \"$TEST_FILE\" -v; else python -m unittest \"$TEST_FILE\" 2>/dev/null || echo 'No test runner found'; fi; break; fi; done; fi",
|
|
114
|
-
"timeout": 60
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
],
|
|
119
|
-
"Notification": [
|
|
120
|
-
{
|
|
121
|
-
"matcher": "",
|
|
122
|
-
"hooks": [
|
|
123
|
-
{
|
|
124
|
-
"type": "command",
|
|
125
|
-
"command": "echo \"Claude Code notification: $(date)\" >> ~/.claude/notifications.log"
|
|
126
|
-
}
|
|
127
|
-
]
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
"Stop": [
|
|
131
|
-
{
|
|
132
|
-
"matcher": "",
|
|
133
|
-
"hooks": [
|
|
134
|
-
{
|
|
135
|
-
"type": "command",
|
|
136
|
-
"command": "if [[ -f requirements.txt || -f pyproject.toml || -f setup.py ]] && [[ $(git status --porcelain | grep '\\.py$') ]]; then echo 'Running linter on changed Python files...'; if command -v flake8 >/dev/null 2>&1; then flake8 $(git diff --name-only --diff-filter=ACMR | grep '\\.py$'); elif command -v pylint >/dev/null 2>&1; then pylint $(git diff --name-only --diff-filter=ACMR | grep '\\.py$'); else echo 'No Python linter found (flake8/pylint)'; fi; fi",
|
|
137
|
-
"timeout": 60
|
|
138
|
-
}
|
|
139
|
-
]
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
"matcher": "",
|
|
143
|
-
"hooks": [
|
|
144
|
-
{
|
|
145
|
-
"type": "command",
|
|
146
|
-
"command": "if [[ -f requirements.txt || -f pyproject.toml || -f setup.py ]] && [[ $(git status --porcelain | grep '\\.py$') ]]; then echo 'Running type checking on changed files...'; if command -v mypy >/dev/null 2>&1; then mypy $(git diff --name-only --diff-filter=ACMR | grep '\\.py$') || echo 'Type checking completed with issues'; else echo 'MyPy not found for type checking'; fi; fi",
|
|
147
|
-
"timeout": 60
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
]
|
|
152
|
-
}
|
|
153
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mcpServers": {
|
|
3
|
-
"python-sdk": {
|
|
4
|
-
"name": "Python SDK",
|
|
5
|
-
"description": "Official Python SDK with FastMCP for rapid MCP development",
|
|
6
|
-
"command": "python",
|
|
7
|
-
"args": ["-m", "python_sdk.server"],
|
|
8
|
-
"env": {}
|
|
9
|
-
},
|
|
10
|
-
"docker": {
|
|
11
|
-
"name": "Docker MCP",
|
|
12
|
-
"description": "Isolated code execution via Docker containers",
|
|
13
|
-
"command": "python",
|
|
14
|
-
"args": ["-m", "mcp_server_docker"],
|
|
15
|
-
"env": {}
|
|
16
|
-
},
|
|
17
|
-
"jupyter": {
|
|
18
|
-
"name": "Jupyter MCP",
|
|
19
|
-
"description": "MCP integration for interactive Jupyter notebooks",
|
|
20
|
-
"command": "python",
|
|
21
|
-
"args": ["-m", "server_jupyter"],
|
|
22
|
-
"env": {}
|
|
23
|
-
},
|
|
24
|
-
"postgresql": {
|
|
25
|
-
"name": "PostgreSQL MCP",
|
|
26
|
-
"description": "Natural language queries to PostgreSQL databases",
|
|
27
|
-
"command": "python",
|
|
28
|
-
"args": ["-m", "server_postgres"],
|
|
29
|
-
"env": {
|
|
30
|
-
"DATABASE_URL": "postgresql://user:pass@host/db"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"opik": {
|
|
34
|
-
"name": "Opik MCP",
|
|
35
|
-
"description": "Observability for LLM apps with tracing and metrics",
|
|
36
|
-
"command": "python",
|
|
37
|
-
"args": ["-m", "opik_mcp"],
|
|
38
|
-
"env": {}
|
|
39
|
-
},
|
|
40
|
-
"memory-bank": {
|
|
41
|
-
"name": "Memory Bank MCP",
|
|
42
|
-
"description": "Centralized memory system for AI agents",
|
|
43
|
-
"command": "server-memory",
|
|
44
|
-
"args": [],
|
|
45
|
-
"env": {}
|
|
46
|
-
},
|
|
47
|
-
"sequential-thinking": {
|
|
48
|
-
"name": "Sequential Thinking MCP",
|
|
49
|
-
"description": "Helps LLMs decompose complex tasks into logical steps",
|
|
50
|
-
"command": "code-reasoning",
|
|
51
|
-
"args": [],
|
|
52
|
-
"env": {}
|
|
53
|
-
},
|
|
54
|
-
"brave-search": {
|
|
55
|
-
"name": "Brave Search MCP",
|
|
56
|
-
"description": "Privacy-focused web search tool",
|
|
57
|
-
"command": "server-brave-search",
|
|
58
|
-
"args": [],
|
|
59
|
-
"env": {}
|
|
60
|
-
},
|
|
61
|
-
"google-maps": {
|
|
62
|
-
"name": "Google Maps MCP",
|
|
63
|
-
"description": "Integrates Google Maps for geolocation and directions",
|
|
64
|
-
"command": "server-google-maps",
|
|
65
|
-
"args": [],
|
|
66
|
-
"env": {
|
|
67
|
-
"GOOGLE_MAPS_API_KEY": "..."
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"deep-graph": {
|
|
71
|
-
"name": "Deep Graph MCP (Code Graph)",
|
|
72
|
-
"description": "Transforms source code into semantic graphs via DeepGraph",
|
|
73
|
-
"command": "mcp-code-graph",
|
|
74
|
-
"args": [],
|
|
75
|
-
"env": {}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## Project Overview
|
|
6
|
-
|
|
7
|
-
This is a Python project optimized for modern Python development. The project uses industry-standard tools and follows best practices for scalable application development.
|
|
8
|
-
|
|
9
|
-
## Development Commands
|
|
10
|
-
|
|
11
|
-
### Environment Management
|
|
12
|
-
- `python -m venv venv` - Create virtual environment
|
|
13
|
-
- `source venv/bin/activate` (Linux/Mac) or `venv\Scripts\activate` (Windows) - Activate virtual environment
|
|
14
|
-
- `deactivate` - Deactivate virtual environment
|
|
15
|
-
- `pip install -r requirements.txt` - Install dependencies
|
|
16
|
-
- `pip install -r requirements-dev.txt` - Install development dependencies
|
|
17
|
-
|
|
18
|
-
### Package Management
|
|
19
|
-
- `pip install <package>` - Install a package
|
|
20
|
-
- `pip install -e .` - Install project in development mode
|
|
21
|
-
- `pip freeze > requirements.txt` - Generate requirements file
|
|
22
|
-
- `pip-tools compile requirements.in` - Compile requirements with pip-tools
|
|
23
|
-
|
|
24
|
-
### Testing Commands
|
|
25
|
-
- `pytest` - Run all tests
|
|
26
|
-
- `pytest -v` - Run tests with verbose output
|
|
27
|
-
- `pytest --cov` - Run tests with coverage report
|
|
28
|
-
- `pytest --cov-report=html` - Generate HTML coverage report
|
|
29
|
-
- `pytest -x` - Stop on first failure
|
|
30
|
-
- `pytest -k "test_name"` - Run specific test by name
|
|
31
|
-
- `python -m unittest` - Run tests with unittest
|
|
32
|
-
|
|
33
|
-
### Code Quality Commands
|
|
34
|
-
- `black .` - Format code with Black
|
|
35
|
-
- `black --check .` - Check code formatting without changes
|
|
36
|
-
- `isort .` - Sort imports
|
|
37
|
-
- `isort --check-only .` - Check import sorting
|
|
38
|
-
- `flake8` - Run linting with Flake8
|
|
39
|
-
- `pylint src/` - Run linting with Pylint
|
|
40
|
-
- `mypy src/` - Run type checking with MyPy
|
|
41
|
-
|
|
42
|
-
### Development Tools
|
|
43
|
-
- `python -m pip install --upgrade pip` - Upgrade pip
|
|
44
|
-
- `python -c "import sys; print(sys.version)"` - Check Python version
|
|
45
|
-
- `python -m site` - Show Python site information
|
|
46
|
-
- `python -m pdb script.py` - Debug with pdb
|
|
47
|
-
|
|
48
|
-
## Technology Stack
|
|
49
|
-
|
|
50
|
-
### Core Technologies
|
|
51
|
-
- **Python** - Primary programming language (3.8+)
|
|
52
|
-
- **pip** - Package management
|
|
53
|
-
- **venv** - Virtual environment management
|
|
54
|
-
|
|
55
|
-
### Common Frameworks
|
|
56
|
-
- **Django** - High-level web framework
|
|
57
|
-
- **Flask** - Micro web framework
|
|
58
|
-
- **FastAPI** - Modern API framework with automatic documentation
|
|
59
|
-
- **SQLAlchemy** - SQL toolkit and ORM
|
|
60
|
-
- **Pydantic** - Data validation using Python type hints
|
|
61
|
-
|
|
62
|
-
### Data Science & ML
|
|
63
|
-
- **NumPy** - Numerical computing
|
|
64
|
-
- **Pandas** - Data manipulation and analysis
|
|
65
|
-
- **Matplotlib/Seaborn** - Data visualization
|
|
66
|
-
- **Scikit-learn** - Machine learning library
|
|
67
|
-
- **TensorFlow/PyTorch** - Deep learning frameworks
|
|
68
|
-
|
|
69
|
-
### Testing Frameworks
|
|
70
|
-
- **pytest** - Testing framework
|
|
71
|
-
- **unittest** - Built-in testing framework
|
|
72
|
-
- **pytest-cov** - Coverage plugin for pytest
|
|
73
|
-
- **factory-boy** - Test fixtures
|
|
74
|
-
- **responses** - Mock HTTP requests
|
|
75
|
-
|
|
76
|
-
### Code Quality Tools
|
|
77
|
-
- **Black** - Code formatter
|
|
78
|
-
- **isort** - Import sorter
|
|
79
|
-
- **flake8** - Style guide enforcement
|
|
80
|
-
- **pylint** - Code analysis
|
|
81
|
-
- **mypy** - Static type checker
|
|
82
|
-
- **pre-commit** - Git hooks framework
|
|
83
|
-
|
|
84
|
-
## Project Structure Guidelines
|
|
85
|
-
|
|
86
|
-
### File Organization
|
|
87
|
-
```
|
|
88
|
-
src/
|
|
89
|
-
├── package_name/
|
|
90
|
-
│ ├── __init__.py
|
|
91
|
-
│ ├── main.py # Application entry point
|
|
92
|
-
│ ├── models/ # Data models
|
|
93
|
-
│ ├── views/ # Web views (Django/Flask)
|
|
94
|
-
│ ├── api/ # API endpoints
|
|
95
|
-
│ ├── services/ # Business logic
|
|
96
|
-
│ ├── utils/ # Utility functions
|
|
97
|
-
│ └── config/ # Configuration files
|
|
98
|
-
tests/
|
|
99
|
-
├── __init__.py
|
|
100
|
-
├── conftest.py # pytest configuration
|
|
101
|
-
├── test_models.py
|
|
102
|
-
├── test_views.py
|
|
103
|
-
└── test_utils.py
|
|
104
|
-
requirements/
|
|
105
|
-
├── base.txt # Base requirements
|
|
106
|
-
├── dev.txt # Development requirements
|
|
107
|
-
└── prod.txt # Production requirements
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### Naming Conventions
|
|
111
|
-
- **Files/Modules**: Use snake_case (`user_profile.py`)
|
|
112
|
-
- **Classes**: Use PascalCase (`UserProfile`)
|
|
113
|
-
- **Functions/Variables**: Use snake_case (`get_user_data`)
|
|
114
|
-
- **Constants**: Use UPPER_SNAKE_CASE (`API_BASE_URL`)
|
|
115
|
-
- **Private methods**: Prefix with underscore (`_private_method`)
|
|
116
|
-
|
|
117
|
-
## Python Guidelines
|
|
118
|
-
|
|
119
|
-
### Type Hints
|
|
120
|
-
- Use type hints for function parameters and return values
|
|
121
|
-
- Import types from `typing` module when needed
|
|
122
|
-
- Use `Optional` for nullable values
|
|
123
|
-
- Use `Union` for multiple possible types
|
|
124
|
-
- Document complex types with comments
|
|
125
|
-
|
|
126
|
-
### Code Style
|
|
127
|
-
- Follow PEP 8 style guide
|
|
128
|
-
- Use meaningful variable and function names
|
|
129
|
-
- Keep functions focused and single-purpose
|
|
130
|
-
- Use docstrings for modules, classes, and functions
|
|
131
|
-
- Limit line length to 88 characters (Black default)
|
|
132
|
-
|
|
133
|
-
### Best Practices
|
|
134
|
-
- Use list comprehensions for simple transformations
|
|
135
|
-
- Prefer `pathlib` over `os.path` for file operations
|
|
136
|
-
- Use context managers (`with` statements) for resource management
|
|
137
|
-
- Handle exceptions appropriately with try/except blocks
|
|
138
|
-
- Use `logging` module instead of print statements
|
|
139
|
-
|
|
140
|
-
## Testing Standards
|
|
141
|
-
|
|
142
|
-
### Test Structure
|
|
143
|
-
- Organize tests to mirror source code structure
|
|
144
|
-
- Use descriptive test names that explain the behavior
|
|
145
|
-
- Follow AAA pattern (Arrange, Act, Assert)
|
|
146
|
-
- Use fixtures for common test data
|
|
147
|
-
- Group related tests in classes
|
|
148
|
-
|
|
149
|
-
### Coverage Goals
|
|
150
|
-
- Aim for 90%+ test coverage
|
|
151
|
-
- Write unit tests for business logic
|
|
152
|
-
- Use integration tests for external dependencies
|
|
153
|
-
- Mock external services in tests
|
|
154
|
-
- Test error conditions and edge cases
|
|
155
|
-
|
|
156
|
-
### pytest Configuration
|
|
157
|
-
```python
|
|
158
|
-
# pytest.ini or pyproject.toml
|
|
159
|
-
[tool.pytest.ini_options]
|
|
160
|
-
testpaths = ["tests"]
|
|
161
|
-
python_files = ["test_*.py", "*_test.py"]
|
|
162
|
-
python_classes = ["Test*"]
|
|
163
|
-
python_functions = ["test_*"]
|
|
164
|
-
addopts = "--cov=src --cov-report=term-missing"
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## Virtual Environment Setup
|
|
168
|
-
|
|
169
|
-
### Creation and Activation
|
|
170
|
-
```bash
|
|
171
|
-
# Create virtual environment
|
|
172
|
-
python -m venv venv
|
|
173
|
-
|
|
174
|
-
# Activate (Linux/Mac)
|
|
175
|
-
source venv/bin/activate
|
|
176
|
-
|
|
177
|
-
# Activate (Windows)
|
|
178
|
-
venv\Scripts\activate
|
|
179
|
-
|
|
180
|
-
# Install dependencies
|
|
181
|
-
pip install -r requirements.txt
|
|
182
|
-
pip install -r requirements-dev.txt
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### Requirements Management
|
|
186
|
-
- Use `requirements.txt` for production dependencies
|
|
187
|
-
- Use `requirements-dev.txt` for development dependencies
|
|
188
|
-
- Consider using `pip-tools` for dependency resolution
|
|
189
|
-
- Pin versions for reproducible builds
|
|
190
|
-
|
|
191
|
-
## Django-Specific Guidelines
|
|
192
|
-
|
|
193
|
-
### Project Structure
|
|
194
|
-
```
|
|
195
|
-
project_name/
|
|
196
|
-
├── manage.py
|
|
197
|
-
├── project_name/
|
|
198
|
-
│ ├── __init__.py
|
|
199
|
-
│ ├── settings/
|
|
200
|
-
│ ├── urls.py
|
|
201
|
-
│ └── wsgi.py
|
|
202
|
-
├── apps/
|
|
203
|
-
│ ├── users/
|
|
204
|
-
│ ├── products/
|
|
205
|
-
│ └── orders/
|
|
206
|
-
└── requirements/
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### Common Commands
|
|
210
|
-
- `python manage.py runserver` - Start development server
|
|
211
|
-
- `python manage.py migrate` - Apply database migrations
|
|
212
|
-
- `python manage.py makemigrations` - Create new migrations
|
|
213
|
-
- `python manage.py createsuperuser` - Create admin user
|
|
214
|
-
- `python manage.py collectstatic` - Collect static files
|
|
215
|
-
- `python manage.py test` - Run Django tests
|
|
216
|
-
|
|
217
|
-
## FastAPI-Specific Guidelines
|
|
218
|
-
|
|
219
|
-
### Project Structure
|
|
220
|
-
```
|
|
221
|
-
src/
|
|
222
|
-
├── main.py # FastAPI application
|
|
223
|
-
├── api/
|
|
224
|
-
│ ├── __init__.py
|
|
225
|
-
│ ├── dependencies.py # Dependency injection
|
|
226
|
-
│ └── v1/
|
|
227
|
-
│ ├── __init__.py
|
|
228
|
-
│ └── endpoints/
|
|
229
|
-
├── core/
|
|
230
|
-
│ ├── __init__.py
|
|
231
|
-
│ ├── config.py # Settings
|
|
232
|
-
│ └── security.py # Authentication
|
|
233
|
-
├── models/
|
|
234
|
-
├── schemas/ # Pydantic models
|
|
235
|
-
└── services/
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Common Commands
|
|
239
|
-
- `uvicorn main:app --reload` - Start development server
|
|
240
|
-
- `uvicorn main:app --host 0.0.0.0 --port 8000` - Start production server
|
|
241
|
-
|
|
242
|
-
## Security Guidelines
|
|
243
|
-
|
|
244
|
-
### Dependencies
|
|
245
|
-
- Regularly update dependencies with `pip list --outdated`
|
|
246
|
-
- Use `safety` package to check for known vulnerabilities
|
|
247
|
-
- Pin dependency versions in requirements files
|
|
248
|
-
- Use virtual environments to isolate dependencies
|
|
249
|
-
|
|
250
|
-
### Code Security
|
|
251
|
-
- Validate input data with Pydantic or similar
|
|
252
|
-
- Use environment variables for sensitive configuration
|
|
253
|
-
- Implement proper authentication and authorization
|
|
254
|
-
- Sanitize data before database operations
|
|
255
|
-
- Use HTTPS for production deployments
|
|
256
|
-
|
|
257
|
-
## Development Workflow
|
|
258
|
-
|
|
259
|
-
### Before Starting
|
|
260
|
-
1. Check Python version compatibility
|
|
261
|
-
2. Create and activate virtual environment
|
|
262
|
-
3. Install dependencies from requirements files
|
|
263
|
-
4. Run type checking with `mypy`
|
|
264
|
-
|
|
265
|
-
### During Development
|
|
266
|
-
1. Use type hints for better code documentation
|
|
267
|
-
2. Run tests frequently to catch issues early
|
|
268
|
-
3. Use meaningful commit messages
|
|
269
|
-
4. Format code with Black before committing
|
|
270
|
-
|
|
271
|
-
### Before Committing
|
|
272
|
-
1. Run full test suite: `pytest`
|
|
273
|
-
2. Check code formatting: `black --check .`
|
|
274
|
-
3. Sort imports: `isort --check-only .`
|
|
275
|
-
4. Run linting: `flake8`
|
|
276
|
-
5. Run type checking: `mypy src/`
|