skrooge
CLAUDE.md6 starsChanged 10 months agoApache-2.0View on GitHub
Skrooge is a CLI tool for estimating Kubernetes scaling costs on GCP. Given a deployment's replica count, CPU/memory changes, and instance type, it calculates how many additional GCP instances are needed and their cost across different pricing tiers. Repository: getsentry/skrooge Language: Python 3.8+ License: Apache 2.0 Dependency groups defined in pyproject.toml: - Core: click, click-log - [lint]: ruff - [test]: pytest, pytest-cov - [scrape]: pandas, requests, lxml The codebase follows a simple three-module pattern: Data flow: CLI parses args →…
- Installs packages
The file
We split this CLAUDE.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 86
Test data uses a hardcoded c2_standard_30_instance_data dict rather than loading from instances.json.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Project Overview
Skrooge is a CLI tool for estimating Kubernetes scaling costs on GCP. Given a deployment's replica count, CPU/memory changes, and instance type, it calculates how many additional GCP instances are needed and their cost across different pricing tiers.
Repository: getsentry/skrooge
Language: Python 3.8+
License: Apache 2.0
Repository Structure
skrooge/
├── skrooge/ # Main package
│ ├── __main__.py # Entry point for `python -m skrooge`
│ ├── cli.py # Click CLI commands and options
│ ├── utils.py # Core calculation logic (constrained resource, instance count, cost)
│ ├── render.py # Output formatting (english, json)
│ ├── scraper.py # GCP instance data scraper (generates instances.json)
│ └── instances.json # Bundled GCP instance specs and regional pricing (~1MB)
├── tests/
│ ├── test_skrooge.py # CLI integration tests (Click CliRunner)
│ └── test_utils.py # Unit tests for calculation functions
├── scripts/
│ └── bump-version.sh # Version bumping script
├── .github/workflows/ # CI/CD (test, publish, release, changelog)
├── pyproject.toml # Project metadata, dependencies, tool config
├── .pre-commit-config.yaml # Pre-commit hooks (ruff, whitespace, yaml)
└── .craft.yml # Sentry Craft release configurationDevelopment Setup
python -m venv venv
source venv/bin/activate
pip install -e '.[lint,scrape,test]'Dependency groups defined in pyproject.toml:
- Core:
click,click-log [lint]:ruff[test]:pytest,pytest-cov[scrape]:pandas,requests,lxml
Common Commands
# Run tests
pytest
# Run tests with coverage (as CI does)
pytest --cov=./ --cov-report=xml
# Lint
ruff check .
# Format
ruff format .
# Update GCP instance data
python3 skrooge/scraper.py > skrooge/instances.jsonArchitecture
The codebase follows a simple three-module pattern:
cli.py: Defines the Click CLI group andestimatecommand. Loadsinstances.json, validates instance types with fuzzy matching (difflib), and orchestrates the calculation pipeline.utils.py: Pure calculation functions:determine_constrained_resource()— determines if CPU or memory is the limiting factordetermine_instance_count_required()— calculates how many instances are neededcalculate_cost()— computes hourly/monthly/yearly costs
render.py: Output dispatching forenglish(human-readable) andjsonformats.
Data flow: CLI parses args → loads instance data → calls utils for calculations → passes result dict to render.
Testing
Tests use pytest. CLI tests use Click's CliRunner for integration testing.
tests/test_skrooge.py: CLI integration tests (version flag, invalid input handling, negative value normalization, cost output verification)tests/test_utils.py: Unit tests fordetermine_constrained_resourceanddetermine_instance_count_requiredwith a c2-standard-30 fixture
Test data uses a hardcoded c2_standard_30_instance_data dict rather than loading from instances.json.
CI/CD
GitHub Actions workflows target main branch:
python-package.yml: Runs lint (ruff check .) and tests (pytest --cov) across Python 3.9–3.12 on every push/PR to main. Uploads coverage to Codecov.publish.yml: Triggered by pushes torelease/**branches. Runs tests, then builds and uploads to PyPI via OIDC.release.yml: Manual workflow dispatch using Sentry's Craft for version bumping, changelog generation, and GitHub releases.changelog-preview.yml: Previews changelog entries on PRs.
Code Conventions
- Linting/Formatting: Ruff (configured in
pyproject.toml).skrooge/scraper.pyis excluded from linting. - Style: PEP 8, snake_case for all functions and variables.
- CLI framework: Click with
click_logfor verbosity control. - Error handling:
click.BadParameterfor user-facing errors, with fuzzy match suggestions viadifflib.get_close_matches. - Logging: Python stdlib
loggingmodule, wired throughclick_log. - Imports: Standard library first, third-party second, local (relative) imports third.
- No type annotations: The codebase does not use type hints consistently.
- Units: CPU in milli-cores, memory in MiB. Instance specs use cores and GiB.
Key Data
instances.json structure:
{
"<family>": {
"<instance-type>": {
"regions": {
"<region>": {
"ondemand": <float>,
"sud": <float>,
"preemptible": <float>,
"cud-1y": <float>,
"cud-3y": <float>
}
},
"specs": {
"cores": <int>,
"memory": <float>,
"local_ssd": <int>,
"gpu": <int>,
...
}
}
}
}18 instance families, 254 instance types, 47+ GCP regions, 5 cost classes.
Pre-commit Hooks
Configured in .pre-commit-config.yaml:
- Trailing whitespace removal
- End-of-file newline
- YAML syntax check
- Large file prevention
- Ruff lint and format
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
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.

