agentleFS
huiruruhuiruru/ecoguilt/skills/impact/SKILL.md

impact

Skill9 starsChanged 8 months agoMITView on GitHub

Show the environmental cost of this coding session — CO2 emitted, water consumed, and what a smarter model choice would have saved.

  • Reads credentials

9 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. 0 are common, 14 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 14

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the file is empty or missing, tell the user the status line hasn't recorded data yet.

    line 27
  2. Distinctive:

    Read the cached recommendation using the same session ID from step 1:

    line 35
  3. Distinctive:

    If the file is empty, missing, or stale, run the recommend script.

    line 40
  4. Distinctive:

    If that doesn't find a file, try:

    line 45
  5. Distinctive:

    Read the model cache to get pricing and energy data for the recommended model:

    line 59
  6. Distinctive:

    Use these refreshed numbers for the bill below.

    line 86
  7. Distinctive:

    Do NOT use abstract comparisons like grams of coal, ml of gasoline, or "a tree needs X days." Use: miles driven in a car going nowhere, …

    line 93
  8. Distinctive:

    Not Diamond optimizes for the cheapest model that can handle the task accurately.

    line 98
  9. Distinctive:

    If the recommended model is cheaper than current:

    line 100
  10. Distinctive:

    If the recommended model is more expensive than current:

    line 105
  11. Distinctive:

    If the recommended model IS the current model, say: "not diamond agrees: [current model] was the right call."

    line 110
  12. Very specific:

    If no_api_key error: show the impact numbers, then add: "set NOTDIAMOND_API_KEY to see what a cheaper model would have saved.

    line 112
  13. Very specific:

    Read anomalous turns from ~/.ecoguilt/history.jsonl for the current session:

    line 117
  14. Distinctive:

    If any exist, show each one.

    line 123
  15. Distinctive:

    If none: "no anomalies this session."

    line 133
  16. Very specific:

    If ~/.ecoguilt/history.jsonl doesn't exist yet: omit the section silently (Stop hook hasn't fired yet).

    line 135
  17. Distinctive:

    Footer: Add a small note at the end: "*as of last tool use — the status line includes this response's tokens.*"

    line 137

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Show the environmental impact of this coding session.

Step 1: Find the session and get the numbers

The status line writes state to /tmp/ecoguilt-{session_id}.json and a per-cwd pointer at /tmp/ecoguilt-cwd-{hash}.txt. Use the pointer to find the correct session for this working directory:

CWD_HASH=$(echo -n "$PWD" | md5 2>/dev/null || echo -n "$PWD" | md5sum 2>/dev/null | cut -d' ' -f1)
SESSION_ID=$(cat "/tmp/ecoguilt-cwd-${CWD_HASH}.txt" 2>/dev/null)
if [ -n "$SESSION_ID" ]; then
  STATE_FILE="/tmp/ecoguilt-${SESSION_ID}.json"
else
  STATE_FILE=$(ls -t /tmp/ecoguilt-*.json 2>/dev/null | grep -v 'models\|test\|recommend\|cwd' | head -1)
  SESSION_ID=$(echo "$STATE_FILE" | sed 's|/tmp/ecoguilt-||; s|\.json||')
fi
echo "STATE: $STATE_FILE"; cat "$STATE_FILE" 2>/dev/null || echo '{}'

If the file is empty or missing, tell the user the status line hasn't recorded data yet.

The file contains: input_tokens, output_tokens, total_tokens, total_kwh, co2_g, water_ml, model, cost_usd, input_kwh_per_token, output_kwh_per_token.

These numbers are the single source of truth — they match what the status line displays. Do NOT recalculate energy, CO2, or water from tokens. Use the values from this file directly.

Step 2: Get Not Diamond's recommendation

Read the cached recommendation using the same session ID from step 1:

cat "/tmp/ecoguilt-${SESSION_ID}-recommend.json" 2>/dev/null || echo '{}'

If the file is empty, missing, or stale, run the recommend script. First find the transcript:

ls -t ~/.claude/projects/*/${SESSION_ID}.jsonl 2>/dev/null | head -1

If that doesn't find a file, try:

ls -t ~/.claude/projects/*/*.jsonl 2>/dev/null | head -1

Then:

bash ${CLAUDE_SKILL_DIR}/../../scripts/recommend.sh "<transcript_path>" 2>/dev/null || echo '{"error": "failed"}'

The response is JSON with model, provider, and messages_sent, or {"error": "no_api_key"} if the user doesn't have NOTDIAMOND_API_KEY set.

Step 3: Calculate the comparison

Read the model cache to get pricing and energy data for the recommended model:

cat /tmp/ecoguilt-models.json 2>/dev/null || echo '[]'

This file is auto-generated by sync-models.sh from the user's models.json + Not Diamond's API. Each entry has: id, provider, display, input_price ($/1M tokens), output_price ($/1M tokens), input_kwh_per_token, output_kwh_per_token, available.

The session state file has: input_tokens, output_tokens, input_kwh_per_token, output_kwh_per_token, cost_usd.

For the recommended model, look up its entry in the model cache by id, then calculate using pricing ratio scaling (more accurate than token-based estimates due to context caching):

  • cur_avg_price = (current input_price + current output_price) / 2
  • rec_avg_price = (recommended input_price + recommended output_price) / 2
  • cost = state.cost_usd × (rec_avg_price / cur_avg_price)
  • kWh = state.total_kwh × (rec_avg_price / cur_avg_price)
  • CO2 = kWh × 0.39 × 1000 (grams)
  • water = kWh × 1800 (ml)
  • miles driven (400g CO2 per mile)
  • bottles of water (500ml each)

Step 4: Re-read state before presenting

The state file updates on every status line render. Since steps 1–3 consumed tokens (running bash commands), the file is now stale. Re-read it so the bill matches the status line:

cat "$STATE_FILE" 2>/dev/null || echo '{}'

Use these refreshed numbers for the bill below. Recalculate the recommended model's comparison against the updated token counts.

Step 5: Present the bill

Section 1 — what you used: State the raw numbers one per line: tokens, kWh, CO2, water, cost. Then the visual comparisons (miles driven, bottles of water, lightbulb hours, etc). Each line should be a scene the reader can picture.

Do NOT use abstract comparisons like grams of coal, ml of gasoline, or "a tree needs X days." Use: miles driven in a car going nowhere, bottles of water poured down a drain, lightbulbs left on in empty rooms, smartphone charges.

IMPORTANT: each comparison must describe a DIFFERENT resource. Do not repeat the same resource in two different ways (e.g. "2 bottles of water" and "half a day's drinking water" are the same thing — pick one). One line per resource: one for CO2, one for water, one for energy.

Section 2 — not diamond's verdict: Not Diamond optimizes for the cheapest model that can handle the task accurately. Its recommendation overrides naive cost comparison — if it suggests a more expensive model, that means accuracy requires it for this task.

If the recommended model is cheaper than current:

  • "not diamond says: [display name] could have handled this."
  • Show the same metrics recalculated for that model using pricing ratio scaling
  • The delta: "that's Xg less CO2. X fewer bottles of water. $X cheaper."

If the recommended model is more expensive than current:

  • "not diamond says: [display name] would be more accurate. that's a $X tradeoff."
  • Show the metrics recalculated for that model
  • The delta: "that's Xg more CO2. X more bottles of water. $X more expensive — but not diamond thinks this task needs it."

If the recommended model IS the current model, say: "not diamond agrees: [current model] was the right call."

If no_api_key error: show the impact numbers, then add: "set NOTDIAMOND_API_KEY to see what a cheaper model would have saved. get a key at notdiamond.ai"

Section 3 — anomalies this session:

Read anomalous turns from ~/.ecoguilt/history.jsonl for the current session:

grep "\"session_id\":\"${SESSION_ID}\"" "$HOME/.ecoguilt/history.jsonl" 2>/dev/null | jq -c 'select(.anomaly != null)' | sort -t'"' -k2

If any exist, show each one. Use the directional breakdown from the anomaly record:

⚠ turn 4  output_spike  out:8,234 / in:412   +$0.18  "write a comprehensive test suite for all..."
⚠ turn 7  input_spike   in:9,102 / out:380   +$0.09  "paste the full logs below:"
⚠ turn 9  cache_break   82% → 12%            +$0.31  "can you refactor this entire module..."

For output_spike/input_spike: show turn_output_tokens and turn_input_tokens from the anomaly object. For cache_break: show prev_cache_efficiency → turn_cache_efficiency as percentages.

If none: "no anomalies this session."

If ~/.ecoguilt/history.jsonl doesn't exist yet: omit the section silently (Stop hook hasn't fired yet).

Footer: Add a small note at the end: "as of last tool use — the status line includes this response's tokens."

Tone: Deadpan. The numbers do the talking. No softening, no "great job for checking!" — just the bill and what could have been different.

$ARGUMENTS

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.