Skip to content

Commit ba0fd66

Browse files
committed
add CLAUDE.md
1 parent 4a5e770 commit ba0fd66

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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-based Reddit moderation log publisher that automatically scrapes moderation actions from a subreddit and publishes them to a wiki page. The application uses PRAW (Python Reddit API Wrapper) and SQLite for data persistence.
8+
9+
## Core Architecture
10+
11+
- **Main application**: `modlog_wiki_publisher.py` - Single-file application containing all core functionality
12+
- **Database layer**: `ModlogDatabase` class handles SQLite operations for deduplication and retention
13+
- **Configuration**: JSON-based config with CLI override support
14+
- **Logging**: Per-subreddit log files in `logs/` directory with rotating handlers
15+
- **Authentication**: Reddit OAuth2 script-type app authentication
16+
17+
## Development Commands
18+
19+
### Setup and Dependencies
20+
```bash
21+
# Install dependencies
22+
pip install praw
23+
24+
# Copy template config (required for first run)
25+
cp config_template.json config.json
26+
```
27+
28+
### Running the Application
29+
```bash
30+
# Test connection and configuration
31+
python modlog_wiki_publisher.py --test
32+
33+
# Single run
34+
python modlog_wiki_publisher.py --source-subreddit SUBREDDIT_NAME
35+
36+
# Continuous daemon mode
37+
python modlog_wiki_publisher.py --source-subreddit SUBREDDIT_NAME --continuous
38+
39+
# Debug authentication issues
40+
python debug_auth.py
41+
```
42+
43+
### Database Operations
44+
```bash
45+
# View recent processed actions
46+
sqlite3 modlog.db "SELECT * FROM processed_actions ORDER BY created_at DESC LIMIT 10;"
47+
48+
# Manual cleanup of old entries
49+
sqlite3 modlog.db "DELETE FROM processed_actions WHERE created_at < date('now', '-30 days');"
50+
```
51+
52+
## Key Configuration
53+
54+
The application supports both JSON config files and CLI arguments (CLI overrides JSON):
55+
56+
- `--source-subreddit`: Target subreddit for reading/writing logs
57+
- `--wiki-page`: Wiki page name (default: "modlog")
58+
- `--retention-days`: Database cleanup period (default: 30)
59+
- `--batch-size`: Entries fetched per run (default: 100)
60+
- `--interval`: Seconds between updates in daemon mode (default: 300)
61+
- `--debug`: Enable verbose logging
62+
63+
## Authentication Requirements
64+
65+
The bot account needs:
66+
- Moderator status on the target subreddit
67+
- Wiki edit permissions for the specified wiki page
68+
- Reddit app credentials (script type, not web app)
69+
70+
## File Structure
71+
72+
- `modlog_wiki_publisher.py`: Main application
73+
- `debug_auth.py`: Authentication debugging utility
74+
- `config.json`: Runtime configuration (created from template)
75+
- `modlog.db`: SQLite database for processed actions
76+
- `logs/`: Per-subreddit log files
77+
- `requirements.txt`: Python dependencies
78+
79+
## Testing
80+
81+
Use `--test` flag to verify configuration and Reddit API connectivity without making changes.
82+
83+
## Common Issues
84+
85+
- 401 errors: Check app type is "script" and verify client_id/client_secret
86+
- Wiki permission denied: Ensure bot has moderator or wiki contributor access
87+
- Rate limiting: Increase `--interval` and/or reduce `--batch-size`

0 commit comments

Comments
 (0)