notque/vexjoy-agent / skills/content/content
content
UnverifiedContent operations: editorial calendar, marketing, publishing, social media management.
scripts/reddit-moderate/reddit-automod-cron.sh
View on GitHub#!/usr/bin/env bash
# Reddit auto-moderation via Claude Code headless mode.
# Designed for cron: fetches modqueue, classifies, auto-actions high-confidence items.
#
# Usage:
# # Dry run (classify but don't act)
# ./skills/content/content/scripts/reddit-moderate/reddit-automod-cron.sh
#
# # Live mode (execute mod actions)
# ./skills/content/content/scripts/reddit-moderate/reddit-automod-cron.sh --execute
#
# Cron example (twice daily at 8am and 8pm):
# 0 8,20 * * * /home/feedgen/vexjoy-agent/skills/content/content/scripts/reddit-moderate/reddit-automod-cron.sh --execute >> /home/feedgen/vexjoy-agent/reddit-data/sap/cron-log/cron.log 2>&1
# Ensure claude CLI and venv python are in PATH (cron doesn't inherit user PATH)
# Venv python first so `python3` resolves to the venv with praw installed
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." && pwd)"
export PATH="$REPO_ROOT/venv/bin:$HOME/.local/bin:$HOME/.nvm/versions/node/$(ls $HOME/.nvm/versions/node/ 2>/dev/null | tail -1)/bin:$PATH"
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(cd "$SCRIPT_DIR/../../.." && pwd)"
SUBREDDIT="${REDDIT_SUBREDDIT:-sap}"
LOG_DIR="$REPO_DIR/reddit-data/$SUBREDDIT/cron-log"
LOCKFILE="/tmp/reddit-automod-$SUBREDDIT.lock"
SINCE_MINUTES="${SINCE_MINUTES:-720}"
MAX_BUDGET="${MAX_BUDGET_USD:-2.00}"
EXECUTE=""
# Parse args
for arg in "$@"; do
case "$arg" in
--execute) EXECUTE="--execute" ;;
*) echo "Unknown arg: $arg" >&2; exit 1 ;;
esac
done
# Create log directory
mkdir -p "$LOG_DIR"
# Prevent concurrent runs
exec 9>"$LOCKFILE"
if ! flock -n 9; then
echo "$(date -Iseconds) SKIP: another instance is running" >> "$LOG_DIR/cron.log"
exit 0
fi
TIMESTAMP="$(date -Iseconds)"
echo "=== Reddit automod run: $TIMESTAMP ==="
MODE="dry-run"
[ -n "$EXECUTE" ] && MODE="live"
echo "Mode: $MODE | Subreddit: r/$SUBREDDIT | Since: ${SINCE_MINUTES}m | Budget: \$${MAX_BUDGET}"
PROMPT="You are running automated Reddit moderation for r/$SUBREDDIT.
Step 1: Run this command to fetch and build classification prompts:
python3 skills/content/content/scripts/reddit-moderate/reddit-mod.py queue --auto --since-minutes $SINCE_MINUTES --json | python3 skills/content/content/scripts/reddit-moderate/reddit-mod.py classify
Step 2: If the queue is empty (count: 0), output 'Queue empty, no action needed.' and stop.
Step 3: For each item in the output, read the 'prompt' field and classify it as one of:
FALSE_REPORT, VALID_REPORT, MASS_REPORT_ABUSE, SPAM, BAN_RECOMMENDED, NEEDS_HUMAN_REVIEW
Assign confidence 0-100 and one-sentence reasoning.
Step 4: Apply actions for items meeting confidence thresholds:
- FALSE_REPORT/MASS_REPORT_ABUSE >= 95%: python3 skills/content/content/scripts/reddit-moderate/reddit-mod.py approve --id {id}
- SPAM >= 90%: python3 skills/content/content/scripts/reddit-moderate/reddit-mod.py remove --id {id} --reason '{reason}' --spam
- VALID_REPORT >= 90%: python3 skills/content/content/scripts/reddit-moderate/reddit-mod.py remove --id {id} --reason '{reason}'
- BAN_RECOMMENDED: ALWAYS skip (never auto-ban)
- Below threshold: skip (leave for human review)
Step 5: Output a summary table of all items and actions taken.
IMPORTANT: When in doubt, SKIP. False negatives are better than false positives.
IMPORTANT: Never ban users. Never lock threads. These require human review."
cd "$REPO_DIR"
if [ -z "$EXECUTE" ]; then
# Dry run: replace action commands with echo
PROMPT="$PROMPT
DRY RUN MODE: Do NOT execute any approve/remove commands. Instead, show what you WOULD do for each item."
fi
claude -p "$PROMPT" \
--output-format text \
--permission-mode auto \
--max-budget-usd "$MAX_BUDGET" \
--no-session-persistence \
--model opus \
2>&1 | tee "$LOG_DIR/run-$(date +%Y%m%d-%H%M%S).log"
EXIT_CODE=${PIPESTATUS[0]}
echo ""
echo "=== Run complete: $(date -Iseconds) | exit: $EXIT_CODE ==="
# Release lock
exec 9>&-
rm -f "$LOCKFILE"
exit $EXIT_CODE
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |