Skip to content
Back to skills

Carbon Badge

ASecurity

Generate a shields.io badge of your Claude Code carbon footprint for your READMEs

  • 259 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added August 30, 2026
ai-agentsshellbashgit

Works with

  • claude code

Security analysis

A100/100

Scanned November 17, 2026

npx -y skills add gwittebolle/claude-carbon --skill carbon-badge --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Carbon Badge?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Carbon Badge
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gwittebolle-carbon-badge/badge)](https://www.skillsdirectory.com/skills/gwittebolle-carbon-badge)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: carbon-badge
description: Generate a shields.io badge of your Claude Code carbon footprint for your READMEs
---

Run the following bash script and present the output to the user.

```bash
#!/usr/bin/env bash
# Locate the install wired into the status line (honours CLAUDE_CONFIG_DIR),
# then fall back to CLAUDE_PLUGIN_ROOT / CLAUDE_CARBON_DIR / the default path.
# Windows (Git Bash): CLAUDE_* variables and the paths stored in settings.json can
# arrive in the native "C:\Users\..." spelling, which bash cannot open. cygpath
# ships with Git for Windows; everywhere else this is the identity function.
ccp() {
  case "${OSTYPE:-}" in msys*|cygwin*) ;; *) printf '%s' "$1"; return 0 ;; esac
  case "$1" in
    [A-Za-z]:[\\/]*|*\\*) cygpath -u "$1" 2>/dev/null || printf '%s' "$1" ;;
    *) printf '%s' "$1" ;;
  esac
}
CFG="$(ccp "${CLAUDE_CONFIG_DIR:-$HOME/.claude}")"
# A jq the installer fetched into the data folder (a Mac older than macOS 15 has none)
if ! command -v jq >/dev/null 2>&1 && [ -x "$CFG/claude-carbon/bin/jq" ]; then PATH="$CFG/claude-carbon/bin:$PATH"; fi
REPO_DIR=""
if command -v jq >/dev/null 2>&1 && [ -f "$CFG/settings.json" ]; then
  SL_CMD="$(jq -r '.statusLine.command // empty' "$CFG/settings.json" 2>/dev/null)"
  # statusLine.command stores a path, shell-escaped, or in double quotes on Windows:
  # unquote, expand ~ and unescape spaces
  SL_CMD="${SL_CMD#\"}"; SL_CMD="${SL_CMD%\"}"
  SL_CMD="${SL_CMD//\\ / }"; SL_CMD="${SL_CMD/#\~/$HOME}"; SL_CMD="$(ccp "$SL_CMD")"
  if [ -n "$SL_CMD" ] && [ -f "$SL_CMD" ]; then
    SL_DIR="$(dirname "$SL_CMD")"
    if [ -f "$SL_DIR/plugin-root" ]; then
      # The plugin's own status line: a small script next to a file naming the plugin's folder
      R=""; IFS= read -r R <"$SL_DIR/plugin-root" 2>/dev/null; R="$(ccp "${R%$'\r'}")"
      [ -n "$R" ] && [ -d "$R/scripts" ] && REPO_DIR="$R"
    else
      REPO_DIR="$(cd "$SL_DIR/.." 2>/dev/null && pwd)"
    fi
  fi
fi
[ -z "$REPO_DIR" ] && [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && REPO_DIR="$(ccp "$CLAUDE_PLUGIN_ROOT")"
[ -z "$REPO_DIR" ] && [ -n "${CLAUDE_CARBON_DIR:-}" ] && REPO_DIR="$(ccp "$CLAUDE_CARBON_DIR")"
if [ -z "$REPO_DIR" ]; then
  # Pure marketplace installs reach here: no statusLine.command in settings.json and
  # no CLAUDE_PLUGIN_ROOT in a skill's bash env. Pick the newest cached plugin copy,
  # keeping only candidates that ship the badge script.
  CACHE_LATEST=""
  for D in "$CFG/plugins/cache"/*/claude-carbon/*/; do
    [ -f "${D}scripts/generate-badge.sh" ] || continue
    if [ -z "$CACHE_LATEST" ] || [ "$(printf '%s\n%s\n' "$CACHE_LATEST" "$D" | sort -V | tail -1)" = "$D" ]; then
      CACHE_LATEST="$D"
    fi
  done
  [ -n "$CACHE_LATEST" ] && REPO_DIR="${CACHE_LATEST%/}"
fi
# The /carbon-* commands are links into the install: they name it when the status line
# belongs to another tool (a clone outside the default folder, a Homebrew install).
if [ -z "$REPO_DIR" ]; then
  CMD_LNK="$(readlink "$CFG/commands/carbon-badge.md" 2>/dev/null || true)"
  case "$CMD_LNK" in
    */skills/carbon-badge/SKILL.md) [ -d "${CMD_LNK%/skills/*}/scripts" ] && REPO_DIR="${CMD_LNK%/skills/*}" ;;
  esac
fi
[ -z "$REPO_DIR" ] && REPO_DIR="$HOME/code/claude-carbon"

bash "$REPO_DIR/scripts/generate-badge.sh"
```

The script prints a ready-to-paste markdown snippet, the raw badge URL and a short note on where the badge belongs. Show all of it exactly as printed — never recompute, reformat or re-escape the number, the month or the URL. The badge is one developer's total, dated with the month it was generated, and it links to the methodology. It belongs in the user's profile README or a personal project, not in a team or organisation repository. The badge is a static image, so re-running `/carbon-badge` is how they refresh the figure and its month.

If the script is missing (an install that predates the badge), suggest `/carbon-update`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.