tsqlapp-navigator
npx machina-cli add skill rhodelta66/tsqlapp-skills/tsqlapp-navigator --openclawTSQL.APP Navigator
Navigate TSQL.APP applications by querying the metadata database. Parse URLs, discover actions, and explain application state.
Two-Database Architecture
Every TSQL.APP application = 2 databases:
| Database | Purpose | Contains |
|---|---|---|
{app} | Business data | Tables, views, stored procedures |
{app}_proj | Application definition | Cards, fields, actions, children |
MCP connects to {app}_proj. Get business DB name: SELECT dbo.main_db()
URL Pattern
https://{domain}/{card}[/{parent_id}/{child_card}]?[ord={field_id}[d]][,{field_id}][&red={filter_name}][&id={record_id}]
| Parameter | Example | Meaning |
|---|---|---|
{card} | incoming_invoice | Card name (path) |
{parent_id} | 142338 | Parent record ID (child context) |
{child_card} | invrow_1 | Child card name |
ord | 18377d | Sort field ID, d=descending |
ord | 32408,30233 | Multi-field sort |
red | Draft+%2F+Empty | Active filter (URL encoded) |
id | 142338 | Selected record ID |
Core Meta Tables
api_card
SELECT id, name, tablename, basetable, reducer FROM api_card WHERE name = @card_name
tablename= READ (view for display)basetable= WRITE (table for CRUD)
api_card_fields
SELECT id, name, list_order FROM api_card_fields WHERE card_id = @card_id
id= field ID used inordURL parameter
api_card_actions
SELECT id, name, display_name, action, keycode, group_id, type, disabled
FROM api_card_actions WHERE card_id = @card_id
action='stored_procedure'(button) or'reducer'(filter)keycode= keyboard shortcutgroup_id= parent sub-menu (NULL = top level)type='list','form','list_form','hidden'
api_card_children
SELECT child, ref, keycode, unbound, reducer, is_hidden, group_id
FROM api_card_children WHERE parent = @card_id
keycode= navigation shortcut (e.g.,'Enter')ref= FK column linking parent to childunbound=0(filter by ref) or1(custom reducer)
Action Hierarchy
Card
├── Top-level (group_id IS NULL)
│ ├── Buttons (action='stored_procedure')
│ ├── Filters (action='reducer')
│ └── Sub-menus (referenced as group_id)
└── Sub-menu contents (group_id = sub-menu.id)
Keyboard sequence: {submenu_keycode} → {action_keycode}
Standard Queries
Parse URL
-- Card info
SELECT id, name, tablename, basetable FROM api_card WHERE name = @card_name
-- Sort field (from ord parameter)
SELECT name FROM api_card_fields WHERE id = @field_id
-- Filter (from red parameter, URL decoded)
SELECT id, sql FROM api_card_actions
WHERE card_id = @card_id AND name = @filter_name AND action = 'reducer'
List All Actions with Shortcuts
SELECT
CASE WHEN g.keycode IS NOT NULL
THEN CONCAT(g.keycode, ' → ', ISNULL(a.keycode, '-'))
ELSE ISNULL(a.keycode, '-')
END as shortcut,
a.name,
CASE a.action WHEN 'reducer' THEN 'filter' ELSE 'button' END as type,
a.disabled
FROM api_card_actions a
LEFT JOIN api_card_actions g ON a.group_id = g.id
WHERE a.card_id = @card_id
ORDER BY COALESCE(a.group_id, 0), a.action_order
List Children with Navigation
SELECT
acc.keycode,
c.name as child_card,
acc.ref as link_column,
CASE acc.unbound WHEN 1 THEN 'custom' ELSE 'bound' END as filter_type
FROM api_card_children acc
JOIN api_card c ON acc.child = c.id
WHERE acc.parent = @card_id AND ISNULL(acc.is_hidden, 0) = 0
ORDER BY acc.keycode
Find What Enter Does
SELECT c.name as child_card, acc.ref
FROM api_card_children acc
JOIN api_card c ON acc.child = c.id
WHERE acc.parent = @card_id AND acc.keycode = 'Enter'
Predict Next URL (Child Navigation)
-- Current: /{card}?id={record_id}
-- After Enter: /{card}/{record_id}/{child_card}
SELECT CONCAT('/', @card, '/', @record_id, '/', c.name) as next_url
FROM api_card_children acc
JOIN api_card c ON acc.child = c.id
WHERE acc.parent = @card_id AND acc.keycode = 'Enter'
Response Pattern
When user shares URL:
- Parse - Extract card, parent/child, sort, filter, selection
- Query - Look up card, fields, actions, children in metadata
- Explain - Current view, active filter, selected record
- List - Available actions with keyboard shortcuts
- Predict - What happens on common keys (Enter, etc.)
Critical Rules
- Do NOT guess - Query metadata for exact values
- URL is state - Every URL is a complete deep link
- Metadata is truth - If it's in the meta tables, it's accurate
- Actions have hierarchy - Check group_id for sub-menus
- Children have shortcuts - Check api_card_children.keycode
Reference
For detailed architecture and examples, see references/architecture.md.
Source
git clone https://github.com/rhodelta66/tsqlapp-skills/blob/main/tsqlapp-navigator/SKILL.mdView on GitHub Overview
Navigate TSQL.APP applications by querying the metadata database. This skill parses TSQL.APP URLs to reveal card context, parent/child relationships, sorts, and active filters, then explains what you’re seeing and what you can do. It relies on a two-database architecture: {app} for business data and {app}_proj for application definitions.
How This Skill Works
The skill parses the URL to identify the current card, parent/child context, sort (ord), and filters (red). It then queries core meta tables—api_card, api_card_fields, api_card_actions, and api_card_children—to describe the UI state, list actions and shortcuts, and map navigation between cards.
When to Use It
- When a user shares a TSQL.APP URL and you need to quickly explain the card, context, and current view.
- When you want to understand which cards, screens, actions, buttons, and filters exist for a card.
- When you need to enumerate available actions (buttons) and filters (reducers) and their shortcuts.
- When you’re exploring parent–child relationships to navigate from a parent card to a child card.
- When locating features in a TSQL.APP app by parsing a URL and describing the underlying state in the meta DB.
Quick Start
- Step 1: Parse the URL to extract card, parent_id, child_card, ord, red, and id to establish context.
- Step 2: Query api_card, api_card_fields, api_card_actions, and api_card_children to build a map of fields, actions, and navigation.
- Step 3: Present the current view state (card name, context, active filters, sort) and list available actions and next navigation steps.
Best Practices
- Always start by parsing the URL to identify card, parent_id, child_card, ord, red, and id.
- Query api_card, api_card_fields, api_card_actions, and api_card_children to map UI elements to their data definitions.
- Decode URL-encoded filters in red to present human-friendly filter names and criteria.
- Cross-check the target app’s {app} and {app}_proj definitions against the main business DB name via SELECT dbo.main_db().
- Provide a concise explanation of the current view, followed by the next actionable steps or related cards.
Example Use Cases
- A user shares https://domain/incoming_invoice and you describe the card, active filters, sort order, and present available actions.
- You reveal the parent–child relationship by showing how to navigate from a parent card to a child card like invrow_1 using api_card_children.
- You identify the sort field from ord (e.g., 18377d) by mapping field_id to a field name via api_card_fields.
- You list all actions for a card, including which are buttons (stored_procedure) vs filters (reducer) and their keyboard shortcuts.
- You decode a filter like red=Draft+%2F+Empty into readable criteria and show how it affects the current view.