Skip to content

Commit 2822443

Browse files
committed
fix: resolve lint errors in .claude context files
1 parent 85038b7 commit 2822443

File tree

4 files changed

+64
-24
lines changed

4 files changed

+64
-24
lines changed

.claude/agents/codebase-agent.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ You are the Codebase Agent for the Ambient Code Reference Repository. You assist
2828
Convert well-defined GitHub issues into pull requests:
2929

3030
**Process**:
31+
3132
1. Read issue description and acceptance criteria
3233
2. Review relevant code in `.claude/context/` and codebase
3334
3. Create implementation plan
@@ -39,6 +40,7 @@ Convert well-defined GitHub issues into pull requests:
3940
9. Push and create PR with detailed description
4041

4142
**Requirements**:
43+
4244
- Issue must have clear acceptance criteria
4345
- All tests must pass
4446
- All linters must pass
@@ -49,13 +51,15 @@ Convert well-defined GitHub issues into pull requests:
4951
Provide actionable feedback on pull requests:
5052

5153
**Review Focus**:
54+
5255
- **Bugs**: Logic errors, edge cases, error handling
5356
- **Security**: Input validation, OWASP Top 10 vulnerabilities
5457
- **Performance**: Inefficient algorithms, unnecessary operations
5558
- **Style**: Adherence to black/isort/ruff standards
5659
- **Testing**: Coverage, missing test cases
5760

5861
**Feedback Guidelines**:
62+
5963
- Be specific and actionable
6064
- Provide code examples for fixes
6165
- Explain "why" not just "what"
@@ -67,13 +71,15 @@ Provide actionable feedback on pull requests:
6771
Maintain codebase health:
6872

6973
**Tasks**:
74+
7075
- Dependency updates (via Dependabot or manual)
7176
- Linting fixes (black, isort, ruff)
7277
- Documentation updates (keep in sync with code)
7378
- Test coverage improvements
7479
- Security vulnerability patches
7580

7681
**Approach**:
82+
7783
- Create separate PRs for each type of change
7884
- Include clear rationale in PR description
7985
- Ensure all tests pass before creating PR
@@ -114,9 +120,10 @@ Follow CLAUDE.md strictly:
114120

115121
### Level 2 (Future): Auto-Merge Low-Risk
116122

117-
*Requires explicit configuration*
123+
> Note: Requires explicit configuration
118124
119125
Auto-merge conditions:
126+
120127
- Dependency updates (patch versions only)
121128
- Linting fixes (no logic changes)
122129
- Documentation updates (no code changes)
@@ -130,6 +137,7 @@ Use modular context files in `.claude/context/`:
130137
### architecture.md
131138

132139
Layered architecture patterns:
140+
133141
- API Layer: FastAPI routes, request/response models
134142
- Service Layer: Business logic, data manipulation
135143
- Model Layer: Pydantic models, validation
@@ -138,6 +146,7 @@ Layered architecture patterns:
138146
### security-standards.md
139147

140148
Security patterns:
149+
141150
- Input validation at API boundary (Pydantic)
142151
- Sanitization in `app/core/security.py`
143152
- Environment variables for secrets (.env files)
@@ -146,6 +155,7 @@ Security patterns:
146155
### testing-patterns.md
147156

148157
Testing strategies:
158+
149159
- Unit tests: Service layer isolation, Arrange-Act-Assert
150160
- Integration tests: API endpoints, TestClient
151161
- E2E tests: Full workflows (outline only)
@@ -158,6 +168,7 @@ Testing strategies:
158168
**Issue**: "Add pagination support to Items endpoint"
159169

160170
**Process**:
171+
161172
1. Read issue and understand requirements
162173
2. Review `app/api/v1/items.py` and `app/services/item_service.py`
163174
3. Create plan:
@@ -175,6 +186,7 @@ Testing strategies:
175186
**PR**: "Add caching to item lookups"
176187

177188
**Review**:
189+
178190
```markdown
179191
**Security** 🔴
180192
- Line 45: Cache keys should be sanitized to prevent cache poisoning
@@ -188,25 +200,31 @@ Testing strategies:
188200
```
189201

190202
**Performance** 🟡
203+
191204
- Line 78: Consider using TTL to prevent cache bloat
192205

193206
**Testing** 🟡
207+
194208
- Missing test case for cache invalidation on update
195209

196210
**Positive**
211+
197212
- Good use of context manager for cache cleanup
198-
```
213+
214+
```text
199215
200216
### Example 3: Proactive Maintenance
201217
202218
**Task**: Update Pydantic from 2.5.0 to 2.6.0
203219
204220
**Process**:
221+
205222
1. Update `requirements.txt`
206223
2. Run tests to verify compatibility
207224
3. Update any deprecated API usage
208225
4. Create PR:
209-
```
226+
227+
```text
210228
Update Pydantic to 2.6.0
211229
212230
- Update requirements.txt
@@ -235,6 +253,7 @@ When errors occur:
235253
## Anti-Patterns
236254

237255
**NEVER**:
256+
238257
- ❌ Commit without running linters and tests
239258
- ❌ Push to main without PR
240259
- ❌ Make assumptions about ambiguous requirements
@@ -246,6 +265,7 @@ When errors occur:
246265
## Success Criteria
247266

248267
A successful CBA operation:
268+
249269
- ✅ All linters pass (black, isort, ruff)
250270
- ✅ All tests pass (80%+ coverage)
251271
- ✅ Security scans pass (bandit, safety)

.claude/context/architecture.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The application follows a strict layered architecture with clear separation of concerns:
66

7-
```
7+
```text
88
┌─────────────────────────────────┐
99
│ API Layer (FastAPI) │ HTTP routes, request/response models
1010
├─────────────────────────────────┤
@@ -14,7 +14,7 @@ The application follows a strict layered architecture with clear separation of c
1414
├─────────────────────────────────┤
1515
│ Core Layer (Utilities) │ Config, security, logging
1616
└─────────────────────────────────┘
17-
```
17+
```text
1818
1919
## Layer Responsibilities
2020
@@ -23,17 +23,20 @@ The application follows a strict layered architecture with clear separation of c
2323
**Purpose**: Handle HTTP concerns
2424
2525
**Files**:
26+
2627
- `health.py` - Health check endpoints
2728
- `v1/items.py` - Resource endpoints
2829
2930
**Responsibilities**:
31+
3032
- Route definitions
3133
- Request/response serialization
3234
- HTTP status codes
3335
- Error responses
3436
- OpenAPI documentation
3537
3638
**Never in API Layer**:
39+
3740
- Business logic
3841
- Database/storage operations
3942
- Complex validation
@@ -43,15 +46,18 @@ The application follows a strict layered architecture with clear separation of c
4346
**Purpose**: Implement business logic
4447
4548
**Files**:
49+
4650
- `item_service.py` - Item business logic
4751
4852
**Responsibilities**:
53+
4954
- CRUD operations
5055
- Business rules
5156
- Data manipulation
5257
- Transaction coordination
5358
5459
**Never in Service Layer**:
60+
5561
- HTTP concerns (status codes, headers)
5662
- Request/response serialization
5763
@@ -60,15 +66,18 @@ The application follows a strict layered architecture with clear separation of c
6066
**Purpose**: Data validation and representation
6167
6268
**Files**:
69+
6370
- `item.py` - Item models (ItemBase, ItemCreate, ItemUpdate, Item)
6471
6572
**Responsibilities**:
73+
6674
- Field validation (Pydantic validators)
6775
- Type annotations
6876
- Serialization rules
6977
- Sanitization (via validators)
7078
7179
**Never in Model Layer**:
80+
7281
- Business logic
7382
- HTTP concerns
7483
@@ -77,27 +86,29 @@ The application follows a strict layered architecture with clear separation of c
7786
**Purpose**: Cross-cutting concerns
7887
7988
**Files**:
89+
8090
- `config.py` - Application settings
8191
- `security.py` - Sanitization, validation utilities
8292
- `logging.py` - Structured logging
8393
8494
**Responsibilities**:
95+
8596
- Configuration management
8697
- Security utilities
8798
- Logging setup
8899
- Shared utilities
89100
90101
## Dependency Flow
91102
92-
```
103+
```text
93104
API Layer
94105
↓ (depends on)
95106
Service Layer
96107
↓ (depends on)
97108
Model Layer
98109
↓ (depends on)
99110
Core Layer
100-
```
111+
```text
101112
102113
**Rule**: Higher layers can depend on lower layers, but not vice versa.
103114
@@ -124,7 +135,7 @@ def create_item(self, data: ItemCreate) -> Item:
124135
# Store
125136
self._items[item.id] = item
126137
return item
127-
```
138+
```text
128139
129140
## Common Patterns
130141
@@ -138,7 +149,7 @@ item_service = ItemService()
138149
139150
# app/api/v1/items.py
140151
from app.services.item_service import item_service
141-
```
152+
```text
142153
143154
### Pydantic Validators
144155
@@ -149,7 +160,7 @@ Sanitization in model validators:
149160
@classmethod
150161
def sanitize_name(cls, v: str) -> str:
151162
return sanitize_string(v, max_length=200)
152-
```
163+
```text
153164
154165
### Error Handling
155166
@@ -167,7 +178,7 @@ def create_item(data: ItemCreate) -> Item:
167178
return item_service.create_item(data)
168179
except ValueError as e:
169180
raise HTTPException(status_code=409, detail=str(e))
170-
```
181+
```text
171182
172183
## Testing Architecture
173184

.claude/context/security-standards.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Principle: Validate at Boundaries
66

77
**Validate external input at API boundary only**:
8+
89
- Use Pydantic models for all request payloads
910
- Validation happens automatically in route parameters
1011
- Trust internal code - don't re-validate
@@ -42,11 +43,13 @@ All sanitization functions in `app/core/security.py`.
4243
### Functions
4344

4445
**`sanitize_string(value, max_length)`**:
46+
4547
- Remove control characters
4648
- Trim whitespace
4749
- Enforce length limits
4850

4951
**`validate_slug(value)`**:
52+
5053
- Ensure URL-safe (lowercase, numbers, hyphens only)
5154
- No leading/trailing hyphens
5255
- No consecutive hyphens
@@ -112,12 +115,14 @@ podman run -e SECRET_KEY=xxx myapp
112115
### Input Validation Rules
113116

114117
**String fields**:
118+
115119
- Max length limits
116120
- Character allowlist (for slugs)
117121
- Trim whitespace
118122
- Remove control characters
119123

120124
**Numeric fields**:
125+
121126
- Min/max validation
122127
- Type checking (Pydantic automatic)
123128

@@ -175,20 +180,23 @@ safety check
175180
### CI Integration
176181

177182
Both run in `.github/workflows/security.yml`:
183+
178184
- Weekly schedule
179185
- On push/PR
180186
- Fail build on HIGH severity
181187

182188
## Common Mistakes
183189

184190
**DON'T**:
191+
185192
- ❌ Validate the same data multiple times
186193
- ❌ Sanitize in both model and service layer
187194
- ❌ Trust user input without validation
188195
- ❌ Commit `.env` files
189196
- ❌ Hardcode secrets
190197

191198
**DO**:
199+
192200
- ✅ Validate once at API boundary
193201
- ✅ Use Pydantic validators
194202
- ✅ Keep secrets in environment

0 commit comments

Comments
 (0)