Agent skill

Query Builder

by totvs in totvs/engpro-advpl-tlpp-skills

Build optimized and safe SQL queries for Protheus tables. An agent skill from totvs/engpro-advpl-tlpp-skills.

MITAuto-check passedDatabases

Install Query Builder

skills CLI
$ npx skills add totvs/engpro-advpl-tlpp-skills --skill query-builder -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install totvs/engpro-advpl-tlpp-skills query-builder --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/totvs/engpro-advpl-tlpp-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/advpl-tlpp/query-builder .claude/skills/query-builder && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
query-builder
GitHub stars
141
Token cost
~4.7k tokens
SKILL.md length
1,628 words
Files
3 (incl. references)
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

Build optimized and safe SQL queries for Protheus tables. An agent skill from totvs/engpro-advpl-tlpp-skills.

  • Works in 6 steps: Build the SQL with ? placeholders for… → Wrap it in ChangeQuery() for… → Instantiate with… → …
  • User says build query
  • SKILL.md covers Overview, When to Use, Bundled Reference Files and Protheus Database Conventions, plus 8 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Query Builder is an agent skill from totvs/engpro-advpl-tlpp-skills. Build optimized and safe SQL queries for Protheus tables. Automatically includes mandatory filters (DELET, branch), suggests appropriate indexes from SIX patterns, generates both Embedded SQL (preferring FWExecStatement) and Workarea (DBSelectArea/DBSeek) versions, and warns about common Protheus SQL pitfalls. Use when user says 'build query', 'SQL for Protheus table', 'FWExecStatement', 'TCQuery', 'Workarea vs SQL'.

Its SKILL.md is about 4.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/cross-database-compatibility.md` and `references/query-patterns-and-examples.md`).

It sits in Databases, covering SQL and ORMs and data access. It works with SQL. The repository describes itself as: Repositório contendo skills para orientar desenvolvimento ADVPL/TLPP com agentes de IA. The licence is MIT.

When your agent uses it

  • User says build query
  • SQL for Protheus table
  • FWExecStatement
  • Workarea vs SQL

Example prompts

  • “build query”
  • “SQL for Protheus table”
  • “FWExecStatement”
  • “/query-builder”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Build the SQL with ? placeholders for every dynamic value (filter, branch, deletion flag).
  2. Wrap it in ChangeQuery() for cross-database compatibility.
  3. Instantiate with FWExecStatement():New(cQuery) (or FWPreparedStatement on libs older than 20211116).
  4. Bind values 1..N with SetString(), SetNumeric(), SetDate(), SetBoolean(), SetIn().
  5. Execute
  6. Always close opened aliases ((cAlias)->(DBCloseArea())) and call oStatement:Destroy().

What it can do on your machine

Read from SKILL.md and the folder at commit 3908e4e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are sql).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Query Builder loads about 4.7k tokens when it runs, and up to ~8.4k if it reads all its reference files. Until then it costs about 110 tokens; SKILL.md has 1,628 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~110
When it runs · the whole SKILL.md, loaded when a task matches
~4.7k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~8.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from totvs/engpro-advpl-tlpp-skills at commit 3908e4e, republished under its MIT licence (© totvs). 1,628 words, ~4,686 tokens.

Download SKILL.mdSave it as .claude/skills/query-builder/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
query-builder
description
Build optimized and safe SQL queries for Protheus tables. Automatically includes mandatory filters (D_E_L_E_T_, branch), suggests appropriate indexes from SIX patterns, generates both Embedded SQL (preferring FWExecStatement) and Workarea (DBSelectArea/DBSeek) versions, and warns about common Protheus SQL pitfalls. Use when user says 'build query', 'SQL for Protheus table', 'FWExecStatement', 'TCQuery', 'Workarea vs SQL'.
license
MIT
metadata.domain
Protheus
metadata.maintainer
Customizações ADVPL/TLPP
metadata.author
Thalion Starforge
metadata.version
4.2.0
metadata.category
Code Generation

Protheus Query Builder

Overview

Build correct, safe, and optimized SQL queries for Protheus ERP tables. Protheus has unique database conventions — mandatory soft-delete filters, multi-branch filtering, Hungarian notation for fields, data dictionary-driven schemas, and specific index patterns — that every query must respect. This skill generates queries that follow these conventions and helps choose between Workarea access and Embedded SQL.

When to Use

Use this skill when:

  • Writing SQL queries against Protheus tables (SA1, SD1, SF2, etc.)
  • Building parameterized SQL queries (FWExecStatement, TCSqlExec) in AdvPL/TLPP
  • Optimizing existing queries for Protheus-specific patterns
  • Deciding between Workarea access and Embedded SQL
  • Ensuring mandatory filters are not missing
  • Generating safe queries that prevent SQL injection

Bundled Reference Files

This skill uses progressive disclosure. The SKILL.md body covers conventions, decision logic, the checklist, and anti-patterns. Detailed code templates and cross-database reference tables are in the references/ directory — read them on demand based on the scenario:

Reference FileWhen to ReadContent
references/query-patterns-and-examples.mdGenerating query code — Workarea, Embedded SQL, multi-table JOINs, TCSqlExec updates, counting, or reviewing SQL injection prevention examplesFull code templates for all 5 query patterns, safe/unsafe FWExecStatement examples, LIKE clause parameterization
references/cross-database-compatibility.mdHandling cross-database concerns — ChangeQuery(), TCGetDB(), DBAccess macros, or translating functions between MSSQL / PostgreSQL / OracleChangeQuery and TCGetDB code examples, DBAccess macros table, cross-database function equivalents (9 operations × 4 dialects)

Also refer to references/sonarqube-rules-reference.md for the complete SonarQube rules reference shared across skills.


Protheus Database Conventions

Table Naming

Protheus table aliases follow the pattern XXN where XX is the module prefix and N is a sequence:

PrefixModuleExample Tables
SACustomers/VendorsSA1 (Customers), SA2 (Vendors), SA3 (Salespeople)
SBProductsSB1 (Products), SB2 (Stock Balances), SB5 (Supplements)
SCPurchasingSC1 (Purchase Requests), SC5 (Sales Orders Header), SC6 (Sales Orders Items), SC7 (Purchase Orders)
SDDocumentsSD1 (Incoming Invoices Items), SD2 (Outgoing Invoices Items), SD3 (Internal Movements)
SEFinancialSE1 (Accounts Receivable), SE2 (Accounts Payable), SE5 (Cash Movements)
SFInvoicesSF1 (Incoming Invoices Header), SF2 (Outgoing Invoices Header)
SXData DictionarySX1 (Parameters), SX2 (Tables), SX3 (Fields), SX5 (Lookup Tables), SX6 (System Parameters), SX7 (Triggers), SIX (Indexes)
ZZCustomZZ1-ZZZ (Custom tables created by customer, also Z01-Z99, ZA0-ZAZ, etc.)
Physical Table Names

The physical table name in the database appends the company code:

AliasPhysical NameRule
SA1SA1010Alias + Company ("01") + Branch padding ("0")
SD1SD1010Same pattern

Use RetSQLName("SA1") to get the correct physical table name dynamically.

Field Naming

Fields follow the pattern XX_FIELD where XX matches the table alias prefix:

TableFieldMeaning
SA1A1_CODCustomer code
SA1A1_NOMECustomer name
SD1D1_DOCInvoice document number
SD1D1_TOTALInvoice item total
SF2F2_DOCOutgoing invoice number
Mandatory System Fields

Every query against Protheus tables MUST include these filters:

FieldFilterPurpose
D_E_L_E_T_= ' ' (single space)Soft-delete flag. Records with '*' are logically deleted
XX_FILIAL= cFilAnt or = FWxFilial("XXX")Multi-branch filter
sql
-- ALWAYS include both filters
SELECT A1_COD, A1_NOME
FROM SA1010 SA1
WHERE SA1.D_E_L_E_T_ = ' '
  AND SA1.A1_FILIAL = '01'

Warning: Omitting D_E_L_E_T_ will return deleted records. Omitting the branch filter will return records from all branches, which is usually incorrect and a security risk.


Query Patterns

This skill supports five query patterns. Read references/query-patterns-and-examples.md for the full code templates.

PatternApproachWhen to Use
1 — Simple Select (Workarea)DbSelectArea + DbSeekSingle record lookup by existing index, record-by-record operations
2 — Simple Select (Embedded SQL)FWExecStatement + OpenAlias / ExecScalarAggregations, complex filters, no suitable index for Workarea
3 — Multi-Table JoinEmbedded SQL with INNER JOINCross-table reporting, invoice details with product names
4 — INSERT/UPDATE (TCSqlExec)FWExecStatement + TCSqlExecDirect SQL writes (bypasses data dictionary triggers)
5 — Counting RecordsFWExecStatement:ExecScalar() on SELECT COUNT(*)Record counts with filters

Important: Pattern 4 (TCSqlExec) bypasses data dictionary validations and triggers. Prefer Workarea RecLock/MsUnlock for standard CRUD operations.


Workarea vs. Embedded SQL Decision Matrix

CriterionWorkarea (DBSeek)Embedded SQL (FWExecStatement)
Single record lookup by keyBest choiceAcceptable
Sequential scan by indexBest choiceAcceptable
Complex multi-table joinsPoor (requires nested seeks)Best choice
Aggregations (SUM, COUNT)Very poorBest choice
Large result setsBetter memory controlGood (but watch alias handling)
Record locking for updateRequiredUse FWExecStatement + TCSqlExec (bypasses triggers)
Performance (key-based)FastestSlight overhead
Data dictionary trigger executionAutomaticNot triggered
Index requirementMust have suitable SIX indexAny column
Code readability for complex queriesPoorBest choice

Rule of thumb: Use Workarea for CRUD operations on single records. Use Embedded SQL for reporting, aggregation, and complex joins.


Index Awareness (SIX Dictionary)

Protheus indexes are defined in the SIX table. The first index of each table (order 1) is typically the primary key.

Common Index Patterns
TableOrderKey ExpressionUse Case
SA11A1_FILIAL + A1_COD + A1_LOJAPrimary key — customer lookup
SA13A1_FILIAL + A1_CGCFind customer by tax ID
SA21A2_FILIAL + A2_COD + A2_LOJAPrimary key — vendor lookup
SB11B1_FILIAL + B1_CODPrimary key — product lookup
SD11D1_FILIAL + D1_DOC + D1_SERIE + D1_FORNECE + D1_LOJA + D1_COD + D1_ITEMIncoming invoice item
SD21D2_FILIAL + D2_DOC + D2_SERIE + D2_CLIENTE + D2_LOJA + D2_COD + D2_ITEMOutgoing invoice item
SE11E1_FILIAL + E1_PREFIXO + E1_NUM + E1_PARCELA + E1_TIPOAccounts receivable
SF21F2_FILIAL + F2_DOC + F2_SERIEOutgoing invoice header
Using Indexes in Embedded SQL

For SQL Server, use the %nolock% DBAccess macro on read queries. This macro translates to WITH (NOLOCK) on MSSQL and is silently ignored on PostgreSQL/Oracle (MVCC), making it safe to use in cross-database code:

sql
SELECT A1_COD, A1_NOME
FROM SA1010 SA1 WITH (%nolock%)
WHERE SA1.D_E_L_E_T_ = ' '
  AND SA1.A1_FILIAL = '01'
  AND SA1.A1_COD = '000001'
  AND SA1.A1_LOJA = '01'

Tip: Always order WHERE clauses to match the index key expression order for the query optimizer.


SQL Injection Prevention

Never concatenate user input directly into SQL strings. Use FWExecStatement to parameterize all dynamic values.

The safe pattern:

  1. Build the SQL with ? placeholders for every dynamic value (filter, branch, deletion flag).
  2. Wrap it in ChangeQuery() for cross-database compatibility.
  3. Instantiate with FWExecStatement():New(cQuery) (or FWPreparedStatement on libs older than 20211116).
  4. Bind values 1..N with SetString(), SetNumeric(), SetDate(), SetBoolean(), SetIn().
  5. Execute:
    • SELECT returning a cursor → cAlias := oStatement:OpenAlias([cAlias][, cLifeTime, cTimeout])
    • SELECT returning a single scalar → xValue := oStatement:ExecScalar(cColumn[, cLifeTime, cTimeout])
    • INSERT / UPDATE / DELETE → TCSqlExec(oStatement:GetFixQuery())
  6. Always close opened aliases ((cAlias)->(DBCloseArea())) and call oStatement:Destroy().

For LIKE clauses, build the % wildcard on the AdvPL side ("%" + cSearch + "%") and bind the whole string as a single ? parameter — this avoids cross-DB concat operator differences.

Do not use SetUnsafe() with user input. It bypasses bind safety and reintroduces SQL injection risk; reserve it for identifiers built from constants.

Cache (optional): OpenAlias / ExecScalar accept cLifeTime and cTimeout (seconds, as character) to reuse a cached result from DBAccess for hot, repeatedly executed queries.

Read references/query-patterns-and-examples.md for complete safe/unsafe code examples, the full method reference, and LIKE-clause examples.


Show full SKILL.md (573 more words)Show less

Common Anti-Patterns

Anti-PatternProblemFix
Missing D_E_L_E_T_ filterReturns deleted recordsAlways add WHERE D_E_L_E_T_ = ' '
Missing branch filterReturns records from all branchesAlways add AND XX_FILIAL = '...'
SELECT * on Protheus tablesReturns dozens of system fields, slowList only the fields you need
Full table scan on SD1/SD2Millions of rows, very slowUse indexed columns in WHERE
Not using %nolock%Lock contention on read queriesAdd WITH (%nolock%) to SELECT tables — cross-DB safe (ignored on PostgreSQL/Oracle)
D_E_L_E_T_ filter on JOINs missingJoined table returns deleted recordsAdd D_E_L_E_T_ = ' ' to every table in JOIN
Hardcoded company/branch codesBreaks in multi-company environmentsUse FWxFilial(), RetSQLName()
Not closing query aliases / FWExecStatementMemory leak, alias exhaustionAlways call (cAlias)->(DBCloseArea()) and oStatement:Destroy()
Macro execution in SQLSQL injection riskUse FWExecStatement for parameterized values
Missing RetSQLName()Wrong physical table name in multi-companyAlways use RetSQLName("XXX")
Creating procedures in sourceProhibited by SonarQubeUse SPManager for procedure management
Using IIF in SQL expressionsProhibited — use CASE WHEN or If/Else in AdvPL logicReplace IIF() with If/Else/EndIf or SQL CASE WHEN
Direct access to SIX/SX2/SX3 via DbSelectAreaProhibited metadata accessUse RetSqlName() for SX2, FWSX3Util() for SX3, standard APIs for SIX
GetMV/ExistBlock inside loopsPerformance degradationCache result in a variable before the loop

Query Building Checklist

Mandatory
  • D_E_L_E_T_ = ' ' included for every table in the query
  • Branch filter (XX_FILIAL) included for every table
  • Physical table name obtained via RetSQLName("XXX")
  • User-provided values parameterized with FWExecStatement (preferred over raw TCQuery)
  • Result alias name generated with GetNextAlias() and opened via FWExecStatement:OpenAlias()
  • Opened alias closed with DBCloseArea() in all code paths (including errors) and FWExecStatement:Destroy() is called
Performance
  • Only required fields listed (no SELECT *)
  • WHERE clause order matches index key expression
  • %nolock% hint used for SQL Server read queries
  • Pagination used for large result sets
  • JOINs reference indexed columns
Safety
  • No macro-execution (&cExpr) in SQL strings
  • No hardcoded company/branch codes
  • Error handling wraps the query execution (Try-Catch)
  • Workarea area saved and restored with GetArea()/RestArea()
  • No IIF() in query construction or expressions — use If/Else/EndIf or SQL CASE WHEN
  • No CREATE PROCEDURE in source — use SPManager
  • GetMV()/ExistBlock() results cached before use in loops

Refer to references/sonarqube-rules-reference.md for the complete SonarQube rules reference.


Cross-Database Compatibility

Protheus supports PostgreSQL, MSSQL Server, and Oracle. All generated SQL must work across all three, or use framework tools to handle differences:

  • ChangeQuery(cQuery) — translates SQL syntax to the active database dialect (TOP → LIMIT, etc.). BeginSQL/EndSQL calls it automatically.
  • TCGetDB() — returns "MSSQL", "ORACLE", or "POSTGRES" for DB-specific branching when ChangeQuery() is insufficient.
  • DBAccess macros — %nolock%, %notDel%, %table:XXX%, %Order:XXX% — translated per database in SQL strings.
  • Best practice: Always use ANSI-compatible SQL (COALESCE, CASE WHEN, CONCAT, FETCH FIRST) or rely on ChangeQuery().

Read references/cross-database-compatibility.md for full code examples, the DBAccess macros table, and the cross-database function equivalents reference (MSSQL vs PostgreSQL vs Oracle).


Troubleshooting

  • Missing D_E_L_E_T_ filter: All Protheus queries must include D_E_L_E_T_ = ' ' (or equivalent %notDel%) to exclude logically deleted records. Omitting this returns deleted rows.
  • Wrong physical table name: Use RetSQLName('alias') to get the physical table name. Hardcoded names like SA1010 will break across environments with different company codes.
  • Index not being used: Ensure the WHERE clause column order matches the SIX index key expression. Use %nolock% hint for SQL Server read-only queries to avoid lock contention.
  • Branch/company filter missing: Use FWxFilial('alias') for the branch filter. Hardcoding branch codes causes cross-branch data leakage.
  • SQL injection via macro-execution: Never use &(cExpr) to build SQL strings. Use FWExecStatement to parameterize all dynamic values in queries.

© totvs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (references) in skills/advpl-tlpp/query-builder of totvs/engpro-advpl-tlpp-skills.

  • SKILL.md
  • references/cross-database-compatibility.md
  • references/query-patterns-and-examples.md

Open the folder on GitHubat commit 3908e4e

Compare with similar skills

Query Builder next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Query Builder compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Query Builder this skilltotvs/engpro-advpl-tlpp-skills141—~4.7kAutomated safety check: PassMIT
DB Migrationskurealnum/dotfiles290—~820Automated safety check: PassNone
Optimizing Ef Core Queriesdotnet/skills5.6k1 repos~2.7kAutomated safety check: PassMIT
Migrationkortix-ai/suna20k—~1.2kAutomated safety check: PassCustom licence
Frappe Core DatabaseImpertio-Studio/Frappe_Claude_Skill_Package187—~3.8kAutomated safety check: PassMIT
SQL ReviewArchive228/loopkit755—~217Automated safety check: PassMIT

Similar skills

  • DB Migrations

    kurealnum/dotfiles

    A skill your agent uses when generating or regenerating Drizzle migration files, changing database schema tables or columns, resolving migration sequence conflicts after rebase, reviewing migration…

    290 GitHub stars~820 tokensUpdated 5 mo ago
    DatabasesAuto-check passed
  • Official

    Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster.

    5.6k GitHub starsUsed in 1 repo~2.7k tokens
    DatabasesAuto-check passed
  • Migration

    kortix-ai/suna

    How to change the database schema in this repo. An agent skill from kortix-ai/suna.

    20k GitHub stars~1.2k tokensUpdated today
    DatabasesAuto-check passed
  • Frappe Core Database

    Impertio-Studio/Frappe_Claude_Skill_Package

    A skill your agent uses when performing database operations in ERPNext/Frappe v14-v16.

    187 GitHub stars~3.8k tokensUpdated 20 days ago
    DatabasesAuto-check passed
  • SQL Review

    Archive228/loopkit

    Review SQL and ORM queries for correctness, safety, and performance before they ship.

    755 GitHub stars~217 tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • Query Optimization

    seb1n/awesome-ai-agent-skills

    Diagnose and optimize existing slow SQL queries using execution plans, indexing strategies, query rewriting, and ORM tuning.

    206 GitHub stars~2.6k tokensUpdated 1 mo ago
    DatabasesAuto-check passed

More from totvs/engpro-advpl-tlpp-skills

All 19 skills in this repo
  • AdvPL UTF-8 to CP1252 Converter

    totvs/engpro-advpl-tlpp-skills

    Converts AdvPL and TLPP source files from UTF-8 to Windows-1252 in place after code generation, because the Protheus compiler accepts only CP1252 files.

    141 GitHub stars~2.6k tokensUpdated 2 days ago
    Auto-check passed
  • AdvPL/TLPP Compile in VS Code

    totvs/engpro-advpl-tlpp-skills

    Compiles AdvPL and TLPP sources from VS Code with the TOTVS Developer Studio extension, handling server setup, connection and compile result reporting.

    141 GitHub stars~3.7k tokensUpdated 2 days ago
    Auto-check passed
  • Protheus Spec-Driven Development

    totvs/engpro-advpl-tlpp-skills

    Plans and builds Protheus AdvPL/TLPP features through Specify, Design, Tasks and Execute phases whose depth scales with the size of the change.

    141 GitHub stars~3.6k tokensUpdated 2 days ago
    Auto-check passed
  • AdvPL and TLPP Code Review

    totvs/engpro-advpl-tlpp-skills

    Reviews AdvPL and TLPP source against SonarQube rules, ProtheusDOC requirements, security, performance and Protheus conventions, and reports findings by severity.

    141 GitHub stars~2.5k tokensUpdated 2 days ago
    Auto-check passed
  • Protheus Data Dictionary Lookup

    totvs/engpro-advpl-tlpp-skills

    Queries the TOTVS Protheus ERP data dictionary for tables, fields, indexes, parameters, triggers and lookups, including impact checks during refactoring.

    141 GitHub stars~1.5k tokensUpdated 2 days ago
    Auto-check passed
  • Protheus MVC Generator

    totvs/engpro-advpl-tlpp-skills

    Generates Protheus MVC screens in ADVPL/TLPP, with ModelDef, ViewDef, MenuDef and Browse functions for single-entity and master-detail layouts.

    141 GitHub stars~2.2k tokensUpdated 2 days ago
    Auto-check passed

Works with

Categories

Questions about Query Builder

What does Query Builder do?

Build optimized and safe SQL queries for Protheus tables. An agent skill from totvs/engpro-advpl-tlpp-skills. Query Builder is an agent skill from totvs/engpro-advpl-tlpp-skills. Build optimized and safe SQL queries for Protheus tables.

When should I use Query Builder?

Query Builder fits situations like: user says build query; SQL for Protheus table; FWExecStatement; workarea vs SQL.

How do I install Query Builder in Claude Code?

Run `npx skills add totvs/engpro-advpl-tlpp-skills --skill query-builder -a claude-code`. Or copy the skill folder (skills/advpl-tlpp/query-builder in totvs/engpro-advpl-tlpp-skills) into .claude/skills/query-builder in your project. Claude Code loads it when a task matches its description.

How do I install Query Builder in Codex?

Run `npx skills add totvs/engpro-advpl-tlpp-skills --skill query-builder -a codex`. Or copy the skill folder (skills/advpl-tlpp/query-builder in totvs/engpro-advpl-tlpp-skills) into .agents/skills/query-builder in your project. Codex loads it when a task matches its description.

Can I use Query Builder in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add totvs/engpro-advpl-tlpp-skills --skill query-builder -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/query-builder, .gemini/skills/query-builder, .github/skills/query-builder and .opencode/skills/query-builder in your project.

What does Query Builder need to run?

SKILL.md names no scripts, command-line tools or credentials: Query Builder is instructions for the agent only.

Does Query Builder access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Query Builder safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Query Builder use?

Query Builder is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Query Builder use?

About 4.7k tokens (SKILL.md is roughly 19k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.7k tokens, read only when the agent opens those files.

What are the alternatives to Query Builder?

Skills that share tags, products or a category with Query Builder: DB Migrations (kurealnum/dotfiles, 290 stars), Optimizing Ef Core Queries (dotnet/skills, 5.6k stars), Migration (kortix-ai/suna, 20k stars) and Frappe Core Database (Impertio-Studio/Frappe_Claude_Skill_Package, 187 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Query Builder?

totvs (a GitHub organization) maintains it in totvs/engpro-advpl-tlpp-skills, which has 141 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on October 5, 2026.

Source: totvs/engpro-advpl-tlpp-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.