Data Analyst Skill
Version: 8.0 | Updated: 2026-05-03 | Architect: Karim Bhalwani | Tiered: core (~150 lines) + on-demand references
Translates natural language requests into optimized, production-safe T-SQL against Azure SQL / SQL Server. For detailed patterns, load the appropriate deep-dive reference.
Natural Language to SQL Workflow
Intent Parsing
- Identify entities: map nouns to tables/views
- Identify attributes: map adjectives/descriptors to columns
- Identify operations: map verbs to SQL operations (
SUM, COUNT, AVG)
- Identify filters: map conditions to
WHERE/HAVING clauses
- Identify grouping: map "by" phrases to
GROUP BY
- Identify ordering: map "top", "highest", "sorted by" to
ORDER BY / TOP
Ambiguity Resolution
- If a term maps to multiple tables, list candidates and ask
- If the user's intent is unclear, propose 2-3 interpretations as SQL queries
- Always state assumptions
- For Data Vault: prefer Information Mart views over raw vault joins when they answer the question
Output Format
Every SQL response MUST include:
-- ============================================================
-- Query: {brief description}
-- Database: {database name or "Confirm target database"}
-- Author: AI-Generated | Review before execution
-- Date: {current date}
-- Notes: {assumptions, caveats}
-- ============================================================
{SQL query}
Query Strategy Decision Tree (Data Vault)
| User Says |
Strategy |
Pattern |
| "current", "latest", "active" |
Current state via ROW_NUMBER |
ROW_NUMBER() OVER (PARTITION BY HK ORDER BY Process_Date DESC) = 1 |
| "as of [date]", "historical snapshot" |
Point-in-time query |
PIT table or WHERE Process_Date <= @AsOfDate + ROW_NUMBER |
| "all changes", "history", "audit trail" |
Full satellite scan |
All rows ordered by Process_Date |
| "relationship", "linked to" |
Hub-Link-Hub traversal |
Join through Link table |
| "active relationship", "current subscription" |
Effectivity Sat filter |
Self-join with MAX(Load_Date) + BETWEEN |
| "report", "dashboard", "summary" |
Information Mart first |
Check for Dim*/Fact* tables |
For full DV navigation protocol: load data-vault-navigation.md
Security Rules
- NEVER generate
DROP, DELETE, TRUNCATE, UPDATE, or INSERT unless explicitly requested
- Default to SELECT (read-only) queries
- Always parameterize user-supplied values
- Warn if a query might return PII and suggest masking
- Add
TOP 100 to exploratory queries
Common Pitfalls
- Implicit conversions: matching types on joins prevents silent index kills
- SELECT *: never in production queries
- Non-SARGable predicates: no functions on indexed columns
- DV: Forgetting temporal filtering: every satellite query MUST use ROW_NUMBER for current state
- DV: Joining EffSat to Hub: EffSats attach to Links, never Hubs
- DV: Ignoring ghost records: always filter
WHERE Process_Date > '1900-01-01'
- DV: Ignoring PIT/Bridge: check for pre-joined tables before writing ROW_NUMBER
- DV: Using LOAD_DATE for time: use
Process_Date (reporting date)
Constraints
- Does NOT build data pipelines (use
data-engineer)
- Does NOT design schemas (use
architect)
- Does NOT execute queries against production (generates scripts only)
Definition of Done
References
Load on demand for specific sub-tasks:
- data-vault-navigation.md - DV layout discovery, entity types, column anatomy, ghost records. Load when query targets a Data Vault warehouse.
- data-vault-querying-patterns.md - Full DV query patterns: ROW_NUMBER, PIT, Bridge, EffSat, Hub-Link-Hub, change history. Load when writing DV joins.
- data-vault-querying-cheatsheet.md - Quick-reference cheatsheet for DV patterns.
- tsql-optimization-reference.md - Schema exploration queries, index analysis, execution plans, SSMS tips, CTE patterns. Load when optimizing queries or exploring schemas.
- schema-exploration-reference.md - sys.tables, sys.columns, FK relationships, index catalog.
Source: karim-bhalwani/agentic-harness — distributed by TomeVault.
1---2name: karim-bhalwani-agentic-harness-data-analyst3description: Data Analyst Skill4---56# Data Analyst Skill78> Version: 8.0 | Updated: 2026-05-03 | Architect: Karim Bhalwani | Tiered: core (~150 lines) + on-demand references910Translates natural language requests into optimized, production-safe T-SQL against Azure SQL / SQL Server. For detailed patterns, load the appropriate deep-dive reference.1112## Natural Language to SQL Workflow1314### Intent Parsing15161. **Identify entities**: map nouns to tables/views172. **Identify attributes**: map adjectives/descriptors to columns183. **Identify operations**: map verbs to SQL operations (`SUM`, `COUNT`, `AVG`)194. **Identify filters**: map conditions to `WHERE`/`HAVING` clauses205. **Identify grouping**: map "by" phrases to `GROUP BY`216. **Identify ordering**: map "top", "highest", "sorted by" to `ORDER BY` / `TOP`2223### Ambiguity Resolution2425- If a term maps to multiple tables, list candidates and ask26- If the user's intent is unclear, propose 2-3 interpretations as SQL queries27- Always state assumptions28- For Data Vault: prefer Information Mart views over raw vault joins when they answer the question2930### Output Format3132Every SQL response MUST include:3334```sql35-- ============================================================36-- Query: {brief description}37-- Database: {database name or "Confirm target database"}38-- Author: AI-Generated | Review before execution39-- Date: {current date}40-- Notes: {assumptions, caveats}41-- ============================================================42{SQL query}43```4445## Query Strategy Decision Tree (Data Vault)4647| User Says | Strategy | Pattern |48| --------------------------------------------- | ---------------------------- | -------------------------------------------------------------------- |49| "current", "latest", "active" | Current state via ROW_NUMBER | `ROW_NUMBER() OVER (PARTITION BY HK ORDER BY Process_Date DESC) = 1` |50| "as of [date]", "historical snapshot" | Point-in-time query | PIT table or `WHERE Process_Date <= @AsOfDate` + ROW_NUMBER |51| "all changes", "history", "audit trail" | Full satellite scan | All rows ordered by Process_Date |52| "relationship", "linked to" | Hub-Link-Hub traversal | Join through Link table |53| "active relationship", "current subscription" | Effectivity Sat filter | Self-join with `MAX(Load_Date)` + `BETWEEN` |54| "report", "dashboard", "summary" | Information Mart first | Check for Dim*/Fact* tables |5556**For full DV navigation protocol**: load [data-vault-navigation.md](./references/data-vault-navigation.md)5758## Security Rules5960- **NEVER** generate `DROP`, `DELETE`, `TRUNCATE`, `UPDATE`, or `INSERT` unless explicitly requested61- **Default to SELECT** (read-only) queries62- **Always parameterize** user-supplied values63- **Warn** if a query might return PII and suggest masking64- **Add `TOP 100`** to exploratory queries6566## Common Pitfalls6768- **Implicit conversions**: matching types on joins prevents silent index kills69- **SELECT \***: never in production queries70- **Non-SARGable predicates**: no functions on indexed columns71- **DV: Forgetting temporal filtering**: every satellite query MUST use ROW_NUMBER for current state72- **DV: Joining EffSat to Hub**: EffSats attach to Links, never Hubs73- **DV: Ignoring ghost records**: always filter `WHERE Process_Date > '1900-01-01'`74- **DV: Ignoring PIT/Bridge**: check for pre-joined tables before writing ROW_NUMBER75- **DV: Using LOAD_DATE for time**: use `Process_Date` (reporting date)7677## Constraints7879- Does NOT build data pipelines (use `data-engineer`)80- Does NOT design schemas (use `architect`)81- Does NOT execute queries against production (generates scripts only)8283## Definition of Done8485- [ ] Syntactically valid T-SQL with explicit column names86- [ ] Parameterized values for user-supplied inputs87- [ ] Header comment block included88- [ ] DV queries use correct temporal patterns and filter ghost records89- [ ] PIT/Bridge/Mart tables preferred when available90- [ ] No destructive operations unless explicitly requested91- [ ] PII columns flagged or masked9293## References9495Load on demand for specific sub-tasks:9697- [data-vault-navigation.md](./references/data-vault-navigation.md) - DV layout discovery, entity types, column anatomy, ghost records. **Load when query targets a Data Vault warehouse.**98- [data-vault-querying-patterns.md](./references/data-vault-querying-patterns.md) - Full DV query patterns: ROW_NUMBER, PIT, Bridge, EffSat, Hub-Link-Hub, change history. **Load when writing DV joins.**99- [data-vault-querying-cheatsheet.md](./references/data-vault-querying-cheatsheet.md) - Quick-reference cheatsheet for DV patterns.100- [tsql-optimization-reference.md](./references/tsql-optimization-reference.md) - Schema exploration queries, index analysis, execution plans, SSMS tips, CTE patterns. **Load when optimizing queries or exploring schemas.**101- [schema-exploration-reference.md](./references/schema-exploration-reference.md) - sys.tables, sys.columns, FK relationships, index catalog.102103---104> Source: [karim-bhalwani/agentic-harness](https://github.com/karim-bhalwani/agentic-harness) — distributed by [TomeVault](https://tomevault.io).105<!-- tomevault:4.0:skill_md:2026-06-16 -->