Files
jogos_matheus/.claude/skills/vitruvio-criar-script/SKILL.md
T
2026-09-23 12:29:08 -03:00

3.4 KiB

name, description
name description
vitruvio-criar-script Use when the user wants to create a new JavaScript script in a Vitruvio repository. Triggers: "create script", "new script", "criar script", "novo script", "add script", or any request to scaffold a scripts/*.js file and register it in vitruvio.json.

Create Vitruvio Script

All messages shown to the user must be written in Portuguese.

You are creating a new script inside a Vitruvio repository. Follow these steps in order.

Step 1 — Confirm you are inside a Vitruvio repo

ls vitruvio.json 2>/dev/null && echo "OK" || echo "NOT_A_VITRUVIO_REPO"

If NOT_A_VITRUVIO_REPO, stop and tell the user to cd into the correct repo.

Step 2 — Collect script details

Ask the user (in a single message, only ask what is missing from their original request):

  • Key (sigla) — unique identifier used in libService.loadScript('key'). Snake_case. Must be unique across all scripts in the repo. If the user already provided a name, suggest a key derived from it.
  • Name — human-readable label shown in the Vitruvio UI.
  • Pattern — which of the two patterns applies:
    • Library — reusable module, loaded by other scripts/endpoints/panels via libService.loadScript. Wrap in ({...}).
    • Process/task script — runs directly from a process task or scheduler. Top-level execution, no export.
  • Description — one sentence about what this script does (optional, but ask if not provided).
  • Domain — USUARIO (user-level, default) or SISTEMA (system-level).

Step 3 — Scaffold and create file

vitruvio new script <key> --name "<name>"

This creates scripts/<key>.js and registers it in vitruvio.json with domain: "USUARIO". Replace the generated file with the appropriate template below. If the domain should be SISTEMA, update that field in vitruvio.json.

Target path: scripts/<key>.js

Library template

/**
 * Nome: <name>
 * Sigla: <key>
 * Descrição: <description>
 */
({
  // example function — replace with actual implementation
  run: function(params) {
    var db = libService.loadScript('db');
    var banco = new db(db.VITRUVIO_DATASOURCE);

    // implementation here

    return {};
  }
})

Process / task script template

/**
 * Nome: <name>
 * Sigla: <key>
 * Descrição: <description>
 */
(function(execution) {
  var db = libService.loadScript('db');
  var banco = new db(db.VITRUVIO_DATASOURCE);

  // implementation here
})(execution)

Rules (Rhino ES5 — no exceptions):

  • No let, const, arrow functions, template literals, destructuring, spread, class, or import/export
  • Use var everywhere
  • No require, process, window, or Node/browser globals
  • String concatenation with +, not template literals
  • JSON.parse / JSON.stringify for serialization

Step 4 — Update vitruvio.json entry

vitruvio new already added the script entry. The full entry shape is:

{
  "key": "<key>",
  "name": "<name>",
  "description": "<description>",
  "language": "javascript",
  "domain": "USUARIO",
  "source": "scripts/<key>.js"
}

Update only what differs: change "domain" to "SISTEMA" if needed; add "description" if provided.

Step 5 — Report

Tell the user:

  • File created: scripts/<key>.js
  • Registered in vitruvio.json with key <key>
  • How to load it from another script or endpoint: var lib = libService.loadScript('<key>');