$npx -y skills add stevesolun/ctx --skill repo-stats-autoupdateKeeps README badge + inline counts in sync with the real number of skills, agents, graph nodes/edges, communities, converted pipelines, and test inventory. Runs automatically on every commit via a git pre-commit hook. Use when the README drifts from reality or before publishing a
| 1 | # repo-stats-autoupdate |
| 2 | |
| 3 | ## What this skill does |
| 4 | |
| 5 | Reads the **authoritative sources** for the ctx repo's key numbers and patches `README.md` in place so badges and inline counts never drift: |
| 6 | |
| 7 | | Number | Source of truth | |
| 8 | |---|---| |
| 9 | | Skills | `~/.claude/skill-wiki/graphify-out/graph.json` — count nodes where `type == "skill"` | |
| 10 | | Agents | same file — count nodes where `type == "agent"` | |
| 11 | | Graph nodes | `len(graph["nodes"])` | |
| 12 | | Graph edges | `len(graph["edges"])`, formatted as `642K` / `1.2M` | |
| 13 | | Communities | `graph/communities.json` → `total_communities` | |
| 14 | | Converted pipelines | `~/.claude/skill-wiki/converted/` subdir count | |
| 15 | | Tests | checked-in README/docs inventory by default; set `CTX_UPDATE_REPO_STATS_LIVE_TESTS=1` to refresh from `pytest --collect-only -q` | |
| 16 | |
| 17 | Fields that can't be resolved (e.g. wiki not deployed) are left untouched — the updater never blocks a commit. |
| 18 | |
| 19 | ## How to use it |
| 20 | |
| 21 | **One-time install (per clone):** |
| 22 | ```bash |
| 23 | git config core.hooksPath .githooks |
| 24 | ``` |
| 25 | |
| 26 | After that, every `git commit` runs `.githooks/pre-commit` which calls the updater and re-stages `README.md` if any number drifted. |
| 27 | |
| 28 | **Manual run:** |
| 29 | ```bash |
| 30 | python src/update_repo_stats.py # patch README |
| 31 | python src/update_repo_stats.py --check # exit 1 if stale (for CI) |
| 32 | CTX_UPDATE_REPO_STATS_LIVE_TESTS=1 python src/update_repo_stats.py # refresh test inventory |
| 33 | ``` |
| 34 | |
| 35 | ## When NOT to use it |
| 36 | |
| 37 | - When you've deliberately phrased a number descriptively (e.g. "over 1,700 skills") — the regex patterns only match exact digits, so prose phrasings are safe, but double-check after big imports. |
| 38 | - When the wiki isn't deployed locally. The updater degrades gracefully: it prints a warning and skips fields it can't resolve. It does **not** invent numbers. |
| 39 | |
| 40 | ## Known gaps (intentionally out of scope) |
| 41 | |
| 42 | - **Does not rebuild the graph or wiki.** Rebuilding `graph/wiki-graph.tar.gz` takes minutes and churns a large artifact — too heavy for per-commit. Run `ctx-wiki-graphify`, then `python src/validate_graph_artifacts.py --deep`, and repack the tarball manually when the skill catalog changes materially. |
| 43 | - **Does not verify graph integrity.** If `graphify-out/graph.json` is corrupt, you'll get junk numbers. Run the wiki health check (`python src/wiki_orchestrator.py --check`) separately. |
| 44 | |
| 45 | ## Related files |
| 46 | |
| 47 | - [src/update_repo_stats.py](../../src/update_repo_stats.py) — the worker |
| 48 | - [.githooks/pre-commit](../../.githooks/pre-commit) — the per-commit trigger |
| 49 | - `README.md` — the target being kept in sync |