agentleFS
totvstotvs/engpro-advpl-tlpp-skills/skills/advpl-tlpp/data-dictionary-lookup/SKILL.md

data-dictionary-lookup

Skill138 starsChanged 6 months agoMITView on GitHub

Query the TOTVS Protheus ERP data dictionary (SX2 tables, SX3 fields, SIX indexes, SX6 parameters, SX5 generic tables, SX7 triggers, SX1 questions, SX9 relationships, SXB standard lookups, SXG/SXA groups). Use when the user asks 'what fields does SA1 have', 'what is the index of SE1', 'parameter MV_ESTADO', 'generic table 12', 'triggers for field A1_COD', 'standard lookup SA1', 'table structure', 'data dictionary'. Also use during refactoring, migration, or code improvements when dictionary impact validation is needed to confirm whether changes affect fields, triggers, indexes, parameters, or table relationships.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check available indexes for a table

    line 22
  2. Distinctive:

    Search generic table contents (SX5)

    line 24
  3. Distinctive:

    Check triggers associated with a field

    line 25
  4. Distinctive:

    Check relationships between tables (SX9)

    line 27
  5. Very specific:

    Use TRIM() in character field comparisons (trailing spaces)

    line 69
  6. Very specific:

    Use base table without suffix: sx3, sx2, six — never sx3t10, sx2t10

    line 70
  7. Very specific:

    Search by exact name (TRIM(x6_var) LIKE 'MV_NAME%') or by description (UPPER(x6_descric) LIKE '%TERM%')

    line 86
  8. Very specific:

    If additional context is needed, search TDN documentation via product-docs-search

    line 87
  9. Distinctive:

    When presenting results to the user, always:

    line 98

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Protheus Data Dictionary Lookup

Overview

Structured querying of the TOTVS Protheus ERP data dictionary. Allows searching tables, fields, indexes, parameters, generic tables, triggers, parameterization questions, relationships, and standard lookups (SQL queries via execute-sql and TDN documentation via search tools).

When to Use

  • Discover which fields a table has and their types/sizes
  • Check available indexes for a table
  • Query the value and purpose of a parameter (MV_*)
  • Search generic table contents (SX5)
  • Check triggers associated with a field
  • Query parameterization questions (SX1)
  • Check relationships between tables (SX9)
  • Query standard lookups (SXB)
  • Find the sharing mode of a table (Exclusive/Shared)
  • Impact validation in the dictionary: during refactorings, migrations, or code improvements, consult the dictionary when necessary to confirm whether the changes affect fields, triggers, indexes, parameters, or relationships of the tables involved in the process

Bundled Reference Files

This skill uses progressive disclosure. The SKILL.md covers dictionary structure, query flow, and response format. SQL queries and detailed column reference are in the references/ directory — read on demand as needed:

Reference FileWhen to ReadContent
references/sql-queries.mdExecuting dictionary queries — listing fields, indexes, parameters, triggers, questions, relationships, standard lookups, or combining SX* tablesComplete SQL queries for all 9 dictionary tables (SX2, SX3, SIX, SX6, SX5, SX7, SX1, SX9, SXB), combined queries (full view, fields with triggers, mandatory fields), and mandatory execute-sql rules (TRIM, d_e_l_e_t_, lowercase)
references/column-reference.mdInterpreting results or needing to understand the meaning of specific columns from SX* tablesDetailed tables with all columns from SX2, SX3, SIX, SX6, SX5, SX7, SX1, SX9, and SXB, including type, possible values, and functional description

Data Dictionary Structure

Protheus organizes its metadata in SX* tables:

TableDescriptionPrimary Key
SX1Parameterization questions (reports/queries)X1_GRUPO + X1_ORDEM
SX2System tables registryX2_CHAVE (table alias)
SX3Table fieldsX3_ARQUIVO + X3_CAMPO
SX5Generic tables (lookup values)X5_TABELA + X5_CHAVE
SX6System parameters (MV_*)X6_VAR
SX7Field triggersX7_CAMPO + X7_SEQUENC
SX9Table relationshipsX9_DOM + X9_CDOM
SXAFolders and groupers-
SXBStandard lookups (F3)XB_ALIAS + XB_TIPO
SXGField groups-
SIXTable indexesINDICE + ORDEM

Mandatory Rules for execute-sql Queries

  1. Always include d_e_l_e_t_ = ' ' (soft-delete filter)
  2. Columns are lowercase — never use X3_CAMPO, always x3_campo
  3. Use TRIM() in character field comparisons (trailing spaces)
  4. Use base table without suffix: sx3, sx2, six — never sx3t10, sx2t10

Query Flow by Scenario

Full table overview

Execute 3 queries in parallel (see queries in references/sql-queries.md):

  1. Metadata → SX2 filtering by x2_chave
  2. Fields → SX3 filtering by x3_arquivo
  3. Indexes → SIX filtering by indice

Parameter lookup

  1. Search by exact name (TRIM(x6_var) LIKE 'MV_NAME%') or by description (UPPER(x6_descric) LIKE '%TERM%')
  2. If additional context is needed, search TDN documentation via product-docs-search

Field triggers

  1. Query SX7 filtering by x7_campo
  2. Combine with SX3 to get field titles for involved fields

Response Format

When presenting results to the user, always:

  1. Title: Table name and description (from SX2)
  2. Sharing mode: E (Exclusive) or C (Shared) — indicate the meaning
  3. Formatted table: Fields in markdown table with relevant columns
  4. Indexes: List with composition and description
  5. Notes: Virtual fields, triggers, special validations

Response Example

## SA1 — Customer Registry

**Mode**: Shared (C/C/C)
**Unique key**: A1_FILIAL+A1_COD+A1_LOJA
**MVC Routine**: CRMA980

### Main Fields

| Field | Title | Type | Size | Dec | Required | Context |
|-------|-------|------|------|-----|----------|---------|
| A1_FILIAL | Branch | C | 8 | 0 | Yes | Real |
| A1_COD | Code | C | 6 | 0 | Yes | Real |
| A1_LOJA | Store | C | 2 | 0 | Yes | Real |
| A1_NOME | Name | C | 40 | 0 | Yes | Real |
...

### Indexes

| Order | Composition | Description |
|-------|-------------|-------------|
| 1 | A1_FILIAL+A1_COD+A1_LOJA | Customer Code+Store |
| 2 | A1_FILIAL+A1_NOME | Name |
...

Common Errors

ErrorCauseSolution
Query returns emptycharacter field has trailing spacesUse TRIM() in comparisons
Data not foundTable has enterprise suffix (sx3t10)Use base table without suffix: sx3, sx2, six
Field not foundAlias with spaces in x3_arquivoUse TRIM(x3_arquivo) = 'SA1'
Deleted records returnedMissing soft-delete filterAlways include d_e_l_e_t_ = ' '

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.