mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-05-15 13:23:13 +08:00
feat: salvage cost tracking and skill scout (#1815)
This commit is contained in:
147
skills/cost-tracking/SKILL.md
Normal file
147
skills/cost-tracking/SKILL.md
Normal file
@@ -0,0 +1,147 @@
|
||||
---
|
||||
name: cost-tracking
|
||||
description: Track and report Claude Code token usage, spending, and budgets from a local cost-tracking database. Use when the user asks about costs, spending, usage, tokens, budgets, or cost breakdowns by project, tool, session, or date.
|
||||
origin: community
|
||||
---
|
||||
|
||||
# Cost Tracking
|
||||
|
||||
Use this skill to analyze Claude Code cost and usage history from a local SQLite
|
||||
database. It is intended for users who already have a cost-tracking hook or
|
||||
plugin writing usage rows to `~/.claude-cost-tracker/usage.db`.
|
||||
|
||||
Source: salvaged from stale community PR #1304 by `MayurBhavsar`.
|
||||
|
||||
## When to Use
|
||||
|
||||
- The user asks "how much have I spent?", "what did this session cost?", or
|
||||
"what is my token usage?"
|
||||
- The user mentions budgets, spending limits, overruns, or cost controls.
|
||||
- The user wants a cost breakdown by project, tool, session, model, or date.
|
||||
- The user wants to compare today against yesterday or inspect a recent trend.
|
||||
- The user asks for a CSV export of recent usage records.
|
||||
|
||||
## How It Works
|
||||
|
||||
First verify prerequisites:
|
||||
|
||||
```bash
|
||||
command -v sqlite3 >/dev/null && echo "sqlite3 available" || echo "sqlite3 missing"
|
||||
test -f ~/.claude-cost-tracker/usage.db && echo "Database found" || echo "Database not found"
|
||||
```
|
||||
|
||||
If the database is missing, do not fabricate usage data. Tell the user that cost
|
||||
tracking is not configured and suggest installing or enabling a trusted local
|
||||
cost-tracking hook/plugin.
|
||||
|
||||
The expected `usage` table usually contains one row per tool call or model
|
||||
interaction. Column names vary by tracker, but the examples below assume:
|
||||
|
||||
| Column | Meaning |
|
||||
| --- | --- |
|
||||
| `timestamp` | ISO timestamp for the usage event |
|
||||
| `project` | Project or repository name |
|
||||
| `tool_name` | Tool or event name |
|
||||
| `input_tokens` | Input token count, when recorded |
|
||||
| `output_tokens` | Output token count, when recorded |
|
||||
| `cost_usd` | Precomputed cost in USD |
|
||||
| `session_id` | Claude Code session identifier |
|
||||
| `model` | Model used for the event |
|
||||
|
||||
Prefer `cost_usd` over hand-calculating pricing. Model prices and cache pricing
|
||||
change over time, and the tracker should be the source of truth for how each row
|
||||
was priced.
|
||||
|
||||
## Examples
|
||||
|
||||
### Quick Summary
|
||||
|
||||
```bash
|
||||
sqlite3 ~/.claude-cost-tracker/usage.db "
|
||||
SELECT
|
||||
'Today: $' || ROUND(COALESCE(SUM(CASE WHEN date(timestamp) = date('now') THEN cost_usd END), 0), 4) ||
|
||||
' | Total: $' || ROUND(COALESCE(SUM(cost_usd), 0), 4) ||
|
||||
' | Calls: ' || COUNT(*) ||
|
||||
' | Sessions: ' || COUNT(DISTINCT session_id)
|
||||
FROM usage;
|
||||
"
|
||||
```
|
||||
|
||||
### Cost By Project
|
||||
|
||||
```bash
|
||||
sqlite3 -header -column ~/.claude-cost-tracker/usage.db "
|
||||
SELECT project, ROUND(SUM(cost_usd), 4) AS cost, COUNT(*) AS calls
|
||||
FROM usage
|
||||
GROUP BY project
|
||||
ORDER BY cost DESC;
|
||||
"
|
||||
```
|
||||
|
||||
### Cost By Tool
|
||||
|
||||
```bash
|
||||
sqlite3 -header -column ~/.claude-cost-tracker/usage.db "
|
||||
SELECT tool_name, ROUND(SUM(cost_usd), 4) AS cost, COUNT(*) AS calls
|
||||
FROM usage
|
||||
GROUP BY tool_name
|
||||
ORDER BY cost DESC;
|
||||
"
|
||||
```
|
||||
|
||||
### Last Seven Days
|
||||
|
||||
```bash
|
||||
sqlite3 -header -column ~/.claude-cost-tracker/usage.db "
|
||||
SELECT date(timestamp) AS date, ROUND(SUM(cost_usd), 4) AS cost, COUNT(*) AS calls
|
||||
FROM usage
|
||||
GROUP BY date(timestamp)
|
||||
ORDER BY date DESC
|
||||
LIMIT 7;
|
||||
"
|
||||
```
|
||||
|
||||
### Session Drilldown
|
||||
|
||||
```bash
|
||||
sqlite3 -header -column ~/.claude-cost-tracker/usage.db "
|
||||
SELECT session_id,
|
||||
MIN(timestamp) AS started,
|
||||
MAX(timestamp) AS ended,
|
||||
ROUND(SUM(cost_usd), 4) AS cost,
|
||||
COUNT(*) AS calls
|
||||
FROM usage
|
||||
GROUP BY session_id
|
||||
ORDER BY started DESC
|
||||
LIMIT 10;
|
||||
"
|
||||
```
|
||||
|
||||
## Reporting Guidance
|
||||
|
||||
When presenting cost data, include:
|
||||
|
||||
1. Today's spend and yesterday comparison.
|
||||
2. Total spend across the tracked database.
|
||||
3. Top projects ranked by cost.
|
||||
4. Top tools ranked by cost.
|
||||
5. Session count and average cost per session when enough data exists.
|
||||
|
||||
For small amounts, format currency with four decimal places. For larger amounts,
|
||||
two decimals are enough.
|
||||
|
||||
## Anti-Patterns
|
||||
|
||||
- Do not estimate costs from raw token counts when `cost_usd` is present.
|
||||
- Do not assume the database exists without checking.
|
||||
- Do not run unbounded `SELECT *` exports on large databases.
|
||||
- Do not hard-code current model pricing in user-facing answers.
|
||||
- Do not recommend installing unreviewed hooks or plugins that execute arbitrary
|
||||
code.
|
||||
|
||||
## Related
|
||||
|
||||
- `/cost-report` - Command-form report using the same database.
|
||||
- `cost-aware-llm-pipeline` - Model-routing and budget-design patterns.
|
||||
- `token-budget-advisor` - Context and token-budget planning.
|
||||
- `strategic-compact` - Context compaction to reduce repeated token spend.
|
||||
140
skills/skill-scout/SKILL.md
Normal file
140
skills/skill-scout/SKILL.md
Normal file
@@ -0,0 +1,140 @@
|
||||
---
|
||||
name: skill-scout
|
||||
description: Search existing local, marketplace, GitHub, and web skill sources before creating a new skill. Use when the user wants to create, build, fork, or find a skill for a workflow.
|
||||
origin: community
|
||||
---
|
||||
|
||||
# Skill Scout
|
||||
|
||||
Use this skill before creating a new skill. The goal is to avoid duplicating
|
||||
existing community or marketplace work, while still vetting anything external
|
||||
before adoption.
|
||||
|
||||
Source: salvaged from stale community PR #1232 by `redminwang`.
|
||||
|
||||
## When to Use
|
||||
|
||||
- The user says "create a skill", "build a skill", "make a skill", or "new
|
||||
skill".
|
||||
- The user asks "is there a skill for X?" or "does a skill exist that does Y?"
|
||||
- The user describes a workflow and you are about to suggest creating a new
|
||||
skill.
|
||||
- The user wants to fork or extend an existing skill.
|
||||
|
||||
If the user explicitly says to skip search or create from scratch, acknowledge
|
||||
that and proceed with the requested creation workflow.
|
||||
|
||||
## How It Works
|
||||
|
||||
### Step 1 - Capture Intent
|
||||
|
||||
Extract:
|
||||
|
||||
- The task the skill should perform.
|
||||
- The trigger conditions for using it.
|
||||
- The domain, tools, frameworks, or data sources involved.
|
||||
- Three to five search keywords plus useful synonyms.
|
||||
|
||||
### Step 2 - Search Local Sources
|
||||
|
||||
Search installed and marketplace skill names first. Local sources are preferred
|
||||
because they are already part of the user's environment.
|
||||
|
||||
```bash
|
||||
find ~/.claude/skills -maxdepth 2 -name SKILL.md 2>/dev/null | grep -iE "keyword|synonym"
|
||||
find ~/.claude/plugins/marketplaces -path '*/skills/*/SKILL.md' 2>/dev/null | grep -iE "keyword|synonym"
|
||||
```
|
||||
|
||||
Then search frontmatter descriptions:
|
||||
|
||||
```bash
|
||||
grep -RilE "keyword|synonym" ~/.claude/skills ~/.claude/plugins/marketplaces 2>/dev/null
|
||||
```
|
||||
|
||||
### Step 3 - Search Remote Sources
|
||||
|
||||
Use available GitHub and web search tools. Prefer concise queries:
|
||||
|
||||
```bash
|
||||
gh search repos "claude code skill keyword" --limit 10 --sort stars
|
||||
gh search code "name: keyword" --filename SKILL.md --limit 10
|
||||
```
|
||||
|
||||
For web search, use at most three targeted queries such as:
|
||||
|
||||
```text
|
||||
"claude code skill" keyword
|
||||
"SKILL.md" keyword
|
||||
"everything-claude-code" keyword
|
||||
```
|
||||
|
||||
### Step 4 - Vet External Matches
|
||||
|
||||
Before recommending any external skill for adoption or forking:
|
||||
|
||||
- Read the `SKILL.md` frontmatter and instructions.
|
||||
- Look for unexpected shell commands, file writes, network calls, credential
|
||||
handling, or package installs.
|
||||
- Check whether the repository appears maintained.
|
||||
- Prefer copying into a fresh local branch and reviewing the diff over editing
|
||||
marketplace originals.
|
||||
|
||||
### Step 5 - Rank Results
|
||||
|
||||
Rank candidates by:
|
||||
|
||||
1. Exact keyword match in the skill name.
|
||||
2. Keyword or synonym match in description.
|
||||
3. Local installed or marketplace source.
|
||||
4. Maintained GitHub source with recent activity.
|
||||
5. Web-only mention.
|
||||
|
||||
Cap the final list at 10 results.
|
||||
|
||||
### Step 6 - Present Decision Options
|
||||
|
||||
Give the user a short table:
|
||||
|
||||
| Option | Meaning |
|
||||
| --- | --- |
|
||||
| Use existing | Invoke or install a matching skill as-is. |
|
||||
| Fork or extend | Copy the closest skill and modify it. |
|
||||
| Create fresh | Build a new skill after confirming no close match exists. |
|
||||
|
||||
Only create a new skill after the user chooses that path or after the search
|
||||
finds no close match.
|
||||
|
||||
## Examples
|
||||
|
||||
### Result Table
|
||||
|
||||
```markdown
|
||||
| # | Skill | Source | Why it matches | Gap |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 1 | article-writing | Local ECC | Drafts articles and guides | Not focused on release notes |
|
||||
| 2 | content-engine | Local ECC | Multi-format content workflow | Heavier than needed |
|
||||
| 3 | blog-writer | GitHub | Blog writing skill with recent commits | Needs security review |
|
||||
```
|
||||
|
||||
### User-Facing Summary
|
||||
|
||||
```markdown
|
||||
I found two close local matches and one external candidate. The closest fit is
|
||||
`article-writing`; it covers drafting and revision, but it does not include the
|
||||
release-note checklist you asked for. I can either use it as-is, fork it into a
|
||||
release-note variant, or create a fresh skill.
|
||||
```
|
||||
|
||||
## Anti-Patterns
|
||||
|
||||
- Do not jump directly to new skill creation when a search is reasonable.
|
||||
- Do not install external skills without reading them first.
|
||||
- Do not present a long unranked list of weak matches.
|
||||
- Do not treat web-only mentions as trusted sources.
|
||||
- Do not edit installed marketplace originals in place.
|
||||
|
||||
## Related
|
||||
|
||||
- `search-first` - General search-before-building workflow.
|
||||
- `skill-stocktake` - Audit installed skills for health, duplicates, and gaps.
|
||||
- `agent-sort` - Categorize and organize existing agents and skills.
|
||||
Reference in New Issue
Block a user