本文へ移動
cccskills
無料GitHub で公開日本語紹介

deno-script

Cataclysm-BN向けのDeno/TypeScriptスクリプトを、プロジェクトの規約に沿って作成・修正します。CLIや移行処理、コード生成、Gitフックなどの実装を支援します。

原文原文の説明を見る

Write or modify Cataclysm-BN Deno/TypeScript scripts. Use for scripts, tools, migrations, generators, git hooks, and CLI utilities.

cataclysmbn/Cataclysm-BNスター 1,289(GitHub 1,289 + cccskills 0)

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • Deno製のCLIを作りたいとき
  • データ移行スクリプトを書きたいとき
  • コードやドキュメントを生成したいとき
  • Gitフックを追加したいとき

日本語での紹介

できること

Cataclysm-BN向けのDeno/TypeScriptスクリプトを、プロジェクトの既存規約に合わせて作成・修正します。shebangと必要な権限、モジュールの説明コメント、JSRからの依存関係の読み込み、Valibotによる入力検証、Cliffyを使ったCLIなどを扱います。ファイル操作には標準ライブラリを使い、外部コマンドの実行やエラー処理も含めて実装します。移行・変換、開発補助、Gitフック、コードやドキュメントの生成といった用途が対象です。

こんなときに便利

プロジェクトの流儀に沿ったスクリプトを新しく用意したいときや、既存のDenoツールに機能を追加したいときに使えます。スクリプトをCLIとして実行可能にし、権限や検証方法も整えたい場合にも向いています。

使い方の例

  • 「Cataclysm-BNの開発用に、指定したファイルを処理するDenoスクリプトを作って」
  • 「このTypeScriptスクリプトに引数を受け取るCLIを追加して」
  • 「この処理をGitのpre-commitフックとして実装して」

注意点

Deno環境が必要です。完成前に deno check、deno fmt、deno lint などで確認し、実行ファイルとして使う場合は実行権限を付ける手順が示されています。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(1)

  • SKILL.md6.9 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Deno Script Development

Write Deno/TypeScript scripts following Cataclysm: Bright Nights conventions.

Use When

  • "create deno script"
  • "write deno script"
  • "add typescript script"
  • "new deno tool"

Required Conventions

1. Shebang and Permissions

Start scripts with the proper shebang and required permissions:

#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run --allow-env

Common permission flags:

  • --allow-read - File system read access
  • --allow-write - File system write access
  • --allow-run - Run subprocesses
  • --allow-env - Access environment variables
  • --allow-net - Network access (only if needed)

2. Module Documentation

Add a module-level JSDoc comment explaining the script's purpose:

/**
 * @module
 *
 * Brief description of what this script does
 *
 * Longer explanation if needed with examples or usage notes.
 */

This pattern is used in existing scripts like:

  • scripts/gen_cli_docs.ts
  • scripts/utils.ts
  • scripts/affected_files.ts

3. Import Conventions

Use JSR imports for standard library and well-known packages:

import { Command } from "@cliffy/command"
import { exists } from "@std/fs"
import { join } from "@std/path"
import { partition } from "@std/collections"
import * as v from "@valibot/valibot"

DO NOT use npm or http imports unless absolutely necessary. Prefer JSR.

4. Validation with Valibot

For data validation, use Valibot (NOT Zod):

import * as v from "@valibot/valibot"

const MySchema = v.object({
  name: v.string(),
  count: v.pipe(v.number(), v.minValue(0)),
  tags: v.array(v.string()),
})

type MyType = v.InferOutput<typeof MySchema>

const parser = v.safeParser(MySchema)
const result = parser(data)
if (result.success) {
  const validated = result.output
}

5. CLI with Cliffy

For command-line interfaces, use Cliffy:

import { Command } from "@cliffy/command"

const main = new Command()
  .name("script-name")
  .version("1.0.0")
  .description("What this script does")
  .option("-o, --output <file>", "Output file path")
  .arguments("<input:string>")
  .action(async ({ output }, input) => {
    // Implementation
  })

if (import.meta.main) {
  await main.parse(Deno.args)
}

6. File Operations

Use @std/fs for file system operations:

import { exists, walk } from "@std/fs"
import { basename, join } from "@std/path"

if (await exists("path/to/file")) {
  const content = await Deno.readTextFile("path/to/file")
}

for await (const entry of walk("src", { exts: [".ts"] })) {
  console.log(entry.path)
}

7. Running Commands

Use Deno.Command for subprocesses:

const cmd = new Deno.Command("git", {
  args: ["status"],
  stdout: "piped",
  stderr: "piped",
})

const { success, stdout, stderr } = await cmd.output()
if (success) {
  const output = new TextDecoder().decode(stdout)
}

8. Error Handling

Handle errors with proper types:

try {
  await someOperation()
} catch (error) {
  const message = error instanceof Error ? error.message : String(error)
  console.error(`Error: ${message}`)
  Deno.exit(1)
}

9. Color Output

Define colors as utility functions:

const colors = {
  red: (text: string) => `\x1b[31m${text}\x1b[0m`,
  yellow: (text: string) => `\x1b[33m${text}\x1b[0m`,
  green: (text: string) => `\x1b[32m${text}\x1b[0m`,
  dim: (text: string) => `\x1b[2m${text}\x1b[0m`,
}

console.log(colors.green("Success!"))
console.warn(colors.yellow("[WARNING] Something happened"))
console.error(colors.red("[ERROR] Failed"))

Example Scripts to Reference

Look at these existing scripts for patterns:

  1. CLI Tool: scripts/gen_cli_docs.ts
    • Shows proper shebang, module docs, CLI parsing
  2. Data Processing: scripts/utils.ts
    • Shows Valibot usage, type utilities
  3. GitHub API: scripts/affected_files.ts
    • Shows async iteration, external API calls
  4. Git Hooks: tools/hooks/pre-commit.ts
    • Shows command execution, file categorization
  5. Installer: tools/hooks/install-hooks.ts
    • Shows user interaction, file manipulation

Project Structure

Scripts location:

  • General utilities: scripts/
  • Build/development tools: tools/
  • Git hooks: tools/hooks/

Testing

Before submitting:

deno check your-script.ts
deno fmt your-script.ts
deno lint your-script.ts

Make the script executable:

chmod +x your-script.ts

Documentation

Add to deno.jsonc tasks if the script should be easily runnable:

{
  "tasks": {
    "your-task": "deno run --allow-... scripts/your-script.ts"
  }
}

Must Do

  1. ALWAYS start with shebang: #!/usr/bin/env -S deno run [permissions]
  2. ALWAYS add @module JSDoc comment
  3. ALWAYS use Valibot for validation (NOT Zod)
  4. ALWAYS prefer JSR imports over npm/http
  5. ALWAYS use Cliffy for CLI interfaces
  6. ALWAYS check with deno check before considering complete
  7. ALWAYS make script executable (chmod +x)
  8. ALWAYS use if (import.meta.main) guard for executable scripts

Must Not Do

  1. NEVER use Zod (use Valibot)
  2. NEVER use npm: imports (use jsr:)
  3. NEVER forget to add required permissions in shebang
  4. NEVER commit without running deno check and deno fmt
  5. NEVER use @ts-ignore or @ts-expect-error
  6. NEVER leave scripts non-executable

Common Patterns

Check if Command Exists

const commandExists = async (cmd: string): Promise<boolean> => {
  try {
    const process = new Deno.Command("command", {
      args: ["-v", cmd],
      stdout: "piped",
      stderr: "piped",
    })
    const { success } = await process.output()
    return success
  } catch {
    return false
  }
}

Get Git Repository Root

const getRepoRoot = async (): Promise<string> => {
  const cmd = new Deno.Command("git", {
    args: ["rev-parse", "--show-toplevel"],
    stdout: "piped",
  })
  const { stdout } = await cmd.output()
  return new TextDecoder().decode(stdout).trim()
}

Read JSON Files Recursively

import { walk } from "@std/fs"

for await (const entry of walk("data", { exts: [".json"] })) {
  const content = await Deno.readTextFile(entry.path)
  const data = JSON.parse(content)
  // Process data
}

Parallel Async Operations

const results = await Promise.all([
  operation1(),
  operation2(),
  operation3(),
])

When to Write a Deno Script

Use Deno scripts for:

  • Data migration/transformation
  • Build automation
  • Development tools
  • Git hooks
  • Code generation
  • Documentation generation
  • CLI utilities

Don't use Deno scripts for:

  • Core game logic (use C++)
  • Performance-critical operations (use C++)
  • Things that should be in-game (use Lua bindings)

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

add-lua-binding-api

無料概要あり

Cataclysm-BNのC++側で、ゲーム機能や定数、コールバックなどをLuaから呼び出せるAPIとして登録するスキルです。

  • Luaからマップ操作を呼び出したいとき
  • Lua APIに定数を追加したいとき
  • Luaからコールバックを登録したいとき
cataclysmbn/Cataclysm-BN1,2892026年10月27日 更新

add-lua-binding-complex

無料概要あり

複雑なC++クラスをLuaから利用できるように、メソッドや継承、プロパティ、演算子、オブジェクトの所有権を含むバインディングの追加を支援します。

  • C++クラスをLuaに公開したいとき
  • 継承を含むバインディングを追加したいとき
  • Lua向けのプロパティや演算子を登録したいとき
cataclysmbn/Cataclysm-BN1,2892026年10月27日 更新

add-lua-binding-simple

無料概要あり

C++の`string_id`や列挙型、読み取り専用の基本型をLuaへ公開するためのバインディング追加手順を示し、登録と動作確認を支援します。

  • C++のID型をLuaに公開したいとき
  • 列挙型をLuaスクリプトで使いたいとき
  • 基本クラスの読み取り専用バインディング追加
cataclysmbn/Cataclysm-BN1,2892026年10月27日 更新

changelog-gen

無料概要あり

Gitの指定範囲に含まれる変更を調べ、英語・韓国語・日本語のゲーム更新履歴を作成・同期します。プレイヤー向けの項目整理や画像・動画の掲載にも対応します。

  • Gitの差分から更新履歴を作りたいとき
  • 複数言語のリリースノートを整えたいとき
  • 関連する変更をまとめて掲載したいとき
cataclysmbn/Cataclysm-BN1,2892026年10月27日 更新

i18n-context

無料概要あり

同じ英語文字列が文脈によって異なる意味になる場合に、gettextの文脈情報を追加し、対象言語のPO翻訳を修正するスキルです。

  • 同じラベルを用途ごとに訳し分けたいとき
  • JSON翻訳に文脈を加えたいとき
  • PO翻訳を更新して検証したいとき
cataclysmbn/Cataclysm-BN1,2892026年10月27日 更新

lua-binding-reference

無料概要あり

Cataclysm-BNのLuaバインディング実装で使うLunaマクロ、型登録、ライブラリ、ビルド手順やよくあるエラーを調べるリファレンスです。

  • Lua向けの型登録方法を確認したいとき
  • オーバーロード関数を登録したいとき
  • バインディングのビルドエラーを調べたいとき
cataclysmbn/Cataclysm-BN1,2892026年10月27日 更新

cataclysmbn のスキルをすべて見る

このスキルの問題を報告する