skillZs
★ LIVE SKILL TAGS ★
>>> LIVE SKILLS INDEX <<<
* OPEN SOURCE *
NO LOGIN, NO TRACKING
※ REAL INSTALL DATA ※
← back to all skills
taiki-kuraishi/skill128 installs

kstack-vite-plus

Vite+(vite-plus パッケージ、vp・vpr コマンド)を使うリポジトリで、lint・format・型検査・test・build などのコマンドを書く・修正する・レビューするときの規約。コマンドを直接呼ばず vite.config.ts の run.tasks に定義して vp run 経由で実行し、Vite Task のキャッシュに乗せること、キャッシュから外すコマンド、キャッシュする task に渡す環境変数、run.cache の設定、CI(GitHub Actions)で node_modules/.vite/task-cache を復元することを扱う。package.json の scripts や CI の workflow へのコマンドの追加、CI の高速化、レビュー指摘への対応でも発火させる。

How do I install this agent skill?

npx skills add https://github.com/taiki-kuraishi/skill --skill kstack-vite-plus
view source ↗

Is this agent skill safe to install?

  • Gen Agent Trust Hubpass

    The skill provides guidelines for configuring the Vite+ build tool and CI workflows. It can run commands on build agents and manage remote deployments through CLI tools, so use credentials with limited scope.

  • Socketpass

    No alerts

  • Snykwarn

    Risk: MEDIUM · 2 issues

What does this agent skill do?

kstack-vite-plus

Vite+ を書くときの規約。理由を理解した上で適用すること。

コマンドは vp run 経由で実行し、キャッシュに乗せる

lint・format・型検査・test・build などのコマンドは vite.config.ts の run.tasks に定義し、CI でも手元でも vp run <task> で実行する。キャッシュは既定のまま効かせる。

// vite.config.ts
import { defineConfig } from "vite-plus";

export default defineConfig({
  run: {
    tasks: {
      lint: "oxlint --deny-warnings",
      "fmt-check": "oxfmt --check",
      "type-check": "tsc --noEmit",
      test: "vp test",
      build: "vp build",
      deploy: { command: "wrangler deploy", cache: false },
    },
  },
});
# Bad: 直接呼ぶと Vite Task のキャッシュを通らない
- run: bun oxlint --deny-warnings
- run: bun tsc --noEmit
- run: bun vp build

# Good
- run: bun vp run lint
- run: bun vp run type-check
- run: bun vp run build

なぜ: Vite Task のキャッシュが効くのは vp run で実行したコマンドだけで、直接呼ぶと入力が前回と同じでも毎回実行される。vp run は、コマンドが読んだファイル・引数・指定した環境変数が前回の成功時と同じなら、出力と書き出したファイルを再生して実行を飛ばす。

キャッシュを外す(cache: false)のは、deploy・migration のように実行のたびに外部へ作用するコマンドと、dev server のように終わらないコマンドだけにする。キャッシュが hit するとコマンドは走らずに成功扱いになり、外部への作用が起きないため。

キャッシュする task は、PATH・HOME・CI など一部を除いて環境変数を消した状態で動き、宣言していない環境変数は未設定に見える。コマンドが読む環境変数は、値で結果が変わるなら cache.env、変わらないなら cache.untrackedEnv に書く(vite-plus 1.0 より前は task 直下の env・untrackedEnv)。

package.json の scripts は既定ではキャッシュされない(⊘ cache disabled)。scripts のまま回すなら root の vite.config.ts で run.cache を { scripts: true, tasks: true } にし、外部へ作用する script は cache: false の task に移す。

CI では task-cache を依存の install の後に復元する

CI の runner は毎回まっさらな状態で始まるので、vp run にしただけではキャッシュが毎回空になる。node_modules/.vite/task-cache を依存の install の後に復元し、検査の後に保存する。restore・save は kstack-github-actions の「キャッシュの restore・save は composite action に切り出す」のとおり、1 つの composite action を mode で切り替えて呼ぶ。

# job(setup-bun は依存の install までを持つ composite action)
- uses: ./.github/actions/setup-bun
- uses: ./.github/actions/vite-task-cache
  with:
    mode: restore
- run: bun vp run lint
- if: success()
  uses: ./.github/actions/vite-task-cache
  with:
    mode: save
# .github/actions/vite-task-cache/action.yml の steps(name・description・inputs は省略)
- if: inputs.mode == 'restore'
  uses: actions/cache/restore@v6
  with:
    path: node_modules/.vite/task-cache
    key: vite-task-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
    restore-keys: vite-task-${{ runner.os }}-${{ runner.arch }}-
- if: inputs.mode == 'save'
  uses: actions/cache/save@v6
  with:
    path: node_modules/.vite/task-cache
    key: vite-task-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
- if: inputs.mode != 'restore' && inputs.mode != 'save'
  shell: bash
  run: exit 1

なぜ: install は node_modules を作り直しうるので、復元はその後に置く。GitHub の cache は同じ key に上書きできないので key は run ごとに変え、入力の変化は Vite Task が task ごとに判定するので lockfile やソースの hash は key に入れない(key で絞ると、hit できた task の分まで復元されなくなる)。

Vite+ はこの復元を実験的な機能としている。入れるときは、restore・save にかかる時間と、vp run が出す cache hit, ... saved の短縮分を比べる。

Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.

<a href="https://skillzs.dev/skills/taiki-kuraishi/skill/kstack-vite-plus">View kstack-vite-plus on skillZs</a>