Openclaw Daily Ops

v1.0.0

Daily cost reporting + session hygiene for OpenClaw deployments. Tracks per-session API spend, shows 7-day trend, and wipes zombie sessions >24h old to preve...

0· 171·1 current·1 all-time
by云龙@zylcold

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for zylcold/openclaw-daily-ops.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "Openclaw Daily Ops" (zylcold/openclaw-daily-ops) from ClawHub.
Skill page: https://clawhub.ai/zylcold/openclaw-daily-ops
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install openclaw-daily-ops

ClawHub CLI

Package manager switcher

npx clawhub@latest install openclaw-daily-ops
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description match the included scripts and README. The skill only needs access to OpenClaw session files and a Discord webhook (provided in config.json) to generate reports and reset stale sessions; nothing requested or installed is unrelated to that purpose.
Instruction Scope
SKILL.md and the scripts are explicit about reading sessions.json/sessions_dir and truncating session JSONL files older than the configured threshold. This is destructive by design (it intentionally truncates files) — the instructions limit action to the configured sessions_dir and workspace_dir but you should confirm those paths before running. The only external endpoint used is the Discord webhook you configure.
Install Mechanism
No install spec or remote downloads; the skill is pure Python scripts and docs, so nothing is written to disk beyond the files shipped and the logs the scripts create. Risk from installation is low.
Credentials
No required environment variables or unrelated credentials. The only secret-like value is the Discord webhook supplied in config.json, which is appropriate for posting reports. The scripts write logs under the configured workspace_dir.
Persistence & Privilege
The skill is not always-enabled and does not request elevated platform privileges. It does not modify other skills or system-wide agent settings. It is intended to be scheduled via cron (user-controlled).
Assessment
This skill appears to do what it says, but before enabling it: 1) Review and edit config.json so sessions_dir and workspace_dir point only to your OpenClaw session paths (not broader system directories). 2) Test both scripts with --dry-run to verify reported sessions and the zombie summary. 3) Back up your session files (or run the zombie killer in dry-run) before allowing it to truncate files. 4) Use a private Discord channel/webhook and avoid exposing the webhook URL; rotate the webhook if it ever leaks. 5) When scheduling with cron, run under the intended user account (not root) to limit file-scope. If any behavior seems unexpected, inspect the scripts again — they are small and readable.

Like a lobster shell, security has layers — review code before you run it.

latestvk973nbh75zqpt0nz0kmzxhd2wd833yan
171downloads
0stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

OpenClaw Daily Ops

Two tasks in one nightly cron: know what you spent, kill what's dead.

  • Parses all OpenClaw session JSONL files → computes today's API cost per session
  • Posts a clean cost report to Discord with 7-day trend
  • Wipes sessions older than 24h with >1MB context (zombie killer)
  • Logs everything to state/cost-log.json and state/session-reset-log.json

Zero AI credits spent — pure Python + one Discord message.


Setup

1. Configure

Copy config.example.json to config.json and fill in your values:

cp config.example.json config.json

Edit config.json:

{
  "sessions_dir": "~/.openclaw/agents/main/sessions",
  "workspace_dir": "~/.openclaw/workspace",
  "discord_webhook": "https://discord.com/api/webhooks/YOUR/WEBHOOK",
  "discord_user_id": "YOUR_DISCORD_USER_ID",
  "channel_names": {
    "channel:YOUR_CHANNEL_ID": "#your-channel-name"
  },
  "zombie_min_age_hours": 24,
  "zombie_min_size_mb": 1,
  "alert_high_cost": 50,
  "alert_low_cost": 10,
  "timezone_offset_hours": -6
}

How to get a Discord webhook:

  1. Go to your Discord channel → Edit Channel → Integrations → Webhooks → New Webhook
  2. Copy the webhook URL

How to get your Discord user ID:

  1. Enable Developer Mode in Discord (Settings → Advanced → Developer Mode)
  2. Right-click your username → Copy User ID

Channel names (optional): Map your OpenClaw channel session keys to human-readable names for the report. Find session keys in ~/.openclaw/agents/main/sessions/sessions.json.

2. Test it

python3 scripts/cost_report.py --config config.json --dry-run

This prints the report without posting to Discord or writing logs.

3. Set up the cron

Add a nightly OpenClaw cron job. In your OpenClaw config or via CLI:

Schedule: 0 21 * * * (9 PM daily — adjust to your timezone)
Model: haiku (cost report is simple, no need for a heavy model)
Payload: Read /path/to/openclaw-daily-ops/SKILL.md and follow it exactly.

Or run it as a system cron:

# Add to crontab -e
0 21 * * * python3 /path/to/openclaw-daily-ops/scripts/cost_report.py --config /path/to/config.json >> /path/to/cost_report.log 2>&1

What the Report Looks Like

📊 Daily Cost Report — Mar 9, 2026

💰 Total: $4.21 · 8.3M tokens

By Session:
🔴 #general — $2.45 · 4.1M tok
🟡 #posting — $1.32 · 2.8M tok
🟢 heartbeat — $0.44 · 1.4M tok

7-day trend: $12 → $8 → $6 → $5 → $4 → $4 → $4

✅ UNDER BUDGET
🔄 Reset 2 stale sessions (3.2MB freed)

Color coding:

  • 🔴 session cost > $5
  • 🟡 session cost $1–$5
  • 🟢 session cost < $1

Skill Steps (for OpenClaw cron payload)

When running as an OpenClaw cron agentTurn, the agent should:

Step 1 — Run cost parser

Execute scripts/cost_report.py --config /path/to/config.json and capture output.

Step 2 — Run zombie killer

Execute scripts/zombie_killer.py --config /path/to/config.json and capture output.

Step 3 — Format and post

Combine both outputs into the report format above and post to your Discord webhook.


Configuration Reference

KeyTypeDescription
sessions_dirstringPath to OpenClaw sessions directory
workspace_dirstringPath to OpenClaw workspace (for state logs)
discord_webhookstringDiscord webhook URL to post the report
discord_user_idstringYour Discord ID — tagged on urgent alerts
channel_namesobjectMap session keys → display names (optional)
zombie_min_age_hoursnumberSessions older than this get reset (default: 24)
zombie_min_size_mbnumberMinimum file size to reset (default: 1MB)
alert_high_costnumberDaily cost threshold for 🚨 URGENT flag (default: $50)
alert_low_costnumberDaily cost threshold for ✅ UNDER BUDGET flag (default: $10)
timezone_offset_hoursnumberYour UTC offset for date filtering (default: -6 for CST)

Files

openclaw-daily-ops/
├── SKILL.md                 ← this file
├── config.example.json      ← template config (copy to config.json)
├── scripts/
│   ├── cost_report.py       ← parses sessions, computes costs, posts to Discord
│   └── zombie_killer.py     ← wipes stale sessions, logs what was cleared
└── state/                   ← created automatically
    ├── cost-log.json        ← rolling 90-day cost history
    └── session-reset-log.json ← log of all zombie kills

FAQ

Q: Will this break my active sessions? No. The zombie killer only resets sessions older than 24h AND larger than 1MB. Active sessions are never touched.

Q: What does "reset" mean? It truncates the session JSONL file to empty. OpenClaw recreates it fresh on next use. All logs are saved to session-reset-log.json before wiping.

Q: Can I adjust the thresholds? Yes — zombie_min_age_hours and zombie_min_size_mb in config.json.

Q: Does this work on Andre/multi-machine setups? Yes. Run the setup on each machine with its own config.json. Both can post to the same Discord webhook.

Comments

Loading comments...