query-builder
Skill183 starsChanged 2 months agoMITView on GitHub
Use when the user needs to build, choose the pattern for, or optimize a SQL query against Protheus ERP tables -- covering Workarea (DbSelectArea/DbSeek) vs Embedded SQL vs TCSqlExec pattern choice, mandatory D_E_L_E_T_/xFilial filters, SIX index-aligned WHERE ordering, FWPreparedStatement parameterization to prevent SQL injection, and cross-database (PostgreSQL/MSSQL/Oracle) portability. Also triggers on Portuguese phrasing like "consulta SQL", "montar query", "otimizar consulta", "qual indice usar", "escolher entre DbSeek ou SQL", or "prevenir SQL injection no Protheus".
4 other projects use a version of this.
Adopted by
Most recently taken up by
- AnyOrgName/php-skillstheir own version, first seen Nov 8, 2026
- nek1987/auto-agent-harnesstheir own version, first seen Oct 11, 2026
- totvs/engpro-advpl-tlpp-skillstheir own version, first seen May 28, 2026
- vespa-engine/skillstheir own version, first seen May 18, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- totvs/engpro-advpl-tlpp-skills★ 166same name
- vespa-engine/skills★ 16same name
- AnyOrgName/php-skills★ 4same name
- nek1987/auto-agent-harness★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- advpl-code-generationSkill
- advpl-code-reviewSkill
- advpl-debuggingSkill
- advpl-refactoringSkill
- advpl-to-tlpp-migrationSkill
- advpr-test-automationSkill
- changelog-patternsSkill
- code-explanationSkill
- documentation-patternsSkill
- embedded-sqlSkill
- probat-testingSkill
- protheus-businessSkill
- protheus-locks-deadlocksSkill
- protheus-referenceSkill
- smartview-developmentSkill
- smartx-developmentSkill
- sx-configurationSkill
- tdn-lookupSkill
The file
Files
Protheus Query Builder
This skill helps build correct, safe, and optimized SQL against Protheus ERP tables, respecting the platform's database conventions: mandatory soft-delete (D_E_L_E_T_) and multi-branch (xFilial) filters, Hungarian-notation field names, dictionary-driven physical schemas (RetSqlName()), and SIX index alignment. It guides the agent to choose the right access pattern -- Workarea navigation vs Embedded SQL vs raw TCSqlExec -- enforce mandatory filters, order WHERE clauses to match available indexes, and parameterize every dynamic value with FWPreparedStatement to eliminate injection risk.
Activate this skill when building any query against Protheus tables (standard SA*/SE*/SF* or custom Z*), deciding between DbSelectArea/DbSeek and Embedded SQL, reviewing code for missing mandatory filters, adding parameterized queries, diagnosing slow queries via index misalignment, or writing cross-database code. It does not cover BeginSQL/EndSQL macro syntax itself (see embedded-sql, its companion skill for macro details), nor record locking semantics during writes (see protheus-locks-deadlocks).
| Reference file | Read when |
| reference.md | Always -- database conventions, table/field naming, mandatory filters, pattern-choice overview |
| patterns-workarea.md | Generating record-by-record code with DbSelectArea + DbSeek + RecLock |
| patterns-fwpreparedstatement.md | Building parameterized TCQuery/TCSqlExec, LIKE clauses, INSERT/UPDATE/DELETE |
| index-awareness.md | Choosing/validating an index, ordering WHERE clauses, common SIX key expressions |
| cross-database.md | Using ChangeQuery(), TCGetDB(), DBAccess macros, MSSQL/PostgreSQL/Oracle equivalents |
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
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.

