| name | github-metrics-collect-last-month |
| description | Builds ./bin/github-metrics collect commands for the previous calendar month (--start / --end). Use when the user asks for 先月分・前月分の収集, last month's collection command, or dated collect one-liners for this repo. |
github-metrics: 先月分の収集コマンド
定義
先月 = 直前の暦月の 1 日 〜 末日( inclusive )。--start と --end はどちらも YYYY-MM-DD。
手順(エージェント向け)
- 基準日: 会話の
Today's date:(user_info)を最優先。なければユーザー確認 or 実行環境の今日。
- 先月の年月を求める:
- 今日が 1 月なら先月は前年 12 月。
- それ以外は同年の (今月 − 1) 月。
--start: YYYY-(先月)-01
--end: その月の末日(2 月はうるう年判定: 4 で割り切れる && (100 で割り切れない || 400 で割り切れる) なら 29、else 28;4,6,9,11 月は 30、残り 31)。
- 出力は そのままコピペできる 1 行 を優先。org / user は
<org-name> かユーザーが言った値に置換。
コマンド形(このリポジトリ)
Organization(MODE=organization デフォルト):
./bin/github-metrics collect <org-name> --start YYYY-MM-DD --end YYYY-MM-DD
個人(MODE=user):
./bin/github-metrics collect <username> --start YYYY-MM-DD --end YYYY-MM-DD
例(検算用)
- 今日が 2026-04-05 → 先月は 2026-03 →
--start 2026-03-01 --end 2026-03-31
- 今日が 2026-01-10 → 先月は 2025-12 →
--start 2025-12-01 --end 2025-12-31
- 今日が 2024-03-01 → 先月は 2024-02(うるう年)→
--start 2024-02-01 --end 2024-02-29
シェルで日付だけ出す(任意・ユーザー向け)
macOS (BSD date) — 先月の初日・末日:
date -v1d -v-1m +%Y-%m-%d
date -v1d -v-1d +%Y-%m-%d
GNU date (Linux):
date -d "$(date +%Y-%m-01) -1 month" +%Y-%m-%d
date -d "$(date +%Y-%m-01) -1 day" +%Y-%m-%d
組み合わせ例:
START=$(date -v1d -v-1m +%Y-%m-%d)
END=$(date -v1d -v-1d +%Y-%m-%d)
./bin/github-metrics collect showcase-gig-platform --start "$START" --end "$END"
(org 名は環境に合わせて変える。)
やらないこと
- 先月以外の期間に勝手に広げない(「直近30日」≠ 先月)。
- README の別例と矛盾させない: 期間指定は
--start / --end のみで足りるならそれに合わせる。