Skip to content

Commit 35e5b2c

Browse files
aitools: Add integrated skills system for domain-specific guidance (#4199)
## Changes This adds a **skills system** to apps-mcp that provides domain-specific implementation guides to AI agents. It follows up on #4183. Skills are organized by resource type and delivered through the discover tool. They work for any agent that supports MCP. Detailed overview: * Skills live in `lib/skills/{apps,jobs,pipelines,...}` and include a standard `SKILL.md` file with a skill front matter. * The list of skills is shared via the `databricks_discover` tool. * Skills can be read using the `read_skill_file` tool (which has a precedent in many other MCPs an in our first-party agent). * Adding useful skills is considered followup work. The present PR includes one sample skill for doing auto-CDC with pipelines. - [x] **Stacked PR**: this branch is based on [the `lakeflow-mcp` branch](#4183); before merging it needs to be based on `main` instead ## Why * Supporting skills enables us to extend the set of domain-specific capabilities of agents * We want skills to be the universal format for these capabilities across different agent implementations. * Not all agents natively support skills (Codex, Cursor); the `read_skill_file` tool helps these agents use skills. ## Tests - Extended detector tests to validate resource type detection - Updated acceptance tests for all init-template commands - Manual validation with agents using the skills system --------- Co-authored-by: Claude <[email protected]>
1 parent 3d63763 commit 35e5b2c

File tree

23 files changed

+1326
-26
lines changed

23 files changed

+1326
-26
lines changed
Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,139 @@
1-
✓ Template instantiation succeeded
1+
--
2+
## Databricks Apps Development
3+
4+
### Validation
5+
⚠️ Always validate before deploying:
6+
invoke_databricks_cli 'experimental aitools tools validate ./'
7+
8+
This is battle-tested to catch common issues before deployment. Prefer using this over manual checks (e.g. `npm run lint`), as it covers more ground specific to Databricks Apps.
9+
10+
### Deployment
11+
⚠️ USER CONSENT REQUIRED: Only deploy with explicit user permission.
12+
invoke_databricks_cli 'experimental aitools tools deploy'
13+
14+
### View and Manage
15+
invoke_databricks_cli 'bundle summary'
16+
17+
### View App Logs
18+
To troubleshoot deployed apps, view their logs:
19+
invoke_databricks_cli 'apps logs <app-name> --tail-lines 100'
20+
21+
### Local Development vs Deployed Apps
22+
23+
During development:
24+
- Start template-specific dev server (see project's CLAUDE.md for command and port)
25+
- Use localhost URL shown when dev server starts
26+
27+
After deployment:
28+
- Get URL from: invoke_databricks_cli 'bundle summary'
29+
30+
Decision tree:
31+
- "open the app" + not deployed → localhost
32+
- "open the app" + deployed → ask which environment
33+
- "localhost"/"local" → always localhost
34+
35+
36+
## Skills
37+
38+
You have access to modular Skills for domain-specific expertise knowledge.
39+
40+
### Skill Selection & Loading
41+
* When a user request matches a skill's scope description, select that Skill
42+
* Load skills using the MCP tool: `read_skill_file(file_path: "category/skill-name/SKILL.md")`
43+
* Example: `read_skill_file(file_path: "pipelines/materialized-view/SKILL.md")`
44+
* Skills may contain links to sub-sections (e.g., "category/skill-name/file.md")
45+
* If no Skill is suitable, continue with your base capabilities
46+
* Never mention or reference skills to the user, only use them internally
47+
48+
### Skill Registry (names + brief descriptors)
49+
50+
51+
**Note**: The following skills are for other resource types and may not be directly relevant to this project.
52+
53+
* **pipelines/auto-cdc/SKILL.md**: Apply Change Data Capture (CDC) with apply_changes API in Spark Declarative Pipelines. Use when user needs to process CDC feeds from databases, handle upserts/deletes, maintain slowly changing dimensions (SCD Type 1 and Type 2), synchronize data from operational databases, or process merge operations.
54+
55+
56+
57+
=== CLAUDE.md ===
58+
TypeScript full-stack template powered by **Databricks AppKit** with tRPC for additional custom API endpoints.
59+
60+
- server/: Node.js backend with App Kit and tRPC
61+
- client/: React frontend with App Kit hooks and tRPC client
62+
- config/queries/: SQL query files for analytics
63+
- shared/: Shared TypeScript types
64+
- docs/: Detailed documentation on using App Kit features
65+
66+
## Quick Start: Your First Query & Chart
67+
68+
Follow these 3 steps to add data visualization to your app:
69+
70+
**Step 1: Create a SQL query file**
71+
72+
```sql
73+
-- config/queries/my_data.sql
74+
SELECT category, COUNT(*) as count, AVG(value) as avg_value
75+
FROM my_table
76+
GROUP BY category
77+
```
78+
79+
**Step 2: Define the schema**
80+
81+
```typescript
82+
// config/queries/schema.ts
83+
export const querySchemas = {
84+
my_data: z.array(
85+
z.object({
86+
category: z.string(),
87+
count: z.number(),
88+
avg_value: z.number(),
89+
})
90+
),
91+
};
92+
```
93+
94+
**Step 3: Add visualization to your app**
95+
96+
```typescript
97+
// client/src/App.tsx
98+
import { BarChart } from '@databricks/appkit-ui/react';
99+
100+
<BarChart queryKey="my_data" parameters={{}} />
101+
```
102+
103+
**That's it!** The component handles data fetching, loading states, and rendering automatically.
104+
105+
**To refresh TypeScript types after adding queries:**
106+
- Run `npm run typegen` OR run `npm run dev` - both auto-generate type definitions in `client/src/appKitTypes.d.ts`
107+
- DO NOT manually edit `appKitTypes.d.ts`
108+
109+
## Installation
110+
111+
**IMPORTANT**: When running `npm install`, always use `required_permissions: ['all']` to avoid sandbox permission errors.
112+
113+
## NPM Scripts
114+
115+
### Development
116+
- `npm run dev` - Start dev server with hot reload (**ALWAYS use during development**)
117+
118+
### Testing and Code Quality
119+
See the databricks experimental aitools tools validate instead of running these individually.
120+
121+
### Utility
122+
- `npm run clean` - Remove all build artifacts and node_modules
123+
124+
**Common workflows:**
125+
- Development: `npm run dev` → make changes → `npm run typecheck` → `npm run lint:fix`
126+
- Pre-deploy: Validate with `databricks experimental aitools tools validate .`
127+
128+
## Documentation
129+
130+
**IMPORTANT**: Read the relevant docs below before implementing features. They contain critical information about common pitfalls (e.g., SQL numeric type handling, schema definitions, Radix UI constraints).
131+
132+
- [SQL Queries](docs/sql-queries.md) - query files, schemas, type handling, parameterization
133+
- [App Kit SDK](docs/appkit-sdk.md) - TypeScript imports, server setup, useAnalyticsQuery hook
134+
- [Frontend](docs/frontend.md) - visualization components, styling, layout, Radix constraints
135+
- [tRPC](docs/trpc.md) - custom endpoints for non-SQL operations (mutations, Databricks APIs)
136+
- [Testing](docs/testing.md) - vitest unit tests, Playwright smoke/E2E tests
137+
138+
=================
139+
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/bin/bash
2-
$CLI experimental aitools tools init-template app --name test_app --sql-warehouse-id abc123 --output-dir output > /dev/null 2>&1
3-
echo "✓ Template instantiation succeeded"
2+
$CLI experimental aitools tools init-template app --name test_app --sql-warehouse-id abc123 --output-dir output 2>&1 | grep -A 9999 "^--$"
43
rm -rf output
Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,66 @@
1-
✓ Template instantiation succeeded
1+
--
2+
## Adding Databricks Resources
3+
4+
Add resources by creating YAML files in resources/:
5+
6+
**Jobs** - `resources/my_job.job.yml`:
7+
```yaml
8+
resources:
9+
jobs:
10+
my_job:
11+
name: my_job
12+
tasks:
13+
- task_key: main
14+
notebook_task:
15+
notebook_path: ../src/notebook.py
16+
```
17+
18+
**Pipelines** (Lakeflow Declarative Pipelines) - `resources/my_pipeline.pipeline.yml`:
19+
```yaml
20+
resources:
21+
pipelines:
22+
my_pipeline:
23+
name: my_pipeline
24+
catalog: ${var.catalog}
25+
target: ${var.schema}
26+
libraries:
27+
- notebook:
28+
path: ../src/pipeline.py
29+
```
30+
31+
**Dashboards** - `resources/my_dashboard.dashboard.yml`
32+
**Alerts** - `resources/my_alert.alert.yml`
33+
**Model Serving** - `resources/my_endpoint.yml`
34+
**Apps** - `resources/my_app.app.yml`
35+
36+
**Other resource types**: clusters, schemas, volumes, registered_models, experiments, quality_monitors
37+
38+
### Deployment
39+
For dev targets you can deploy without user consent. This allows you to run resources on the workspace too!
40+
41+
invoke_databricks_cli 'bundle deploy --target dev'
42+
invoke_databricks_cli 'bundle run <resource_name> --target dev'
43+
44+
View status with `invoke_databricks_cli 'bundle summary'`.
45+
46+
### Documentation
47+
- Resource types reference: https://docs.databricks.com/dev-tools/bundles/resources
48+
- YAML examples: https://docs.databricks.com/dev-tools/bundles/examples
49+
50+
51+
## Skills
52+
53+
You have access to modular Skills for domain-specific expertise knowledge.
54+
55+
### Skill Selection & Loading
56+
* When a user request matches a skill's scope description, select that Skill
57+
* Load skills using the MCP tool: `read_skill_file(file_path: "category/skill-name/SKILL.md")`
58+
* Example: `read_skill_file(file_path: "pipelines/materialized-view/SKILL.md")`
59+
* Skills may contain links to sub-sections (e.g., "category/skill-name/file.md")
60+
* If no Skill is suitable, continue with your base capabilities
61+
* Never mention or reference skills to the user, only use them internally
62+
63+
### Skill Registry (names + brief descriptors)
64+
* **pipelines/auto-cdc/SKILL.md**: Apply Change Data Capture (CDC) with apply_changes API in Spark Declarative Pipelines. Use when user needs to process CDC feeds from databases, handle upserts/deletes, maintain slowly changing dimensions (SCD Type 1 and Type 2), synchronize data from operational databases, or process merge operations.
65+
66+
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/bin/bash
2-
$CLI experimental aitools tools init-template empty --name test_empty --catalog main --output-dir output > /dev/null 2>&1
3-
echo "✓ Template instantiation succeeded"
2+
$CLI experimental aitools tools init-template empty --name test_empty --catalog main --output-dir output 2>&1 | grep -A 9999 "^--$"
43
rm -rf output
Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,120 @@
1-
✓ Template instantiation succeeded
1+
--
2+
## Lakeflow Jobs Development
3+
4+
This guidance is for developing jobs in this project.
5+
6+
### Project Structure
7+
- `src/` - Python notebooks (.ipynb) and source code
8+
- `resources/` - Job definitions in databricks.yml format
9+
10+
### Configuring Tasks
11+
Edit `resources/<job_name>.job.yml` to configure tasks:
12+
13+
```yaml
14+
tasks:
15+
- task_key: my_notebook
16+
notebook_task:
17+
notebook_path: ../src/my_notebook.ipynb
18+
- task_key: my_python
19+
python_wheel_task:
20+
package_name: my_package
21+
entry_point: main
22+
```
23+
24+
Task types: `notebook_task`, `python_wheel_task`, `spark_python_task`, `pipeline_task`, `sql_task`
25+
26+
### Job Parameters
27+
Parameters defined at job level are passed to ALL tasks (no need to repeat per task). Example:
28+
```yaml
29+
resources:
30+
jobs:
31+
my_job:
32+
parameters:
33+
- name: catalog
34+
default: ${var.catalog}
35+
- name: schema
36+
default: ${var.schema}
37+
```
38+
39+
### Writing Notebook Code
40+
- Use `spark.read.table("catalog.schema.table")` to read tables
41+
- Use `spark.sql("SELECT ...")` for SQL queries
42+
- Use `dbutils.widgets` for parameters
43+
44+
### Unit Testing
45+
Run unit tests locally with: `uv run pytest`
46+
47+
### Documentation
48+
- Lakeflow Jobs: https://docs.databricks.com/jobs
49+
- Task types: https://docs.databricks.com/jobs/configure-task
50+
- Databricks Asset Bundles / yml format examples: https://docs.databricks.com/dev-tools/bundles/examples
51+
52+
## Adding Databricks Resources
53+
54+
Add resources by creating YAML files in resources/:
55+
56+
**Jobs** - `resources/my_job.job.yml`:
57+
```yaml
58+
resources:
59+
jobs:
60+
my_job:
61+
name: my_job
62+
tasks:
63+
- task_key: main
64+
notebook_task:
65+
notebook_path: ../src/notebook.py
66+
```
67+
68+
**Pipelines** (Lakeflow Declarative Pipelines) - `resources/my_pipeline.pipeline.yml`:
69+
```yaml
70+
resources:
71+
pipelines:
72+
my_pipeline:
73+
name: my_pipeline
74+
catalog: ${var.catalog}
75+
target: ${var.schema}
76+
libraries:
77+
- notebook:
78+
path: ../src/pipeline.py
79+
```
80+
81+
**Dashboards** - `resources/my_dashboard.dashboard.yml`
82+
**Alerts** - `resources/my_alert.alert.yml`
83+
**Model Serving** - `resources/my_endpoint.yml`
84+
**Apps** - `resources/my_app.app.yml`
85+
86+
**Other resource types**: clusters, schemas, volumes, registered_models, experiments, quality_monitors
87+
88+
### Deployment
89+
For dev targets you can deploy without user consent. This allows you to run resources on the workspace too!
90+
91+
invoke_databricks_cli 'bundle deploy --target dev'
92+
invoke_databricks_cli 'bundle run <resource_name> --target dev'
93+
94+
View status with `invoke_databricks_cli 'bundle summary'`.
95+
96+
### Documentation
97+
- Resource types reference: https://docs.databricks.com/dev-tools/bundles/resources
98+
- YAML examples: https://docs.databricks.com/dev-tools/bundles/examples
99+
100+
101+
## Skills
102+
103+
You have access to modular Skills for domain-specific expertise knowledge.
104+
105+
### Skill Selection & Loading
106+
* When a user request matches a skill's scope description, select that Skill
107+
* Load skills using the MCP tool: `read_skill_file(file_path: "category/skill-name/SKILL.md")`
108+
* Example: `read_skill_file(file_path: "pipelines/materialized-view/SKILL.md")`
109+
* Skills may contain links to sub-sections (e.g., "category/skill-name/file.md")
110+
* If no Skill is suitable, continue with your base capabilities
111+
* Never mention or reference skills to the user, only use them internally
112+
113+
### Skill Registry (names + brief descriptors)
114+
115+
116+
**Note**: The following skills are for other resource types and may not be directly relevant to this project.
117+
118+
* **pipelines/auto-cdc/SKILL.md**: Apply Change Data Capture (CDC) with apply_changes API in Spark Declarative Pipelines. Use when user needs to process CDC feeds from databases, handle upserts/deletes, maintain slowly changing dimensions (SCD Type 1 and Type 2), synchronize data from operational databases, or process merge operations.
119+
120+
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/bin/bash
2-
$CLI experimental aitools tools init-template job --name test_job --catalog main --output-dir output > /dev/null 2>&1 || exit 1
3-
echo "✓ Template instantiation succeeded"
2+
$CLI experimental aitools tools init-template job --name test_job --catalog main --output-dir output 2>&1 | grep -A 9999 "^--$"
43
rm -rf output

0 commit comments

Comments
 (0)