# Context Loading Reference

> **Scope**: Subreddit data directory structure, file purposes, setup flow, and context loading sequence. Does NOT cover the classification prompt itself or script command flags.
> **Version range**: All toolkit versions using `reddit-data/{subreddit}/` directories
> **Generated**: 2026-04-16

---

## Overview

Before classifying any items, the skill loads subreddit-specific context from `reddit-data/{subreddit}/`. This context enables accurate classification by providing rules, historical patterns, community norms, and repeat offender data. The setup command bootstraps this directory automatically; moderators then customize the human-written files.

---

## Directory Structure

```
reddit-data/{subreddit}/
  rules.md                  # Auto-generated by setup
  mod-log-summary.md        # Auto-generated by setup
  moderator-notes.md        # Human-written
  config.json               # Human-edited
  repeat-offenders.json     # Auto-generated by setup
```

---

## File Purposes

| File | Source | Purpose |
|------|--------|---------|
| `rules.md` | Auto-generated by `setup` | Sidebar rules + formal rules combined |
| `mod-log-summary.md` | Auto-generated by `setup` | Historical mod action patterns and frequencies |
| `moderator-notes.md` | Human-written | Community context, known spam patterns, cultural norms |
| `config.json` | Human-edited | Per-subreddit confidence thresholds and overrides |
| `repeat-offenders.json` | Auto-generated by `setup` | Authors with multiple prior removals |

---

## Setup Flow

Bootstrap a subreddit before first use:

```bash
python3 skills/content/reddit-moderate/scripts/reddit-mod.py setup
```

This creates `reddit-data/{subreddit}/` with auto-generated rules, mod log summary, repeat offender list, and template files.

After setup, create or edit `moderator-notes.md` to add community-specific context that automated tools cannot extract (known spam patterns, cultural norms, which accounts are known bad actors).

---

## Context Loading Sequence

1. Load all files from `reddit-data/{subreddit}/`
2. If any file is missing, proceed without it. Classification still works with partial context, just at lower confidence.
3. Pass loaded context into classification prompt template placeholders (rules, moderator_notes, mod_log_summary)
4. Repeat offender data is checked per-item, not loaded as bulk context

---

## Credentials

Required env vars (add to `~/.env`, `chmod 600`):

```bash
REDDIT_CLIENT_ID="your_client_id"
REDDIT_CLIENT_SECRET="your_secret"
REDDIT_USERNAME="your_username"
REDDIT_PASSWORD="your_password"
REDDIT_SUBREDDIT="your_subreddit"
```

Credentials are loaded from `~/.env` via python-dotenv. Load them from `~/.env` via python-dotenv only.

```bash
pip install praw python-dotenv
```

---

## Dry-Run Default

Classification defaults to **dry-run mode**. In dry-run:

- Show what actions WOULD be taken for each item
- Display classification, confidence, and reasoning
- Wait for confirmation before executing any mod actions
- The user must pass `--execute` to enable live actions

This prevents surprises when first enabling classification or onboarding a new subreddit.
