Skip to content

Commit b8a7ff2

Browse files
committed
docs: fix documentation inconsistencies in copilot-instructions and AGENTS
1 parent 8dc85ac commit b8a7ff2

2 files changed

Lines changed: 53 additions & 31 deletions

File tree

.github/copilot-instructions.md

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# GitHub Copilot Instructions
22

3-
> **⚡ Token Efficiency Note**: This is a minimal pointer file (~500 tokens, auto-loaded by Copilot).
4-
> For complete operational details, reference: `#file:AGENTS.md` (~2,500 tokens, loaded on-demand)
3+
> **⚡ Token Efficiency Note**: This is a minimal pointer file (~500 tokens, auto-loaded by Copilot).
4+
> For complete operational details, reference: `#file:AGENTS.md` (~2,500 tokens, loaded on-demand)
55
> For specialized knowledge, use: `#file:SKILLS/<skill-name>/SKILL.md` (loaded on-demand when needed)
66
77
## 🎯 Quick Context
88

9-
**Project**: FastAPI REST API demonstrating modern Python async patterns
10-
**Stack**: Python 3.13 • FastAPI • SQLAlchemy (async) • SQLite • Docker • pytest
11-
**Pattern**: Routes → Services → Database (layered architecture)
9+
**Project**: FastAPI REST API demonstrating modern Python async patterns
10+
**Stack**: Python 3.13 • FastAPI • SQLAlchemy (async) • SQLite • Docker • pytest
11+
**Pattern**: Routes → Services → Database (layered architecture)
1212
**Philosophy**: Learning-focused PoC emphasizing async/await and type safety
1313

1414
## 📐 Core Conventions
@@ -21,7 +21,7 @@
2121

2222
## 🏗️ Architecture at a Glance
2323

24-
```
24+
```text
2525
Route → Service → Database
2626
↓ ↓
2727
Cache Session
@@ -31,7 +31,7 @@ Cache Session
3131
- **Services**: Async database operations via SQLAlchemy
3232
- **Database**: SQLite with async support (`aiosqlite`)
3333
- **Models**: Pydantic for validation, SQLAlchemy for ORM
34-
- **Cache**: aiocache SimpleMemoryCache (10min/1hr TTL)
34+
- **Cache**: aiocache SimpleMemoryCache (TTL: 600s / 10 min)
3535

3636
## ✅ Copilot Should
3737

@@ -56,28 +56,26 @@ Cache Session
5656

5757
```bash
5858
# Run with hot reload
59-
uvicorn main:app --reload --host 0.0.0.0 --port 8000
59+
uvicorn main:app --reload --host 0.0.0.0 --port 9000
6060

6161
# Test with coverage
6262
pytest --cov=. --cov-report=term-missing
6363

6464
# Docker
6565
docker compose up
6666

67-
# Swagger: http://localhost:8000/docs
67+
# Swagger: http://localhost:9000/docs
6868
```
6969

7070
## 📚 Need More Detail?
7171

72-
**For operational procedures**: Load `#file:AGENTS.md`
73-
**For Docker expertise**: *(Planned)* `#file:SKILLS/docker-containerization/SKILL.md`
72+
**For operational procedures**: Load `#file:AGENTS.md`
73+
**For Docker expertise**: *(Planned)* `#file:SKILLS/docker-containerization/SKILL.md`
7474
**For testing patterns**: *(Planned)* `#file:SKILLS/testing-patterns/SKILL.md`
7575

7676
---
7777

7878
💡 **Why this structure?** Copilot auto-loads this file on every chat (~500 tokens). Loading `AGENTS.md` or `SKILLS/` explicitly gives you deep context only when needed, saving 80% of your token budget!
79-
5. **Caching**: In-memory cache (10 min TTL) with `X-Cache` headers (HIT/MISS)
80-
6. **Async/Await**: All database operations are async
8179

8280
## Coding Guidelines
8381

@@ -93,13 +91,15 @@ docker compose up
9391
### File Exclusions
9492

9593
Black and flake8 exclude:
94+
9695
- `.venv`, `.git`, `.github`, `.pytest_cache`, `__pycache__`
9796
- `assets/`, `htmlcov/`, `postman_collections/`, `scripts/`, `storage/`
9897
- Exception: `tests/test_main.py` allows E501 (long lines for test names)
9998

10099
### Commit Conventions
101100

102101
Follow **Conventional Commits** (enforced by commitlint):
102+
103103
- `feat:` for new features
104104
- `fix:` for bug fixes
105105
- `chore:` for maintenance/tooling
@@ -163,17 +163,18 @@ docker compose down -v
163163

164164
## API Endpoints
165165

166-
| Method | Path | Description | Cache |
167-
|--------|-------------------------------------|------------------------------|-------|
168-
| GET | `/health` | Health check | No |
169-
| GET | `/players/` | Get all players | Yes |
170-
| GET | `/players/{player_id}` | Get player by ID | No |
171-
| GET | `/players/squadnumber/{squad_number}` | Get player by squad number | No |
172-
| POST | `/players/` | Create new player | Clears|
173-
| PUT | `/players/{player_id}` | Update existing player | Clears|
174-
| DELETE | `/players/{player_id}` | Delete player | Clears|
166+
| Method | Path | Description | Cache |
167+
|--------|--------------------------------------|------------------------------|-------|
168+
| GET | `/health` | Health check | No |
169+
| GET | `/players/` | Get all players | Yes |
170+
| GET | `/players/{player_id}` | Get player by ID | No |
171+
| GET | `/players/squadnumber/{squad_number}`| Get player by squad number | No |
172+
| POST | `/players/` | Create new player | Clears|
173+
| PUT | `/players/{player_id}` | Update existing player | Clears|
174+
| DELETE | `/players/{player_id}` | Delete player | Clears|
175175

176176
**Cache Notes**:
177+
177178
- Cache key: `"players"`, TTL: 600s (10 min)
178179
- Cache is cleared on POST/PUT/DELETE operations
179180
- Response header `X-Cache: HIT` or `MISS` indicates cache status
@@ -189,6 +190,7 @@ docker compose down -v
189190
## CI/CD Pipeline
190191

191192
GitHub Actions workflow (`.github/workflows/python-app.yml`):
193+
192194
1. **Lint Job**: Commitlint → Flake8 → Black (check mode)
193195
2. **Test Job**: pytest with coverage report generation
194196
3. **Coverage Job**: Upload to Codecov and Codacy (only for same-repo PRs)
@@ -198,18 +200,21 @@ GitHub Actions workflow (`.github/workflows/python-app.yml`):
198200
## Common Pitfalls & Solutions
199201

200202
1. **Virtual Environment**: Always activate `.venv` before running black, flake8, or pytest:
203+
201204
```bash
202205
source .venv/bin/activate
203206
```
204207

205208
2. **FastAPI Route Ordering**: Static routes MUST be defined before dynamic path parameters. Place `/players/statistics` before `/players/{player_id}`, or FastAPI will try to parse "statistics" as a player_id.
209+
206210
```python
207211
# CORRECT order:
208212
@api_router.get("/players/statistics") # Static route first
209213
@api_router.get("/players/{player_id}") # Dynamic route after
210214
```
211215

212216
3. **SQLAlchemy 2.0 Migration**: Use `select()` not `session.query()`. Example:
217+
213218
```python
214219
statement = select(Player).where(Player.id == player_id)
215220
result = await async_session.execute(statement)
@@ -220,6 +225,7 @@ GitHub Actions workflow (`.github/workflows/python-app.yml`):
220225
5. **Cache Invalidation**: Remember to call `await simple_memory_cache.clear(CACHE_KEY)` after mutations (POST/PUT/DELETE).
221226

222227
6. **Pydantic Model Conversion**: Use `player_model.model_dump()` to convert Pydantic to dict for SQLAlchemy:
228+
223229
```python
224230
player = Player(**player_model.model_dump())
225231
```
@@ -231,11 +237,13 @@ GitHub Actions workflow (`.github/workflows/python-app.yml`):
231237
## VS Code Configuration
232238

233239
Recommended extensions (`.vscode/extensions.json`):
240+
234241
- `ms-python.python`, `ms-python.flake8`, `ms-python.black-formatter`
235242
- `github.vscode-pull-request-github`, `github.vscode-github-actions`
236243
- `ms-azuretools.vscode-containers`, `sonarsource.sonarlint-vscode`
237244

238245
Settings (`.vscode/settings.json`):
246+
239247
- Auto-format on save with Black
240248
- Pytest enabled (not unittest)
241249
- Flake8 integration with matching CLI args
@@ -245,6 +253,6 @@ Settings (`.vscode/settings.json`):
245253

246254
- **Postman Collection**: `postman_collections/python-samples-fastapi-restful.postman_collection.json`
247255
- **Architecture Diagram**: `assets/images/structure.svg`
248-
- **FastAPI Docs**: https://fastapi.tiangolo.com/
249-
- **SQLAlchemy 2.0**: https://docs.sqlalchemy.org/en/20/
250-
- **Conventional Commits**: https://www.conventionalcommits.org/
256+
- **FastAPI Docs**: <https://fastapi.tiangolo.com/>
257+
- **SQLAlchemy 2.0**: <https://docs.sqlalchemy.org/en/20/>
258+
- **Conventional Commits**: <https://www.conventionalcommits.org/>

AGENTS.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# AGENTS.md
22

3-
> **⚡ Token Efficiency Note**: This file contains complete operational instructions (~2,500 tokens).
4-
> **Auto-loaded**: NO (load explicitly with `#file:AGENTS.md` when you need detailed procedures)
5-
> **When to load**: Complex workflows, troubleshooting, CI/CD setup, detailed architecture questions
3+
> **⚡ Token Efficiency Note**: This file contains complete operational instructions (~2,500 tokens).
4+
> **Auto-loaded**: NO (load explicitly with `#file:AGENTS.md` when you need detailed procedures)
5+
> **When to load**: Complex workflows, troubleshooting, CI/CD setup, detailed architecture questions
66
> **Related files**: See `#file:.github/copilot-instructions.md` for quick context (auto-loaded, ~500 tokens)
77
88
---
@@ -12,7 +12,7 @@
1212
```bash
1313
# Install all dependencies
1414
pip install -r requirements.txt
15-
pip install -r requirements-lint.txt
15+
pip install -r requirements-lint.txt
1616
pip install -r requirements-test.txt
1717

1818
# Start development server
@@ -62,11 +62,13 @@ black .
6262
```
6363

6464
**Pre-commit checklist**:
65+
6566
1. Run `flake8 .` - must pass with no errors
6667
2. Run `black --check .` - must pass with no formatting changes needed (or run `black .` to auto-fix)
6768
3. Run `pytest --cov=./ --cov-report=term` - all tests must pass
6869

6970
**Style rules** (enforced by Black + Flake8):
71+
7072
- Line length: 88 characters
7173
- Target: Python 3.13
7274
- Black configuration in `pyproject.toml`
@@ -123,11 +125,13 @@ curl http://localhost:9000/health
123125
**Trigger**: Push to `master` or PR to `master`
124126

125127
**Jobs**:
128+
126129
1. **Lint**: Commit messages (commitlint) → Flake8 → Black check
127130
2. **Test**: pytest with verbose output → coverage report generation
128131
3. **Coverage**: Upload to Codecov and Codacy (requires secrets)
129132

130133
**Local validation** (run this before pushing):
134+
131135
```bash
132136
# Matches CI exactly
133137
flake8 . && \
@@ -141,12 +145,14 @@ pytest --cov=./ --cov-report=xml --cov-report=term
141145
**Trigger**: Version tags in format `v{MAJOR}.{MINOR}.{PATCH}-{COACH}`
142146

143147
Example:
148+
144149
```bash
145150
git tag -a v1.0.0-ancelotti -m "Release 1.0.0 - Ancelotti"
146151
git push origin v1.0.0-ancelotti
147152
```
148153

149154
**Pipeline automatically**:
155+
150156
- Runs full test suite with coverage
151157
- Builds multi-stage Docker image
152158
- Pushes to GHCR with multiple tags (version, coach name, latest)
@@ -159,7 +165,7 @@ git push origin v1.0.0-ancelotti
159165

160166
**Structure**: Layered architecture (Routes → Services → Database)
161167

162-
```
168+
```text
163169
routes/ # FastAPI endpoints with caching
164170
├── player_route.py # CRUD endpoints
165171
└── health_route.py # Health check
@@ -183,6 +189,7 @@ tests/ # Test suite
183189
```
184190

185191
**Key patterns**:
192+
186193
- Dependency injection: `AsyncSession` via `Depends(generate_async_session)`
187194
- Async everywhere: SQLAlchemy async, aiocache, FastAPI async endpoints
188195
- Pydantic validation: Request/response with camelCase aliasing
@@ -192,12 +199,14 @@ tests/ # Test suite
192199
## Troubleshooting
193200

194201
### Port already in use
202+
195203
```bash
196204
# Kill process on port 9000
197205
lsof -ti:9000 | xargs kill -9
198206
```
199207

200208
### Module import errors
209+
201210
```bash
202211
# Ensure all dependencies installed
203212
pip install -r requirements.txt -r requirements-lint.txt -r requirements-test.txt
@@ -207,6 +216,7 @@ python --version # Should be 3.13.3
207216
```
208217

209218
### Database locked errors
219+
210220
```bash
211221
# Stop all running instances
212222
pkill -f uvicorn
@@ -216,6 +226,7 @@ rm storage/players.db
216226
```
217227

218228
### Docker issues
229+
219230
```bash
220231
# Clean slate
221232
docker compose down -v
@@ -226,12 +237,15 @@ docker compose up
226237
## Testing the API
227238

228239
### Using FastAPI Docs (Recommended)
229-
Open http://localhost:9000/docs - Interactive Swagger UI with "Try it out" buttons
240+
241+
Open <http://localhost:9000/docs> - Interactive Swagger UI with "Try it out" buttons
230242

231243
### Using Postman
244+
232245
Pre-configured collection available in `postman_collections/`
233246

234247
### Using curl
248+
235249
```bash
236250
# Health check
237251
curl http://localhost:9000/health

0 commit comments

Comments
 (0)