Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 09:05:26 +08:00
commit c4490425a6
6 changed files with 191 additions and 0 deletions

32
commands/spending-get.md Normal file
View File

@@ -0,0 +1,32 @@
---
description: Get current spending totals (daily, weekly, and hourly)
---
# Get Spending Totals
Display current spending totals for today, this week, and the current hour.
## Instructions
1. **Execute command**:
- Run: `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/track_spending.py --data-dir ${CLAUDE_PLUGIN_ROOT}/spending_data get --format text`
- Display the daily, weekly, and hourly spending totals
2. **Format output**:
- Show daily total with date
- Show weekly total with week number
- Show hourly total with time period
- Use clear formatting for easy reading
## Example Output
```
Daily: $5.25
Weekly: $32.40
Hourly: $1.32
```
## Notes
- No confirmation needed (read-only operation)
- Data is read from `${CLAUDE_PLUGIN_ROOT}/spending_data/`

View File

@@ -0,0 +1,45 @@
---
description: Reset all spending tracking data
---
# Reset Spending Data
Reset all spending tracking data (daily, weekly, and hourly). This operation is destructive and cannot be undone.
## Arguments
Input: `$ARGUMENTS`
## Instructions
1. **Parse arguments**:
- Check if `--confirm` or `-f` flag is present in `$ARGUMENTS`
2. **Ask for confirmation** (UNLESS `--confirm` or `-f` flag is present):
- Warn user: "⚠️ This will delete ALL spending tracking data (daily, weekly, and hourly). This cannot be undone."
- Show affected files:
- `${CLAUDE_PLUGIN_ROOT}/spending_data/daily.json`
- `${CLAUDE_PLUGIN_ROOT}/spending_data/weekly.json`
- `${CLAUDE_PLUGIN_ROOT}/spending_data/hourly.json`
- `${CLAUDE_PLUGIN_ROOT}/spending_data/session_state.json`
- Ask: "Are you sure you want to proceed? (yes/no)"
- If user responds "no" or anything other than "yes", abort
- If user responds "yes", proceed
3. **Execute reset**:
- Run: `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/track_spending.py --data-dir ${CLAUDE_PLUGIN_ROOT}/spending_data reset --confirm`
- Display success message
## Example Usage
```
/spending-reset
/spending-reset --confirm
/spending-reset -f
```
## Notes
- ALWAYS ask for confirmation unless `--confirm` or `-f` is provided
- This operation is irreversible
- Session state will also be cleared

View File

@@ -0,0 +1,46 @@
---
description: Show detailed spending statistics
---
# Spending Statistics
Display detailed statistics about your Claude Code API spending, including historical data and averages.
## Instructions
1. **Execute command**:
- Run: `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/track_spending.py --data-dir ${CLAUDE_PLUGIN_ROOT}/spending_data stats`
- Display the full statistics output
2. **Show information**:
- Total days tracked
- Total spending across all days
- Average spending per day
- Total hours tracked
- Average spending per hour
- Current day and hour totals
## Example Output
```
=== Spending Statistics ===
Daily Tracking:
Total days tracked: 15
Total across all days: $123.45
Average per day: $8.23
Hourly Tracking:
Total hours tracked: 89
Total across all hours: $123.45
Average per hour: $1.39
Current Period:
Today (2025-10-10): $12.34
This hour (2025-10-10T12:00): $2.45
```
## Notes
- No confirmation needed (read-only operation)
- Historical data is kept for 30 days by default