본문으로 건너뛰기
cccskills
무료GitHub에 공개

deno-script

Create or update Deno and TypeScript scripts for Cataclysm-BN, following the project’s conventions. Use it for command-line tools, data migrations, code or documentation generators, Git hooks, and other development utilities.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

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)

실행 점수 미검증

설치 방법 보기

이럴 때 유용합니다

  • Creating a Deno command-line utility
  • Writing a data migration script
  • Generating code or documentation
  • Adding a Git hook

포함된 파일(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 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use this skill to expose Cataclysm-BN game functions and utilities to Lua. It guides you through organizing functions into libraries, registering constants and callbacks, documenting the API, and handling errors so Lua scripts can use the new bindings.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Expose game or map functions to Lua
  • Add constants or utility functions to a Lua library
  • Let Lua scripts register callbacks
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

Expose complex C++ classes to Lua by adding bindings for methods, inheritance, constructors, properties, and operators. The skill also guides ownership handling and registration so Lua scripts can use the intended class interface.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Exposing a C++ class to Lua
  • Binding inherited class methods
  • Adding constructors and properties
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

Add Lua bindings that let Cataclysm-BN scripts access simple C++ types, including string IDs, enums, and basic read-only classes. The skill guides documentation macros, registration in the appropriate source file, and build and in-game checks.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Exposing a C++ string ID to Lua
  • Registering an enum for Lua scripts
  • Making a basic read-only C++ type available to Lua
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

Generate and synchronize player-facing changelog files across English, Korean, and Japanese from a Git reference range. It groups related changes, organizes featured updates and fixes, and preserves localized labels and relevant media.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Preparing changelogs between two Git refs
  • Updating English, Korean, and Japanese release notes
  • Grouping related player-facing changes
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

Use this skill when the same English text needs different translations in different parts of an application. It adds gettext context at the source, updates affected PO entries, and guides validation of translations and formatting checks for the touched locale.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Separate translations for an ambiguous label
  • Add context to translated JSON strings
  • Update and validate affected PO entries
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

A practical reference for adding Lua bindings to Cataclysm-BN. Look up Luna macros, usertypes, libraries, type and function patterns, documentation helpers, build steps, and common errors, with examples showing how C++ types and functions become usable from Lua.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Look up Luna macros for a type
  • Register C++ methods and properties for Lua
  • Troubleshoot binding or build errors
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

cataclysmbn의 스킬 모두 보기

이 스킬의 문제 신고