|
| 1 | +# GitHub Copilot Instructions for RedditModLog |
| 2 | + |
| 3 | +## Project Context |
| 4 | +This is a Python-based Reddit moderation log publisher that scrapes mod actions and publishes them to wiki pages. Focus on security, reliability, and maintainability. |
| 5 | + |
| 6 | +## Code Style & Standards |
| 7 | +- **No comments on self-documenting code** - avoid obvious comments |
| 8 | +- **Use conventional commits** for all changes |
| 9 | +- **Environment variables** for all configuration (Docker-ready) |
| 10 | +- **Security first**: Never expose moderator identities, always anonymize |
| 11 | +- **Error handling**: Graceful degradation, comprehensive logging |
| 12 | + |
| 13 | +## Key Architecture Patterns |
| 14 | +- **Single-file application**: Keep core logic in `modlog_wiki_publisher.py` |
| 15 | +- **SQLite database**: Multi-subreddit support with proper data separation |
| 16 | +- **Configuration hierarchy**: CLI args → env vars → config file |
| 17 | +- **Action validation**: Use `VALID_MODLOG_ACTIONS` constant for all validation |
| 18 | + |
| 19 | +## Critical Security Rules |
| 20 | +- **NEVER** allow `anonymize_moderators=false` in production |
| 21 | +- **NEVER** expose actual moderator usernames in public wikis |
| 22 | +- **ALWAYS** validate Reddit API inputs before processing |
| 23 | +- **ALWAYS** escape markdown content (pipe characters) for table safety |
| 24 | + |
| 25 | +## Docker & Deployment |
| 26 | +- **Non-root user**: All containers must run as non-root for security |
| 27 | +- **Multi-platform**: Support linux/amd64 and linux/arm64 architectures |
| 28 | +- **Health checks**: Include SQLite connectivity validation |
| 29 | +- **Volume mounts**: Persist data and logs outside containers |
| 30 | +- **Environment variables**: Full configuration via env vars |
| 31 | + |
| 32 | +## Reddit API Best Practices |
| 33 | +- **Rate limiting**: Respect Reddit's API limits with exponential backoff |
| 34 | +- **Authentication**: Use script-type apps, not web apps |
| 35 | +- **Error handling**: Graceful handling of 401, 403, 429 errors |
| 36 | +- **Content linking**: Link to actual posts/comments, never user profiles |
| 37 | + |
| 38 | +## Database Schema |
| 39 | +- **Multi-subreddit**: Include subreddit column in all relevant tables |
| 40 | +- **Action deduplication**: Use action_id as primary key |
| 41 | +- **Content IDs**: Extract from permalinks for accurate tracking |
| 42 | +- **Schema versioning**: Implement migrations for database changes |
| 43 | + |
| 44 | +## Testing & Quality |
| 45 | +- **Pre-commit hooks**: Black, flake8, isort, mypy, security scanning |
| 46 | +- **Validation**: Strict input validation with clear error messages |
| 47 | +- **Environment testing**: `--test` flag for configuration validation |
| 48 | +- **CI/CD**: Multi-platform builds with manual approval for main branch |
| 49 | + |
| 50 | +## Documentation Standards |
| 51 | +- **CLAUDE.md**: Primary developer documentation with examples |
| 52 | +- **README.md**: User-facing documentation with setup instructions |
| 53 | +- **Environment variables**: Document all config options with examples |
| 54 | +- **Security warnings**: Highlight privacy and security considerations |
| 55 | + |
| 56 | +## Forbidden Patterns |
| 57 | +- ❌ Hardcoded credentials or configuration |
| 58 | +- ❌ User profile links in public wikis |
| 59 | +- ❌ Unescaped markdown content in tables |
| 60 | +- ❌ Missing error handling for Reddit API calls |
| 61 | +- ❌ Exposing real moderator names in production |
| 62 | + |
| 63 | +## Preferred Libraries |
| 64 | +- **PRAW**: Reddit API wrapper (already in use) |
| 65 | +- **SQLite3**: Database (already in use) |
| 66 | +- **Apprise**: Future notification support |
| 67 | +- **Standard library**: Prefer built-in modules when possible |
| 68 | + |
| 69 | +## Git Workflow |
| 70 | +- **Feature branches**: Use descriptive branch names |
| 71 | +- **Pull requests**: Required for main branch changes |
| 72 | +- **Manual approval**: Never auto-merge to main branch |
| 73 | +- **Conventional commits**: Use standard commit message format |
| 74 | + |
| 75 | +When suggesting code improvements, prioritize security, reliability, and maintainability over clever optimizations. |
0 commit comments