Skip to content
Development
Command

/generate

Generate ADVPL/TLPP code - functions, classes, MVC structures, REST APIs, Web Services, and entry points for TOTVS Protheus

From plugin
advpl-specialist
17613 skills10 agents13 commands2 hooks
Install
> /plugin marketplace add thalysjuvenal/advpl-specialist
> /plugin install advpl-specialist@advpl-specialist-marketplace

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/generate

Context preview

What this command does when you run it.

Generate ADVPL/TLPP code - functions, classes, MVC structures, REST APIs, Web Services, and entry points for TOTVS Protheus

Command definition

generate.md
description: Generate ADVPL/TLPP code - functions, classes, MVC structures, REST APIs, Web Services, and entry points for TOTVS Protheus
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Agent, WebSearch, WebFetch
argument-hint: "<type> [name] [--module module]"

/advpl-specialist:generate

**IMPORTANT:** Always respond in the same language the user is writing in. If the user writes in Portuguese, respond in Portuguese. If in English, respond in English. Adapt all explanations and suggestions to the user's language. Code comments may remain in English or match the user's language.

Generate new ADVPL or TLPP code following Protheus conventions and best practices.

Usage

/advpl-specialist:generate <type> [name] [--module <module>]

Types

| Type | Description | Output | |------|------------|--------| | `function` | User Function | .prw file | | `class` | TLPP class | .tlpp file | | `mvc` | MVC structure (MenuDef, ModelDef, ViewDef) | .prw file | | `rest` | REST API endpoint | .prw or .tlpp file | | `ponto-entrada` | Entry point | .prw file | | `webservice` | SOAP Web Service | .prw file | | `treport` | TReport report | .prw file | | `fwformbrowse` | FWFormBrowse/FWExecView screen | .prw file | | `job` | Batch job / scheduled process | .prw or .tlpp file | | `workflow` | Approval workflow process | .prw file |

Options

| Flag | Description | Default | |------|------------|---------| | `--module` | Module prefix (COM, FAT, FIN, etc.). For TLPP output, also used as the namespace agrupador: `custom.<module>.<servico>` | Ask user | | `--lang` | Language: advpl or tlpp | advpl for function/mvc/pe, tlpp for class | | `--output` | Output file path | Current directory + name + extension. **Do NOT scan the project to infer a path** — if the user wants a specific location, they must pass `--output` explicitly or answer a question about it. |

> **TLPP namespace (mandatory for `.tlpp` files):** every generated `.tlpp` file declares a `namespace custom.<agrupador>.<servico>` line right after the includes. The generator derives the namespace from `--module` (as agrupador) plus the service/class name (as servico), all lowercase with no underscores. If `--module` is not provided, the generator asks the user for the agrupador during the Planning Phase. See [advpl-code-generation — TLPP Namespace Rules](../skills/advpl-code-generation/reference.md) for the complete rule.

Process

**MANDATORY: Always enter planning mode before generating code. Never skip planning.**

No Project Source Scanning (CRITICAL)

**Do NOT scan the customer's project source files.** The plugin is template-driven — all code is generated from the plugin's own templates and skills. Reading existing `.prw` / `.tlpp` / `.prx` files from the customer's project is **not required** for any `/generate` scenario and must be avoided because:

  • Protheus projects routinely have thousands of source files — scanning them is prohibitively slow and wastes the user's time
  • The generated code comes from the plugin's templates, not from the customer's codebase
  • Naming, style and patterns come from `skills/advpl-code-generation/reference.md`, not from existing files
  • The caller already provides everything the generator needs: `type`, `name`, `--module`, business requirements

**Allowed uses of `Read` / `Glob` / `Grep`:**

  • Reading files **inside the plugin itself** — `skills/*`, `templates-*.md`, `patterns-*.md`, `agents/code-generator.md`, `skills/advpl-code-generation/reference.md`
  • `Write` the final generated `.prw` / `.tlpp` file to disk
  • `Read` a **specific file** the user explicitly referenced in their request (single file, exact path the user provided)

**Forbidden uses:**

  • `Glob "**/*.prw"`, `Glob "**/*.tlpp"`, `Glob "src/**/*"` — never list customer source files
  • `Grep` across the customer's source tree to "find patterns" or "check existing naming"
  • `Read` customer source files "to understand the codebase" — the templates are self-contained
  • `Bash ls`, `Bash find`, `Bash tree` on the customer project root — same prohibition

**Output path rule:** Save the generated file to the **current working directory** using `<name>.<ext>` (or the path passed via `--output`). Never `Glob` to discover module folders, never "guess" the right location by scanning. If the user has a preferred location, either they pass `--output` or the generator asks a direct question.

**Only exception:** The user explicitly references an existing file in their request (e.g., *"gere um REST similar ao que está em `src/fontes/FATA001.prw`"*). In that case, `Read` is allowed **only** on the exact path the user provided — never expanded into a full-project scan.

Planning Phase (REQUIRED)

1. **Parse arguments** - Extract type, name, and flags 2. **Ask missing details** - If name or module not provided, ask the user. **For TLPP generation (`.tlpp` output), also collect the namespace agrupador: if `--module <agrupador>` is provided, infer `namespace custom.<agrupador>.<servico>` automatically; if `--module` is missing, ask the user explicitly for the agrupador before entering plan mode. Never silently omit the namespace and never invent a default.** 2a. **Validate identifier length (BLOCKING)** - Compute `len(name)` and compare against the effective limit for the chosen language/construct: `User Function` in `.prw` must be ≤ 8 chars, `Static Function` in `.prw` must be ≤ 10 chars, TLPP with `namespace` accepts up to 255 chars. If the name exceeds the limit, **do NOT enter plan mode**. Present the user with two explicit options and wait for their choice:

  • **(A) Shorten the name** — suggest 2-3 alternatives following Protheus conventions (module prefix + sequence like `FATA100`, mnemonic abbreviation, or functional abbreviation). Never offer random truncations.
  • **(B) Switch to TLPP with namespace** — explain that TLPP with namespace supports up to 255 chars (available from Protheus release 12.1.2410). Ask for the agru
Read more
Ships withadvpl-specialist

Plugin para Claude Code especializado em ADVPL e TLPP para desenvolvimento no ecossistema TOTVS Protheus — para desenvolvedores e consultores funcionais. Documentacao completa:

Get the whole plugin