metric-source-attribution
Skill0 starsChanged 5 months agoMITView on GitHub
自動スクリプトが数値・率・件数を出力する際、必ず「何を数えたか」のソース/分母ラベルをセットで出力するパターン。hot.md 2026-08-22 主題「数字は立っているが何のものか誰も言えない」から抽出。取得率/成功件数/フォロバ率など全種類に適用。
In this repository99 other files it gives its agents.
- agents-tools-quoted-jsonSkill
- asc-api-app-store-submitSkill
- asd-ste100Skill
- automation-bool-selector-pitfallsSkill
- automation-stale-cooldown-flagSkill
- autonomous-build-verifySkill
- book-to-skillSkill
- ccusage-cli-cost-trackingSkill
- chrome-ext-mv3-programmatic-injectSkill
- chrome-ext-store-assetsSkill
- claude-headless-p-invocationSkill
- claude-plugin-context-auditSkill
- claude-session-log-to-kbSkill
- cloudflare-workers-do-deploySkill
- codebase-to-courseSkill
- codesign-keychain-prompt-fixSkill
- codex-cli-setupSkill
- codex-delegation-handoffSkill
- content-factory-grounding-dedupSkill
- conversation-log-append-patternSkill
- cron-to-launchd-macosSkill
- cross-automation-shared-resource-killSkill
- design-token-migration-rnSkill
- discord-bot-image-to-claudeSkill
- discord-gateway-resume-dedupSkill
- excel-filtered-url-http-auditSkill
- execution-budget-vs-capsSkill
- expo-free-local-ios-testflightSkill
- ga4-connect-projectsSkill
- gcal-oauth-desktop-setupSkill
- git-commit-helperSkill
- git-prepush-secret-remote-checkSkill
- gsc-cli-automationSkill
- hatena-blogsync-autopostSkill
- hook-latency-wrapSkill
- hook-log-append-patternSkill
- html-to-pdf-slide-deckSkill
- humanizerSkill
- human-review-gate-shellSkill
- implementation-model-routingSkill
- insights-to-claude-mdSkill
- ios-permission-key-security-matrixSkill
- ios-sim-store-screenshotsSkill
- launchd-exit78-exconfig-debugSkill
- llm-content-pipeline-quality-gateSkill
- local-ai-video-pipelineSkill
- local-flux-mflux-image-genSkill
- local-llm-slow-diagnosisSkill
- local-music-generationSkill
- lottie-skottie-authoring-pitfallsSkill
- machine-wide-api-ratelimit-latchSkill
- macos-hook-path-timeoutSkill
- md-to-docx-reportSkill
- memory-md-inject-bloat-auditSkill
- message-display-secrets-maskSkill
- migrate-icloud-desktop-assetsSkill
- nextauth-local-e2e-sessionSkill
- nextjs-rsc-payload-slimSkill
- nothing-designSkill
- openclaw-ollama-setupSkill
- The first 60 shown.
The file
Files
問題
自動スクリプトが数値・率を出力する際に「何を分母にしたか」「どのデータソースから計算したか」を省略すると、その数値は後続作業で参照できない。
実例(hot.md 2026-08-22 窓から)
| 出力値 | 問題 |
| 取得率 100% | 何を取得したのか不明。対象リストが空だった可能性 |
| 相場 0円 | どの API / テーブルから取得したか不明。ソースが 0件返却 |
| 成功 6件 | 全何件中の 6件か不明。エラー0件と区別できない |
| フォロバ率 1.0% | 分母がフォロワー全体か直近フォローか不明 |
| 学習サンプル N件 | どのフィルタを通過したデータか不明 |
全て「数値は正しく計算されている」が「何のための数値か言えない」状態。
パターン
NG(数値のみ)
print(f"成功: {success_count}件")
print(f"取得率: {rate:.1%}")OK(ソース・分母をセット)
print(f"成功: {success_count}件 / 全{total_count}件 (source: {table_name})")
print(f"取得率: {rate:.1%} (分母: candidates={len(candidates)}, フィルタ: {filter_desc})")OK(構造化出力)
result = {
"success": success_count,
"total": total_count,
"source": "orders WHERE status='complete' AND date=today",
"rate": success_count / total_count if total_count else None,
"rate_denominator": "total発注件数",
}
print(json.dumps(result, ensure_ascii=False))チェックリスト
スクリプトを書いたら以下を確認する:
count/件数を出力 → 分母(total/全N件)が隣にあるrate/率/%を出力 → 分母の定義文字列(例: "直近フォローアカウント")が付く- 外部 API から価格・数量を取得 → どの endpoint/table かが出力に含まれる
- フィルタを通した件数 → フィルタ条件の要約が付く
- 「0件」「0円」など zero を出力 → ソースが返した件数も付ける(空リスト vs APIエラーを区別)
実装パターン集
ラッパー関数(Python)
def report(label: str, value, total=None, source: str = ""):
"""常にソース付きで出力する。"""
parts = [f"{label}: {value}"]
if total is not None:
parts.append(f"/ 全{total}")
if source:
parts.append(f"(source: {source})")
print(" ".join(parts))
# 使用例
report("成功", success, total=len(orders), source="orders table")
report("フォロバ率", f"{rate:.1%}", total=followed_count, source="follower_events last 7d")ログ形式(bash)
log_metric() {
local label="$1" value="$2" total="$3" source="$4"
echo "[METRIC] ${label}: ${value} / ${total:-?} (src: ${source:-unknown})"
}
log_metric "success" "$success_count" "$total_count" "DB orders table"
log_metric "price" "${price}円" "market API" "Yahoo Finance endpoint"Pitfalls
- 0件・0円を「成功」と誤認: ソースが空リストを返した場合も取得率100%になる。
len(source_list)も出力して区別する。 total=0除算エラー: rate 計算前にif total == 0: return Noneして出力に"(分母=0, 計算不可)"を付ける。- 分母の定義ズレ: 「フォロバ率」の分母が実装者によって「全フォロワー」と「直近フォロー」で異なる。定義を文字列で出力に埋める。
- 外部ソース変更を見逃す: API endpoint が変わって 0件返却でもエラーにならない場合がある。
source_countを常にログに出す。 - ログレベルが高すぎて埋もれる: metric 出力は
INFOではなく専用プレフィックス[METRIC]を使い grep できるようにする。
Verification
# スクリプト内の数値出力に source/分母が付いているか確認
grep -n "print\|echo\|log" your_script.py | grep -v "source\|total\|分母\|src" | grep -E "[0-9]件|[0-9]%|rate|count"
# → 残ったものが attribution 欠けの候補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.

