Agent skill
documentation-patterns
Use when generating technical documentation for ADVPL/TLPP code - Protheus.doc headers, routine docs, API docs
Install this agent skill to your Project
npx add-skill https://github.com/thalysjuvenal/advpl-specialist/tree/main/skills/documentation-patterns
SKILL.md
Documentation Patterns
Overview
Patterns and templates for generating technical documentation from ADVPL/TLPP source code on TOTVS Protheus.
When to Use
- Generating Protheus.doc headers for functions/classes
- Creating routine documentation (tables, parameters, entry points, flow)
- Documenting REST API endpoints
- Adding documentation to undocumented legacy code
Documentation Types
Type: header — Protheus.doc Header
Standard documentation header following TOTVS conventions:
/*/{Protheus.doc} NomeFuncao
Descricao breve do que a funcao faz.
@type User Function | Static Function | Method
@author Nome do autor
@since DD/MM/YYYY
@version 1.0
@param cParam1, Character, Descricao do parametro 1
@param nParam2, Numeric, Descricao do parametro 2
@return Tipo, Descricao do retorno
@example
cResult := NomeFuncao("ABC", 123)
@see FuncaoRelacionada1, FuncaoRelacionada2
@obs Observacoes adicionais
@history DD/MM/YYYY, Autor, Descricao da alteracao
/*/
Fields:
- @type: User Function, Static Function, Method, Main Function
- @author: Extracted from git blame or user input
- @since: Date of creation (from git log or current date)
- @param: One line per parameter with name, type, description
- @return: Return type and description
- @example: Usage example
- @see: Related functions (detected from function calls in code)
- @history: Change history (from git log if available)
Type: full — Complete Routine Documentation
# NomeDaRotina
## Objetivo
[O que essa rotina faz em 1-2 frases]
## Tipo
[User Function | Static Function | Class Method | Job | Entry Point]
## Modulo
[COM | FAT | FIN | EST | CTB | FIS | PCP | MNT]
## Tabelas
### Leitura
| Alias | Descricao | Campos usados |
|-------|-----------|---------------|
| SA1 | Clientes | A1_COD, A1_NOME, A1_CGC |
### Gravacao
| Alias | Descricao | Campos gravados |
|-------|-----------|-----------------|
| SC5 | Pedidos de venda | C5_NUM, C5_EMISSAO, C5_VALOR |
## Parametros MV_*
| Parametro | Descricao | Impacto |
|-----------|-----------|---------|
| MV_ESTADO | UF padrao | Define UF quando nao informada |
## Pontos de Entrada
| Nome | Momento | O que permite |
|------|---------|---------------|
| MT100LOK | Apos validacao do modelo | Validacao customizada |
## Fluxo de Execucao
1. Valida parametros de entrada
2. Posiciona na tabela SA1
3. Calcula valores
4. Grava na SC5
5. Retorna resultado
## Dependencias
| Funcao | Arquivo | Tipo |
|--------|---------|------|
| fCalcImposto | MATA461.prw | Static Function |
## Historico de Alteracoes
| Data | Autor | Descricao |
|------|-------|-----------|
| 01/01/2026 | Thalys Augusto | Criacao |
Type: api — REST API Documentation
# API: NomeDoEndpoint
## Endpoint
`METHOD /api/v1/recurso`
## Autenticacao
Bearer Token (Authorization header)
## Parametros
### Path Parameters
| Nome | Tipo | Obrigatorio | Descricao |
|------|------|-------------|-----------|
### Query Parameters
| Nome | Tipo | Obrigatorio | Descricao |
|------|------|-------------|-----------|
### Request Body
```json
{
"campo1": "string",
"campo2": 0
}
```
## Response
### 200 OK
```json
{
"success": true,
"data": {}
}
```
### 400 Bad Request
```json
{
"success": false,
"error": "descricao do erro"
}
```
Process
- Read the target file completely
- Identify all functions/methods and their signatures
- Analyze variable types from declarations and usage
- Detect tables accessed (DBSelectArea, RecLock, BeginSQL, %table:%)
- Detect MV_* parameters (GetMV, SuperGetMV)
- Detect entry points (if the code IS an entry point, or calls them)
- Map function call dependencies (Grep for function names)
- Check git log for history if available
- Generate documentation following the requested type template
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
advpl-to-tlpp-migration
Use when migrating ADVPL procedural code to TLPP object-oriented code, converting functions to classes, or modernizing legacy Protheus code
protheus-reference
Use when looking up Protheus native functions, SX data dictionary tables, REST API endpoints, MV parameters, or TOTVS framework documentation
embedded-sql
Use when writing SQL queries in ADVPL/TLPP using BeginSQL/EndSQL blocks, %table%, %notDel%, %xfilial%, %exp% macros, or when choosing between Embedded SQL and TCQuery string concatenation
protheus-business
Use when consulting Protheus ERP business processes, module workflows, routines, integrations, or understanding how business operations work in TOTVS Protheus
advpl-refactoring
Use when refactoring ADVPL/TLPP code - extract functions, simplify logic, remove dead code, improve naming
code-explanation
Use when explaining ADVPL/TLPP code in plain language for developers and functional consultants
Didn't find tool you were looking for?