mcpField
T
taskfiles

taskfiles

github.com/ionfury開発2571 回インストール今日更新
リポジトリ

taskfiles について

Taskfile.yaml や関連ファイルを保守する開発者向けに、Taskfiles の作成方法をまとめたスキルです。名前空間付きの include、ワイルドカードタスク、依存関係、前提条件、動的変数のパターンを扱います。

主な機能

  1. 01Taskfile テンプレートの標準化
  2. 02名前空間付きタスクファイルの include
  3. 03ワイルドカードタスクと依存関係の設定
  4. 04内部ヘルパータスクの定義
  5. 05動的変数とループの利用

活用シーン

  1. 01リポジトリに名前空間付きタスクファイルを追加
  2. 02引数付きタスクコマンドの作成
  3. 03タスクの前提条件と並列依存関係の設定

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/ionfury/homelab --skill taskfiles

インストール後、Claude Code で/taskfilesを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

tests.yaml
references/
cli.md
schema.md
styleguide.md
task-catalog.md

詳細

Taskfile

リポジトリ構造

Taskfile.yaml                    # Root: includes namespaced taskfiles
.taskfiles/
├── inventory/taskfile.yaml      # inv: IPMI host management
├── terragrunt/taskfile.yaml     # tg: Infrastructure operations
├── worktree/taskfile.yaml       # wt: Git worktree management
└── renovate/taskfile.yaml       # renovate: Config validation

ファイルテンプレート

スキーマとバージョンを必ず含めます:

---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"

vars:
  MY_DIR: "{{.ROOT_DIR}}/path"

tasks:
  my-task:
    desc: Short description for --list output.
    cmds:
      - echo "hello"

パターン

新しい Taskfile を追加する

ルートの Taskfile.yaml に追加します:

includes:
  namespace: .taskfiles/namespace
ワイルドカードタスク

パラメーター化された操作に使用します:

plan-*:
  desc: Plans a specific terragrunt stack.
  vars:
    STACK: "{{index .MATCH 0}}"
  label: plan-{{.STACK}}
  cmds:
    - terragrunt plan --working-dir {{.INFRASTRUCTURE_DIR}}/stacks/{{.STACK}}
  preconditions:
    - which terragrunt
    - test -d "{{.INFRASTRUCTURE_DIR}}/stacks/{{.STACK}}"
依存関係

cmds の前に、依存タスクを並列で実行します:

apply-*:
  deps: [use, fmt]
  cmds:
    - terragrunt apply ...
内部ヘルパータスク
ipmi-command:
  internal: true
  silent: true
  requires:
    vars: [HOST, COMMAND]
  cmds:
    - ipmitool ... {{.COMMAND}}
事前条件
preconditions:
  - which required-tool
  - test -d "{{.PATH}}"
  - sh: test "{{.VALUE}}" != ""
    msg: "VALUE cannot be empty"
ソースの追跡
fmt:
  sources:
    - "{{.DIR}}/**/*.tf"
  generates:
    - "{{.DIR}}/**/*.tf"
  cmds:
    - tofu fmt -recursive
動的変数と For ループ
vars:
  VALID_HOSTS:
    sh: "cat {{.INVENTORY_FILE}} | yq -r '.hosts | keys[]'"

power-status:
  cmds:
    - for: { var: VALID_HOSTS }
      cmd: task inv:status-{{.ITEM}}
CLI 引数
new:
  requires:
    vars: [CLI_ARGS]
  vars:
    NAME: "{{.CLI_ARGS}}"
  cmds:
    - git worktree add ... -b "{{.NAME}}"

使用方法:task wt:new -- feature-branch

参考資料

コメント