Skip to content
Skills Library
Programming · Automation

commit-with-costs

/commit-with-costs

Create a git commit with trailers for session cost metrics and Claude attribution. Use when the user asks you to commit changes to git.

Licence
MIT
Last repository change
11.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
6
Scripts
2
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 11.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • 2 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/check-git-instructions.js, scripts/commit-workflow.js

What it does and when to use it

Create a git commit with trailers for session cost metrics and Claude attribution. Use when the user asks you to commit changes to git.

Original author description

Create a git commit with trailers for session cost metrics and Claude attribution. Use when the user asks you to commit changes to git.

How it works

  1. Rules
  2. Checklist
  3. 0. Pre-flight and Config
  4. 1. Resolve SessionID
  5. 2. Detect or Generate Commit Message
  6. 3. Get User Approval
  7. 4. Fetch Cost Data
  8. 5. Create Commit
  9. 6. Display Final Summary
Original SKILL.md headings · 138 lines, 563 words
SKILL.md preview
---
name: commit-with-costs
description: Create a git commit with trailers for session cost metrics and Claude attribution. Use when the user asks you to commit changes to git.
effort: low
allowed-tools:
  - AskUserQuestion
  - Bash(git *)
  - Bash(node *)
  - Read
  - Grep

---

Create a git commit with cost metric trailers and Claude attribution.

Activate only when user invokes `/commit-with-costs` or asks to commit with costs (e.g. "commit with costs", "commit and track costs").

**PLUGIN_ROOT**: `${CLAUDE_PLUGIN_ROOT}`

**Node.js Check**: !`node "${CLAUDE_PLUGIN_ROOT}/lib/check-node-version.js"`
Halt if ERROR.

**Git Instructions Check**: !`node "${CLAUDE_SKILL_DIR}/scripts/check-git-instructions.js"`
Display any WARNING before proceeding.

**Dependencies**: !`node "${CLAUDE_PLUGIN_ROOT}/lib/check-dependencies.js" "${CLAUDE_PLUGIN_ROOT}"`

## Rules

| Rule | Behavior |
|------|----------|
| DELEGATE_TO | Read the referenced file; execute its instructions exactly. Never improvise or guess commands. |
| Narration | Narrate only STEP_DESCRIPTION steps; all others silent. |
| JSON outputs | Extract fields into variables (e.g. `data.session_id` → SESSION_ID). |
| Cost metrics | Never fabricate or estimate. Only use values from successful ccusage execution. |

---

## Checklist

```
- [ ] 0. Pre-flight and config
- [ ] 1. Resolve SessionID
- [ ] 2. Detect or Generate Commit Message
- [ ] 3. Get User Approval
- [ ] 4. Fetch Cost Data
- [ ] 5. Create commit
- [ ] 6. Display Final Summary
```

## 0. Pre-flight and Config

Halt if git commands already ran in this turn.

**SKILL_CONFIG**: !`node "${CLAUDE_PLUGIN_ROOT}/lib/skill-config.js" check commit-with-costs`

- Starts with `✓ Configuration found` → Step 1a
- Starts with `NOT_CONFIGURED` → Step 1b

Config lives at the project root. Access it only via `skill-config.js`, never by relative path.

## 1. Resolve SessionID

### 1a. Load existing configuration

```bash
node "${CLAUDE_PLUGIN_ROOT}/lib/skill-config.js" read commit-with-costs
```

Extract `config.sessionId` → SESSION_ID. Proceed to Step 2.

### 1b. Create new configuration

Display: "Configuration not found ({{path from SKILL_CONFIG}}). Let's create it."

```bash
node "${CLAUDE_SKILL_DIR}/scripts/commit-workflow.js" list-sessions
```

Extract `data.sessions`. Use AskUserQuestion: "Select a Claude Code session:" with first 4 session IDs as options.

```bash
node "${CLAUDE_PLUGIN_ROOT}/lib/skill-config.js" write commit-with-costs '{"sessionId":"{{SELECTED_SESSION_ID}}"}'
```

- `created` → inform user of `path`.
- `exists` → keep it; never overwrite. Step 1a.

## 2. Detect or Generate Commit Message

Check conversation for an existing `Proposed commit message:` block (e.g. from `/preview-commit-message`).

**If found:** Extract COMMIT_SUBJECT and COMMIT_BODY from the ━━━-delimited block. Skip to Step 3.

**If not found:**

DELEGATE_TO: `${CLAUDE_PLUGIN_ROOT}/references/stage_and_analyze.md`

DELEGATE_TO: `${CLAUDE_PLUGIN_ROOT}/references/message_guidelines.md`

Store COMMIT_SUBJECT and COMMIT_BODY. Produce no output yet — the message is displayed in Step 3 via the AskUserQuestion `question` field.

## 3. Get User Approval

Obtain user approval via **AskUserQuestion** before proceeding. The commit message MUST be embedded in the question field (see reference) — this overrides the Narration silent rule.

DELEGATE_TO: `${CLAUDE_PLUGIN_ROOT}/references/message_approval.md`

- "use_full" or "use_subject_only" → Step 4
- "request_revisions" → return to Step 2

## 4. Fetch Cost Data

**STEP_DESCRIPTION**: "Fetching session cost metrics"

DELEGATE_TO: `references/fetch_cost.md`

**If FETCH_STATUS = "success":** Store SESSION_ID, CURRENT_COST, COST_METHOD, COST_SINCE, CLEANUP_PERIOD_DAYS. Proceed to Step 5.

**If not "success":** Display error. Halt: cost metrics are required.

## 5. Create Commit

**STEP_DESCRIPTION**: "Creating git commit with cost metrics"

Verify SESSION_ID, CURRENT_COST, and APPROVAL_STATUS all exist. If any missing, exit.

DELEGATE_TO: `references/create_commit.md`

**If STATUS = "success":** Extract COMMIT_SHA. Proceed to Step 6.
**If not:** Display error. Exit.

## 6. Display Final Summary

```
✅ Commit created with project cost metrics in footer
   SHA: {COMMIT_SHA}

📊 Project cost metrics:
   Project: {SESSION_ID}
   (if COST_METHOD = "inc"):
      Cost since previous commit (since {COST_SINCE}):
   (if COST_METHOD = "cum"):
      Cost total, last {CLEANUP_PERIOD_DAYS} days:
   (for each model in CURRENT_COST array):
      • {model}: ${cost} = {in}in [+ {cacheWrites} cacheWrites] [+ {cacheReads} cacheReads] + {out}out
```

Only show `cacheWrites`/`cacheReads` when non-zero. Cache values are pre-abbreviated strings – display as-is.
Files in this package (6)
  • README.md 7 KB
  • SKILL.md 5 KB
  • references/create_commit.md 1 KB
  • references/fetch_cost.md 1 KB
  • scripts/check-git-instructions.js 1 KB
  • scripts/commit-workflow.js 8 KB

Versions

The database has no other skills named commit-with-costs.

Database snapshot: 13.11.2026 · package version 88f69f8b410e (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100merge-with-costs
    Merge sub-agent worktree branches and create the merge commit with session cost metrics and Claude attribution. Use when the user asks to merge worktree or sub-agent branches with costs.
  • 100commit
    Write a commit message and create a git commit. Use when the user wants to commit changes, asks for a commit message, or says "commit this" or "make a commit".
  • 86commit
    Create a Git commit for the current task. Use when the user asks to commit changes.
  • 96git-commit
    Use when the user asks to commit pending work.
  • 100git-commit
    Commit staged changes with conventional commit message. Use when user says "commit changes", "commit this", "save my changes", or wants to create a git commit.
  • 100git-commit
    Commit staged changes with conventional commit message. Use when user says "commit changes", "commit this", "save my changes", or wants to create a git commit.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.