Skip to content

Commit 4a8fc6e

Browse files
authored
feat: add AI coding agent guidelines and enhance coding standards (#14)
Implements comprehensive guidelines for AI coding assistants to ensure consistent code quality and adherence to project standards. Changes: - Add AICodingAgent.md with mandatory workflow for AI assistants - Enhance CODING_STANDARDS.md with "Simplicity First" principle - Add "Code Smells and Anti-Patterns to Avoid" section - Reference existing documentation rather than duplicating content The guidelines emphasize reading all dev-notes documentation, running quality checks before commits, and following established conventions. Fixes #8
1 parent 5bc1a64 commit 4a8fc6e

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed

AICodingAgent.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# AI Coding Agent Guidelines
2+
3+
**Project:** Aletheia-Probe - Journal Assessment Tool
4+
**Purpose:** Explicit instructions for AI coding assistants
5+
6+
---
7+
8+
## 1. Before Making ANY Changes (MANDATORY)
9+
10+
Read and follow ALL standards in:
11+
12+
- **`dev-notes/CODING_STANDARDS.md`** - All coding conventions, patterns, code smells to avoid
13+
- **`dev-notes/LOGGING_USAGE.md`** - Dual-logger system usage
14+
- **`dev-notes/DEPENDENCIES.md`** - Dependencies information
15+
- **`dev-notes/NORMALIZED_DATABASE_DESIGN.md`** - Database schema (if working with data)
16+
- **`dev-notes/integration/*.md`** - Data sources (if working with backends)
17+
18+
Also:
19+
- Review recent commits to understand current patterns
20+
- Check open issues and PRs for ongoing work
21+
- Remember: This tool affects real academic decisions - quality is paramount
22+
23+
---
24+
25+
## 2. Pre-Commit Workflow (MANDATORY)
26+
27+
Before ANY commit, run:
28+
29+
```bash
30+
bash scripts/run-quality-checks.sh
31+
```
32+
33+
**Requirements:**
34+
- ALL checks MUST pass
35+
- Do NOT commit failing code
36+
- Do NOT bypass checks
37+
- Do NOT use `type: ignore` without justification
38+
39+
---
40+
41+
## 3. Commit and PR Format
42+
43+
### Commits
44+
45+
Follow conventional commits (see `git log` for examples):
46+
47+
```
48+
<type>: <subject ≤72 chars>
49+
50+
<WHY, not just WHAT>
51+
```
52+
53+
Types: `feat:`, `fix:`, `docs:`, `test:`, `refactor:`, `chore:`
54+
55+
### Pull Requests
56+
57+
Include:
58+
- **Summary**: What does this do?
59+
- **Motivation**: Why is this needed?
60+
- **Testing**: How was this tested?
61+
- **Checklist**: Quality checks pass, tests added, docs updated
62+
63+
---
64+
65+
## Summary Checklist
66+
67+
**DO:**
68+
1. Read all `dev-notes/` documentation first
69+
2. Run `bash scripts/run-quality-checks.sh` before committing
70+
3. Follow CODING_STANDARDS.md (simplicity, f-strings, type hints, enums, etc.)
71+
4. Follow LOGGING_USAGE.md (dual-logger system)
72+
5. Write tests for new functionality
73+
6. Add docstrings (Google style)
74+
7. Write clear commit messages explaining WHY
75+
76+
**DO NOT:**
77+
1. Commit code that fails quality checks
78+
2. Modify code you don't understand
79+
3. Introduce code smells (see CODING_STANDARDS.md)
80+
4. Add unnecessary dependencies
81+
5. Use backwards-compatibility hacks
82+
83+
**When uncertain, ask for clarification.**

dev-notes/CODING_STANDARDS.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This project adheres to the following Python Enhancement Proposals (PEPs) and co
2323

2424
## Table of Contents
2525

26+
0. [Core Principle: Simplicity First](#core-principle-simplicity-first)
2627
1. [Python Version and Tools](#python-version-and-tools)
2728
2. [Project-Specific Conventions](#project-specific-conventions)
2829
3. [Domain-Specific Patterns](#domain-specific-patterns)
@@ -32,6 +33,30 @@ This project adheres to the following Python Enhancement Proposals (PEPs) and co
3233

3334
---
3435

36+
## Core Principle: Simplicity First
37+
38+
**MANDATORY**: Simple solutions are ALWAYS preferred over complex ones.
39+
40+
- Choose the most straightforward implementation that solves the problem
41+
- Avoid over-engineering or premature optimization
42+
- Only add complexity when absolutely necessary and well-justified
43+
- Refactor complex code to be simpler when possible
44+
- If a simple solution works, use it
45+
46+
**Example:**
47+
```python
48+
# GOOD - Simple and clear
49+
def is_empty(text: str) -> bool:
50+
return not text.strip()
51+
52+
# BAD - Unnecessarily complex (unless you need regex for specific validation)
53+
def is_empty(text: str) -> bool:
54+
import re
55+
return bool(re.match(r"^\s*$", text))
56+
```
57+
58+
---
59+
3560
## Python Version and Tools
3661

3762
### Target Environment
@@ -354,16 +379,44 @@ class TestJournalAssessment:
354379

355380
---
356381

382+
## Code Smells and Anti-Patterns to Avoid
383+
384+
### Common Code Smells
385+
386+
Do NOT introduce these code quality issues:
387+
388+
- **Code Duplication** - Extract common code into reusable functions or classes
389+
- **Magic Numbers/Strings** - Use named constants or enums (see Project-Specific Conventions above)
390+
- **Long Functions** - Break down functions longer than 50 lines into smaller, focused functions
391+
- **Deep Nesting** - Use guard clauses and early returns to flatten conditionals
392+
- **Mutable Default Arguments** - Use `None` as default and initialize inside the function
393+
- **Bare Exceptions** - Catch specific exception types instead of generic `except:`
394+
- **God Objects** - Keep classes focused and cohesive with single responsibility
395+
396+
### Development Practices to Avoid
397+
398+
- **Skipping Quality Checks** - Always run quality checks before committing (see `scripts/run-quality-checks.sh`)
399+
- **Modifying Unknown Code** - Don't make changes in areas you don't fully understand
400+
- **Adding Unnecessary Dependencies** - Use standard library when possible; justify new dependencies
401+
- **Backwards-Compatibility Hacks** - Delete unused code cleanly; avoid underscore prefixes or commented-out code
402+
- **Using `type: ignore` Without Justification** - Fix type issues properly or provide clear reasoning
403+
404+
**When uncertain about any change, ask for clarification before proceeding.**
405+
406+
---
407+
357408
## Summary
358409

359410
This coding standards document references established Python best practices (PEPs and community guidelines) and defines project-specific conventions for:
360411

412+
- **Simplicity First**: Prefer simple solutions over complex ones
361413
- **String Formatting**: Exclusive use of f-strings
362414
- **Type Safety**: Comprehensive type hints with modern syntax
363415
- **Domain Patterns**: Custom exceptions, retry decorators, async patterns
364416
- **Security**: Input validation, SQL injection prevention, path traversal protection
365417
- **Database**: Parameterized queries and batch operations
366418
- **Testing**: Descriptive naming and fixture organization
367419
- **Quality**: Automated tooling (Black, isort, mypy, ruff, pytest)
420+
- **Code Quality**: Avoid code smells and anti-patterns
368421

369422
All new code must follow these guidelines. When modifying existing code, bring it up to these standards where practical.

0 commit comments

Comments
 (0)