Skip to content
cccskills
FreePublished on GitHub

shift-planner

従業員リスト(勤務可能時間帯・曜日・資格等の制約条件付き)と人員要件(作業室×曜日×時間帯の必要人員)を入力として、 個人別シフトを自動編成するスキル。

制約充足型 Greedy Assignment アルゴリズムにより、 ハード制約(労働時間上限、連続勤務制限、休息時間、資格マッチング)を遵守しつつ、 公平性(週末均等配分、時間偏差)を考慮したシフト表を生成する。カバレッジ検証(30分刻み)と公平性レポートも自動出力。

Use when: 「シフトを作成」「従業員のシフト編成」「勤務表を自動生成」 「人員配置のシフト計画」「週次シフトスケジュール」「shift schedule」

The English summary is being prepared. Showing the original description.

See how to install

Files included (10)

  • SKILL.md11.0 KB
  • assets/sample_requirements.csv393 B
  • assets/sample_roster.csv783 B
  • assets/sample_shift_patterns.csv261 B
  • assets/shift_output_template.md845 B
  • references/labor_constraints_guide.md2.9 KB
  • references/shift_planning_methodology.md3.8 KB
  • scripts/generate_shifts.py38.2 KB
  • scripts/tests/__init__.py0 B
  • scripts/tests/test_generate_shifts.py29.5 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Shift Planner

Overview

従業員リスト(roster)と人員要件(requirements)を入力として、制約充足型 Greedy Assignment で個人別シフトを自動編成するスキル。 production-schedule-optimizer の出力(人員要件)を活用可能だが、単体でも汎用的なシフト計画ツールとして動作する。

Primary language: Japanese (default), English supported Algorithm: Constraint-Satisfaction Greedy Assignment (difficulty-first slot ordering) Output format: Markdown report (shift table, coverage matrix, fairness report, alerts) Dependencies: None (Python standard library only)


When to Use

  • 従業員の個人別シフト表を自動生成したい
  • 勤務可能曜日・時間帯・資格などの制約を考慮したシフト編成が必要
  • production-schedule-optimizer で算出した人員要件に基づくシフト計画を立てたい
  • シフトのカバレッジ(時間帯別充足状況)を検証したい
  • 従業員間の公平性(労働時間偏差、週末シフト配分)を分析したい
  • 監督者配置要件を含むシフト計画が必要

Prerequisites

  • Python 3.9+
  • 外部依存なし(標準ライブラリのみ: csv, math, argparse, dataclasses)
  • 入力CSVはUTF-8エンコーディング

Limitations

  • 深夜跨ぎシフト非対応: start_hour >= end_hour のパターンは SFT-E004 で Reject
  • 週単位: 月・年単位のスケジューリングは対象外
  • 1日1シフト: 同一従業員の同日複数シフトは未対応

Output

  • 形式: Markdown レポート(4セクション構成)
  • 内容:
    1. シフト割当表(曜日別)
    2. カバレッジマトリクス(30分刻み)
    3. 公平性レポート(従業員別)
    4. アラート一覧

Input Specification

3種類のCSVファイルを入力として受け取る(シフトパターンは任意)。

1. roster.csv — 従業員リスト

ColumnTypeRequiredDescription
employee_idstringYes一意の従業員ID(例: EMP-001)
namestringYes表示名
available_daysstringYes勤務可能曜日(セミコロン区切り: MON;TUE;WED)
max_hours_weekfloatYes週最大労働時間
max_days_weekintYes週最大勤務日数
qualificationsstringYes対応可能な作業室コード(セミコロン区切り)
is_supervisorintYes監督者=1, それ以外=0
preferred_patternsstringNo希望シフトパターン(セミコロン区切り, 空=制限なし)
avoid_daysstringNo回避希望曜日(ソフト制約, セミコロン区切り)
contract_hoursfloatNo契約時間(デフォルト=max_hours_week, 公平性計算用)

2. requirements.csv — 人員要件

ColumnTypeRequiredDescription
daystringYes曜日コード(MON-SUN)
room_codestringYes作業室コード
required_staffintYes必要人員数
start_hourfloatNo稼働開始(デフォルト 8.0)
end_hourfloatNo稼働終了(デフォルト 17.0)
need_supervisorintNo監督者必須=1(デフォルト 1)

3. shift_patterns.csv — シフトパターン定義(任意)

ColumnTypeRequiredDescription
pattern_idstringYesパターンID(例: FULL_8H)
namestringYes表示名
start_hourfloatYes開始時刻
end_hourfloatYes終了時刻
break_startfloatNo休憩開始(空=休憩なし)
break_endfloatNo休憩終了
net_hoursfloatYes実労働時間

未指定時はビルトインの5パターン(FULL_8H / EARLY_8H / LATE_8H / SHORT_6H / HALF_4H)を使用。

Sample files: assets/sample_roster.csv, assets/sample_requirements.csv, assets/sample_shift_patterns.csv


Workflow 1: Shift Generation

Purpose: 制約充足型 Greedy Assignment で個人別シフトを自動編成する。

Phase 1: Slot Priority Sort

  • (day, room) ごとの要件を「充足困難度」でソート
  • 困難度 = required_staff / 有資格従業員数(高い=先に割当)
  • タイブレーク: DAY_ORDER index → room_code ASC

Phase 2: Greedy Assignment Loop

各スロットについて:

  1. 候補フィルタ (is_eligible): ハード制約チェック

    • available_days, qualifications, max_hours, max_days, 連続勤務, 休息時間
  2. 優先度スコア (compute_priority_score): 固定重み式

    score = -(remaining_hours * 10)     # 契約残余多い=優先
            + (weekend_shifts * 20)      # 週末バランス
            + (avoid_penalty * 50)       # 回避曜日ペナルティ
            - (supervisor_bonus * 100)   # 監督者ボーナス
            - (speciality * 5)           # 資格専門度
            + (preference_miss * 30)     # 希望パターン不一致
    

    タイブレーク: score ASC → employee_id ASC(完全決定性)

  3. パターン選択 (select_pattern): ソートキー = (希望一致, -カバー時間, pattern_id ASC)

  4. 割当 + 状態更新: hours_assigned, days_assigned, last_shift_end を更新

  5. 監督者チェック: need_supervisor=1 の場合、監督者不在なら SFT-W002

Phase 3: Coverage Verification

  • 30分刻みで assigned >= required を検証
  • 休憩時間中は on_duty から除外

Phase 4: Fairness Metrics

  • 従業員別: 実労働時間, 契約時間差分, 勤務日数, 週末シフト数, 回避曜日違反数
  • 全体: 週末シフト標準偏差 → SFT-W009 (>1.0)

Detail: Load references/shift_planning_methodology.md for algorithm details.


Workflow 2: Validation & Alerts

Purpose: 入力データと生成結果の品質検証。

Error (SFT-E): Processing Stops

CodeTriggerDescription
SFT-E001max_hours_week <= 0週労働時間が無効
SFT-E002max_days_week <= 0週勤務日数が無効
SFT-E003net_hours <= 0(パターン)パターン実労働時間が無効
SFT-E004start_hour >= end_hour(パターン)深夜跨ぎ非対応
SFT-E005required_staff <= 0(要件)必要人員が無効
SFT-E006room_code に有資格者ゼロ(静的)構造的に充足不可能
SFT-E007有効パターンゼロ全パターンが無効
SFT-E008employee_id 重複従業員ID重複

Warning (SFT-W): Processing Continues

CodeTriggerDescription
SFT-W001カバレッジギャップassigned < required
SFT-W002監督者不在need_supervisor=1 なのに未配置
SFT-W003回避曜日に割当ソフト制約違反
SFT-W004時間偏差 > 4h公平性警告
SFT-W005割当ゼロの従業員遊休
SFT-W006連続勤務日数超過事後監査
SFT-W007シフト間休息時間不足事後監査
SFT-W008候補ゼロ(動的)当日制約で割当不可
SFT-W009週末シフト標準偏差 > 1.0週末不公平
SFT-W010max_hours_week 到達時間上限で未充足

Detail: Load references/labor_constraints_guide.md for labor law considerations.


Scripts

generate_shifts.py

python3 skills/shift-planner/scripts/generate_shifts.py \
  --roster roster.csv \
  --requirements requirements.csv \
  --patterns shift_patterns.csv \
  --week-start 2026-02-23 \
  --max-consecutive-days 6 \
  --min-rest-hours 11 \
  --output shifts.md
FlagRequiredDefaultDescription
--rosterYes-従業員リスト CSV
--requirementsYes-人員要件 CSV
--patternsNoビルトイン5パターンシフトパターン CSV
--week-startYes-週開始日(YYYY-MM-DD, 表示専用)
--max-consecutive-daysNo6最大連続勤務日数
--min-rest-hoursNo11.0シフト間最小休息時間(時間)
--outputNostdout出力先(Markdown)

Built-in Shift Patterns

PatternStartEndBreakNet Hours
FULL_8H08:0017:0012:00-13:008.0h
EARLY_8H06:0015:0011:00-12:008.0h
LATE_8H10:0019:0014:00-15:008.0h
SHORT_6H08:0014:00None6.0h
HALF_4H08:0012:00None4.0h

Resources

references/

FileDescriptionWhen to Load
shift_planning_methodology.mdアルゴリズム詳細、スコアリング重み、改善手法アルゴリズム理解・改善時
labor_constraints_guide.md労働法制約、休憩規則、連続勤務制限労働制約検討時

assets/

FileDescription
sample_roster.csv従業員リストサンプル(8名)
sample_requirements.csv人員要件サンプル(7日×2室)
sample_shift_patterns.csvシフトパターンサンプル
shift_output_template.md出力テンプレート

Best Practices

入力データ準備

  1. 従業員ID命名: 部門+連番(EMP-001, SUP-001)で管理性向上
  2. 資格コード: production-schedule-optimizer の room_code と一致させる
  3. 契約時間: 公平性計算の基準。max_hours_week と異なる場合は明示的に指定

シフト最適化

  1. 困難スロット優先: アルゴリズムが自動処理(有資格者少ないスロット=先に割当)
  2. 監督者確保: is_supervisor=1 の従業員を十分に配置
  3. 週末公平配分: W_WEEKEND 重みで自然に分散、W009 で検知
  4. 回避曜日: ソフト制約として考慮、やむを得ない場合は W003 で通知

production-schedule-optimizer との連携

  1. estimate_staff.py の recommended 値を requirements.csv の required_staff に転記
  2. room_code を一致させる
  3. start_hour / end_hour は PSO の稼働時間帯に合わせる

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Track and update action item status from natural language updates like 'Seanのメールには返信しておいた' or 'Lu対応予定'. Integrates with daily-comms-ops workflow. Use when managing action items across communication channels.

The English summary is being prepared. Showing the original description.

takusaotome/claude-skills-library10Updated Oct 5, 2026

AI活用提案の専門コンサルタントスキル。LLM・AIエージェントの活用事例知識を基に、業界別、部門別、シーン別に最適なAI導入提案を行います。システム化、業務改善、効率化を得意とし、具体的な活用事例、期待効果、導入ステップを含む実践的な提案を提供します。Use when proposing AI/LLM adoption strategies for specific industries, departments, or business scenarios.

The English summary is being prepared. Showing the original description.

takusaotome/claude-skills-library10Updated Oct 5, 2026

Generate AI-powered BPO service proposals for Japanese companies in the US market. Use when creating outsourcing proposals with AI service menus, ROI estimation, implementation roadmaps, and bilingual (JA/EN) proposal documents for 在米日系企業向けAI実装.

The English summary is being prepared. Showing the original description.

takusaotome/claude-skills-library10Updated Oct 5, 2026

AI(LLM)が生成した日本語テキストの「AI臭」を検出・診断し、人間らしい文章にリライトするスキル。 Use when: 「AIっぽい文章を直して」「人間らしくリライトして」「AI臭を消して」「この文章をもっと自然にして」 「テキストのAI感を減らして」「機械っぽさを取りたい」 "make this sound more human", "remove AI tone", "humanize this text", "detect if this is AI-generated". 6つのAI特有パターン(視覚的マーカー、単調なリズム、マニュアル的構成、非コミット姿勢、抽象語の濫用、 定型メタファー)を正規表現ベースで検出し、0-100のAI臭スコアを算出。3つの人間化技法 (バランスを崩す・客観を崩す・論理を崩す)でリライトを実行する。 Note: 検出スクリプトは日本語テキスト専用。英語テキストの場合はClaude自身がreferences/を参照して分析・リライトする。

The English summary is being prepared. Showing the original description.

takusaotome/claude-skills-library10Updated Oct 5, 2026

Generate audit-ready internal control design documents from As-Is business process inventories. Produces control IDs, assertion mappings, procedures, SoD analysis, KPIs, materiality thresholds, and implementation roadmaps. Use when building internal controls for new audit engagements, SOX/J-SOX compliance, or process improvement initiatives.

The English summary is being prepared. Showing the original description.

takusaotome/claude-skills-library10Updated Oct 5, 2026

Review audit-related documents (control design documents, bottleneck analyses, requirements definitions, etc.) for quality, scoring them 0-100 with a severity-rated findings list. Use when reviewing audit documents, checking control design quality, or verifying cross-document consistency. Supports documents governed by US GAAP, IFRS, or J-GAAP.

The English summary is being prepared. Showing the original description.

takusaotome/claude-skills-library10Updated Oct 5, 2026

See all skills by takusaotome

Report a problem with this skill