SQL and BFF — Executing Predefined Platform Logic
This page is mainly for Skill authors, delivery teams, and Agent maintainers. Business users don't need to know
sqlcodeorfunctionName, let alone enumerate the SQL or BFF entries in the system themselves.
The short version
When the standard data commands aren't enough, the Lovrabet CLI can reuse SQL and BFF entries that already exist on the platform:
sql exec: for complex queries, standardized metrics, and multi-table joinsbff exec: for already-encapsulated business logic, aggregation endpoints, and transactional flows
It also provides:
sql detailbff detail
so maintainers can confirm parameters and definitions.
Why there is no sql list or bff list
That's intentional, not an omission.
The reasoning is simple:
- SQL and BFF entries often carry sensitive business logic
- Business users and general-purpose Agents shouldn't be free to scan and invoke them at will
- The right pattern is for Skill maintainers to write the allowed SQL / BFF entries into the skill, and let the Agent follow the business flow
In other words:
- Business users state "what business result I want"
- Skills decide "which SQL / which BFF to call"
- The Agent performs the actual call
sql detail / sql exec
When SQL is the right fit
- Complex multi-table queries
- Consistent statistical definitions across reports
- Daily or weekly reports, reconciliation results
- Anything
data aggregatealone can't express
View a SQL definition
lovrabet sql detail --sqlcode 2305f915-dd48cd4cExecute SQL
lovrabet sql exec --sqlcode 2305f915-dd48cd4c --params '{"date":"2026-04-20"}'The sqlcode format is:
xxxxxxxx-xxxxxxxxbff detail / bff exec
When BFF is the right fit
- You need the result of an already-encapsulated business endpoint
- The logic spans multiple data sources or multiple steps
- You need a consistent snapshot, view, or processing result
View a BFF definition
lovrabet bff detail --id 42Here --id is the script ID, not the function name.
Execute a BFF
lovrabet bff exec --name processOrder --params '{"orderId":1,"action":"ship"}'Here --name is the function name.
Choosing between SQL and BFF
| The result you need | Better entry point |
|---|---|
| Single-table query or summary | data filter / data aggregate |
| Complex statistics or joins | sql exec |
| An already-encapsulated business flow result | bff exec |
A simple heuristic:
- Feels like "querying the database for a figure" → lean toward SQL
- Feels like "calling a ready-made business endpoint" → lean toward BFF
How business users should phrase requests
Business users usually shouldn't say things like:
- Run
sqlcode=2305...for me - Execute
functionName=processOrder
More natural phrasing:
- Generate yesterday's operations report for me
- Pull a unified after-sales snapshot for this customer
- Find out why this order stopped moving forward
The Agent and the skill then decide whether to call SQL or BFF behind the scenes.
One tip for Skill maintainers
If a business action is frequent, stable, and reusable, don't make the Agent improvise every time. A better approach:
- State explicitly in the skill which SQL / BFF this scenario should use
- Document what parameters the input requires
- Document how to interpret the output
That way business users get "a stable result" — not "a lucky guess at which command to run".