msh ai context
Generate AI-ready context pack for asset or project.
Usage
msh ai context [--asset <asset_id>] [--json] [--include-tests] [--include-history]
Description
Generates a comprehensive context pack containing:
- Project information
- Asset metadata
- Lineage graph
- Glossary terms
- Schemas
- Tests (optional)
- Metrics and policies
Options
--asset <asset_id>: Focus context pack on specific asset (includes upstream/downstream)--json: Output context pack as JSON--include-tests: Include test metadata in context pack--include-history: Include recent run/deploy history
Examples
Generate Project-Level Context Pack
msh ai context
Generates context pack for entire project.
Generate Asset-Focused Context Pack
msh ai context --asset revenue
Generates context pack focused on revenue asset, including upstream and downstream dependencies.
Include Tests and History
msh ai context --asset revenue --include-tests --include-history
Includes test metadata and recent run/deploy history in context pack.
Output as JSON
msh ai context --asset revenue --json
Example JSON Output:
{
"project": {
"id": "my-project",
"name": "My Project",
"warehouse": "postgres",
"default_schema": "public"
},
"assets": [
{
"id": "revenue",
"path": "assets/revenue.msh",
"blocks": {
"ingest": {...},
"transform": {...}
},
"schema": {
"columns": [
{"name": "customer_id", "type": "integer"},
{"name": "month", "type": "date"},
{"name": "monthly_revenue", "type": "decimal"}
]
}
}
],
"lineage": [
{
"from": "stg_orders",
"to": "revenue",
"type": "transform"
}
],
"glossary_terms": [
{
"id": "term.customer",
"name": "Customer",
"description": "A customer entity"
}
],
"schemas": {...},
"tests": [...],
"metrics": [...],
"policies": [...]
}
Use Cases
Preparing Context for AI Commands
Context packs are automatically used by AI commands, but you can generate them manually:
# Generate context pack
msh ai context --asset revenue --json > context.json
# Use in custom AI workflows
Understanding Project Structure
Generate context pack to understand project structure:
msh ai context --json | jq '.assets | length'
Analyzing Dependencies
Focus on specific asset to understand dependencies:
msh ai context --asset revenue
Context Pack Structure
Project Information
- Project ID, name, warehouse, default schema
Assets
- Asset metadata (ID, path, blocks)
- Schema information
- Transform SQL
Lineage
- Upstream dependencies
- Downstream dependencies
- Dependency types
Glossary Terms
- Business terms
- Metrics
- Dimensions
- Policies
Schemas
- Flattened view of schemas per asset
- Column types and constraints
Tests (Optional)
- Test definitions
- Latest test statuses
History (Optional)
- Recent run history
- Deployment history
Prerequisites
-
Manifest: Generate manifest before using context command
msh manifest -
Glossary (optional): Create glossary for better context
msh glossary add-term "Customer" --description "A customer entity"
Optimization
Context packs are optimized for AI consumption:
- Token limits respected
- PII columns masked (based on policies)
- Relevant information prioritized
Related Commands
msh manifest- Generate project manifestmsh inspect- Inspect individual assetmsh ai explain- Uses context pack internally