/project-toolkit:metricsfrom project-toolkit
Collects agent usage metrics from git history and generates health reports. Tracks Invocation Rate, Coverage, Infrastructure Review, and Usage Distribution for measuring agent adoption and system health.
Ships in project-toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This utility collects and reports metrics on agent usage from git history. It collects 4 of the metrics defined in docs/agent-metrics.md (Invocation Rate, Coverage, Infrastructure Review, Usage Distribution) for measuring agent system health, effectiveness, and adoption.
| Trigger Phrase | Operation |
|---|---|
collect agent metrics | Run collect_metrics.py with default 30-day window |
generate metrics dashboard | Run with markdown output for reporting |
check agent adoption rate | Run and highlight Metric 2 (agent coverage) |
weekly metrics report | Run with 7-day window, markdown output |
export metrics as JSON | Run with JSON output for automation |
Use this skill when:
Use manual git log inspection instead when:
| Avoid | Why | Instead |
|---|---|---|
| Running without specifying time window | Default 30 days may not match your intent | Use --since with explicit day count |
| Comparing metrics across different time windows | Misleading trends | Normalize to same window size |
| Ignoring zero agent coverage | Indicates broken detection patterns | Verify commit message conventions match patterns |
| Manual commit counting | Error-prone, misses patterns | Use the script for consistent detection |
| Storing JSON output without markdown | Loses human-readable context | Generate both formats for archival |
After execution:
| Script | Platform | Usage |
|---|---|---|
collect_metrics.py | Python 3.8+ | Cross-platform |
backlog_provenance.py | Python 3.10+, gh | Read-only issue provenance report |
defect_lineage.py | Python 3.10+, git | Check, report, and recheck defect lineage records |
# Basic usage (30 days, summary output)
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/metrics/collect_metrics.py; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
# Last 90 days as markdown
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/metrics/collect_metrics.py --since 90 --output markdown; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
# JSON output for automation
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/metrics/collect_metrics.py --output json; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
# Backlog provenance of issues created in the last 7 days (Markdown)
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/metrics/backlog_provenance.py --days 7; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
# Same report as JSON, for an explicit UTC interval ending 2026-09-29 (exclusive)
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/metrics/backlog_provenance.py --days 29 --until 2026-09-29T00:00:00Z --output-format json; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
# Defect lineage records (this repo keeps them in .project-toolkit/metrics/lineage/):
# validate, report, and recheck against origin/<default_branch> (run git fetch origin first)
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/metrics/defect_lineage.py check <records-dir>; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/metrics/defect_lineage.py report <records-dir>; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/metrics/defect_lineage.py recheck <records-dir>/<id>.json --write; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
# --root belongs to the top-level parser, so it goes before the subcommand
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/metrics/defect_lineage.py --root <repo> recheck <records-dir>/<id>.json --write; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
The utility collects the following metrics:
| Metric | Description | Target |
|---|---|---|
| Metric 1: Invocation Rate | Agent usage distribution | Proportional to task types |
| Metric 2: Agent Coverage | % of commits with agent involvement | 50% |
| Metric 4: Infrastructure Review | % of infra changes with security review | 100% |
| Metric 5: Usage Distribution | Agent utilization patterns | Balanced distribution |
backlog_provenance.py is a read-only diagnostic for the backlog provenance epic. It reads every
issue created in an explicit UTC interval and reports the split by recorded
source:human and source:agent label, plus two labeled heuristics. It does not
score productivity, and it never files, labels, or closes an issue.
human-only, agent-only, conflict (both labels), unknown (neither).area-validation label. Bursts are 3 or more issues by one login within 10 minutes of the first. Both are heuristics, not causal attribution.N/A, or null in JSON.Baseline, reproducible with --days 29 --until 2026-09-29T00:00:00Z (UTC, all issue states, retrieved 2026-09-29): 212 issues created 2026-08-31 through 2026-09-28. All 212 are unknown because no source:* label existed yet on that history. 87 (41.0%) match the machinery heuristic and 16 bursts cover 79 issues. Reconciled against the GitHub search API created:2026-08-31..2026-09-28 count of 212. The earlier epic figure of 405 issues created in 30 days (2026-09-10 snapshot, about 9 in 10 machinery by title) is a historical claim. It used a different title rule and window, so it is not comparable to this run. The weekly cost-governance review cites this script's output.
A later fix makes an old defect vanish from the current tree. A report of only
the current state then loses the evidence of the review race, and a report of
only the old defect calls a fixed problem live. defect_lineage.py keeps the
chain. One JSON record per reviewed chain lives in a records
directory that each command takes as an argument. The schema and its rules are
in the docstring of defect_lineage_record.py.
supports says what the chain shows: defect, review_race, process_gap, or observation. Record planned work with supports: ["observation"] and follow_up.kind: planned_work. A follow-up counts as a defect only when the record says so.CURRENT, FIXED, REVERTED, SUPERSEDED, or UNVERIFIED. It says whether the record's claim holds at the recorded live SHA. REVERTED means the claim holds again after a recorded reverted_by. SUPERSEDED means a recorded superseded_by replaced the chain.recheck reads recheck.path at a revision with git show and matches recheck.pattern. It appends one status_history entry and never deletes the chain. A missing file gives UNVERIFIED, never FIXED. So does a pattern that stops matching when the record has no merged defect_repair follow-up and no superseded_by (for example, the code moved). --rev must be a branch, tag, or SHA: HEAD~1 and main^ are rejected as unsafe with exit 2. An unresolved revision exits 3 and records nothing.report groups records into live, unverified, historical, and observation buckets. Live holds CURRENT and REVERTED. Unverified holds UNVERIFIED. Historical holds FIXED and SUPERSEDED. Observation holds every observation-only record, whatever its status. Only the live bucket holds findings present at the recorded SHA.check rejects contradictory records, including: a review race that did not follow the merge, a repair merged before detection, FIXED without a merged repair, a stored delay that disagrees with the timestamps, and out-of-order history, a follow-up merged before the introduction, and a FIXED history entry dated before the follow-up merged.Exit codes: 0 ok, 1 invalid record, 2 bad path, JSON, or argument, 3 git cannot run or the revision does not resolve.
The utility detects agents in commit messages using these patterns:
orchestrator, analyst, architect, etc.Reviewed by: securityagent: implementer or [security-agent]Infrastructure commits are identified by these patterns:
.github/workflows/*.{yml,yaml}.github/actions/**lefthook and .lefthook configs, with optional -local suffix.config/lefthook configs, with optional -local suffix.yml, .yaml, .json, .jsonc, .tomlbuild/**, scripts/**Dockerfile*docker-compose**.tf, *.tfvars.env*.agents/**Conventional commit prefixes are classified:
feat: - Featurefix: - Bug fixdocs: - Documentationci: - CI/CDrefactor: - RefactoringHuman-readable console output with key metrics highlighted.
Formatted markdown suitable for dashboards and reports. Can be saved directly to .project-toolkit/metrics/ for archival.
Structured data for programmatic consumption and CI integration.
See .github/workflows/agent-metrics.yml for automated weekly metrics collection.
The workflow:
To generate a monthly dashboard report:
# Generate report
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/metrics/collect_metrics.py --since 30 --output markdown > .project-toolkit/metrics/report-$(date +%Y-%m).md; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
# Review and commit
git add .project-toolkit/metrics/
git commit -m "docs(metrics): add monthly metrics report"
docs/agent-metrics.mdcollect_metrics.pyUpdate the AGENT_PATTERNS list to detect new agent references.
Update the INFRASTRUCTURE_PATTERNS list for new infrastructure file types.
Backticked paths below are in the rjmurillo/ai-agents repository. They do not ship with this skill; a consumer install cannot resolve them.
docs/agent-metrics.md. Agent metrics definitions..project-toolkit/metrics/dashboard-template.md. Dashboard template..project-toolkit/metrics/baseline-report.md. Baseline report..github/workflows/agent-metrics.yml. CI workflow.What SKILL.md sets; muted values are Claude Code's defaults
haikuThree short reads, in order
npx claudepluginhub rjmurillo/ai-agents --plugin project-toolkit105 skills in this plugin
/adr-generatorCreate comprehensive Architectural Decision Records (ADRs). Researches the destination directory to detect existing template conventions, gathers context, determines next ADR number, generates the ADR, validates completeness, and saves. Supports multiple ADR formats (MADR, Nygard, Alexandrian, project canonical). Use when documenting technical decisions, creating new ADR files, or capturing rationale so future readers can revisit a choice. Use when you say "write an ADR", "document this decision", "document these design choices", "record why we chose this", "capture the rationale", or "for future maintainers", or when creating an ADR-like markdown file under docs/decisions/, docs/adr/, docs/architecture/, architecture/decisions/, or .project-toolkit/architecture/. Do NOT use to debate or review an existing ADR (use adr-review)./adr-reviewMulti-agent debate orchestration for Architecture Decision Records. Automatically triggers on ADR create/edit/delete. Coordinates architect, critic, independent-thinker, security, analyst, and high-level-advisor agents in structured debate rounds until consensus. Use when you say "review this ADR", when an ADR is created/edited/deleted, or when reviewing, accepting, or updating a decision file under .project-toolkit/architecture/, docs/architecture/, docs/decisions/, docs/adr/, or architecture/decisions/, including intent like "review this decision record" or "check this rationale for future maintainers". Do NOT use to author a new ADR (use adr-generator).Other plugins' skills for the same job