| name | add-feature |
|---|---|
| description | Add new T-SQL features to ScriptDOM parser. Asks questions about SQL Server version and feature type, then guides through grammar changes, AST updates, script generation, and testing using existing instruction files. Handles syntax additions, new functions, data types, index types, and validation rules. |
| argument-hint | Feature description (e.g., 'Add VECTOR data type', 'Add JSON_OBJECT function') |
| user-invocable | true |
| platforms | SQL Server, Azure SQL DB, Fabric, Fabric DW, VNext |
This skill helps add new T-SQL features to the ScriptDOM parser by:
- Interviewing you about the feature and target platform (SQL Server, Azure SQL DB, Fabric, Fabric DW, VNext)
- Determining the latest parser version from
SqlVersionFlags.cs - Routing you to the appropriate parser:
- SQL Server → version-specific parser (TSql120-180)
- Azure SQL DB/Fabric/VNext → latest parser version
- Fabric DW → separate TSqlFabricDW parser
- Classifying the change type (grammar, validation, function, data type, etc.)
- Guiding through implementation and testing without duplicating existing documentation
Ask the user these questions to understand the feature:
-
What T-SQL feature are you adding?
- Example: "VECTOR data type", "JSON_OBJECT function", "RESUMABLE option for ALTER TABLE"
-
Which platform is this feature for?
- SQL Server (on-premises / standalone)
- Azure SQL Database (uses latest parser version)
- Fabric (uses latest parser version)
- Fabric DW (uses separate TSqlFabricDW parser)
- VNext (future version, uses latest parser version unless repo instructions say otherwise)
-
If SQL Server, which version introduced this feature?
- SQL Server 2014 (TSql120)
- SQL Server 2016 (TSql130)
- SQL Server 2017 (TSql140)
- SQL Server 2019 (TSql150)
- SQL Server 2022 (TSql160)
- SQL Server 2025 (TSql170)
- SQL Server vNext (TSql180)
- (Skip if Azure SQL DB, Fabric, or VNext - these use TSql180 by default)
-
Do you have example T-SQL syntax or Microsoft documentation links?
- This helps verify the exact syntax requirements
-
Is this a new syntax element or enabling existing syntax in a new context?
- New syntax: Requires grammar rules, AST nodes
- Validation fix: May only need version checks in validation code
-
Does similar syntax already work in other contexts?
- Example: "RESUMABLE works for ALTER INDEX but not ALTER TABLE"
- This indicates a validation issue rather than missing grammar
Based on the answers, classify the feature into one of these types:
Indicators:
- Similar syntax already works elsewhere in SQL
- Error message says "Option 'X' is not valid..." or "Feature 'Y' not supported..."
- The grammar may already parse it, but validation blocks it
→ Route to: grammar_validation.guidelines.instructions.md
Indicators:
- Completely new statement, clause, or operator
- Error says "Incorrect syntax near..." or "Unexpected token..."
- Parser doesn't recognize the syntax at all
→ Route to: bug_fixing.guidelines.instructions.md
Indicators:
- Adding a new built-in T-SQL function (e.g., JSON_OBJECT, STRING_AGG)
- May need special handling for RETURN statement contexts
→ Route to: function.guidelines.instructions.md
Indicators:
- Adding a completely new SQL Server data type (e.g., VECTOR, GEOGRAPHY)
- Requires custom parameter syntax (e.g.,
VECTOR(1536, FLOAT32))
→ Route to: new_data_types.guidelines.instructions.md
Indicators:
- Adding a new CREATE INDEX variant (e.g., VECTOR INDEX, JSON INDEX)
- Requires specialized syntax different from standard indexes
→ Route to: new_index_types.guidelines.instructions.md
Indicators:
- Identifier-based predicate works without parentheses but fails with them
- Error near closing parenthesis:
WHERE (REGEXP_LIKE(...))fails
→ Route to: parser.guidelines.instructions.md
Indicators:
- Adding a database option for ALTER DATABASE or CREATE DATABASE statements
- Simple ON/OFF option (e.g.,
SET AUTOMATIC_INDEX_COMPACTION = ON) - Complex option with sub-options (e.g.,
SET CHANGE_TRACKING (AUTO_CLEANUP = ON)) - Enum-based option (e.g.,
SET RECOVERY FULL)
→ Route to: database_option.guidelines.instructions.md
For grammar changes (Types B, C, D, E, G), follow this workflow:
First, determine the latest parser version:
Check SqlScriptDom/Parser/TSql/SqlVersionFlags.cs for the highest TSql version enum value.
Then select the appropriate grammar file:
- SQL 2014+: TSql120.g
- SQL 2016+: TSql130.g
- SQL 2017+: TSql140.g
- SQL 2019+: TSql150.g
- SQL 2022+: TSql160.g
- SQL 2025+: TSql170.g
- SQL Server vNext: TSql180.g
- Use the latest parser version (currently TSql180.g)
- Check
SqlVersionFlags.csto confirm the highest version
- Use TSqlFabricDW.g (separate parser with Fabric-specific syntax)
Reference: grammar.guidelines.instructions.md
Key patterns:
- Use
this.FragmentFactory.CreateFragment<Type>()for AST nodes - Use syntactic predicates
(LA(1) == Token)for lookahead - Avoid modifying shared grammar rules (create specialized versions instead)
- Include proper script generation in
ScriptGenerator
If adding new AST nodes:
- Edit
SqlScriptDom/Parser/TSql/Ast.xml - Rebuild to regenerate visitor classes
- Implement script generation in
SqlScriptDom/ScriptDom/SqlServer/ScriptGenerator
Reference: testing.guidelines.instructions.md
-
Input Script:
Test/SqlDom/TestScripts/YourFeature.sql- Include all syntax variations
- Test edge cases, parameters, expressions
-
Baseline:
Test/SqlDom/Baselines<version>/YourFeature.sql- Expected pretty-printed output after parse → script gen → reparse
In Test/SqlDom/Only<version>SyntaxTests.cs:
[TestMethod]
public void YourFeatureTest()
{
ParserTest<version>("YourFeature.sql");
}Add to the OnlyFabricDWTestInfos array in Test/SqlDom/OnlyFabricDWSyntaxTests.cs:
new ParserTestFabricDW("YourFeatureFabricDW.sql",
nErrors80: X, nErrors90: Y, nErrors100: Z,
nErrors110: A, nErrors120: B, nErrors130: C,
nErrors140: D, nErrors150: E, nErrors160: F, nErrors170: G, nErrors180: H),(Set expected error counts for each parser version)
Simplified patterns available - see testing guidelines for:
ParserTestAllowingErrors- for scripts with expected parse errorsParserTestOutputconstructors - for custom output verification- Error message verification - exact match or fragment-based
# Build to regenerate parser
dotnet build SqlScriptDom/Microsoft.SqlServer.TransactSql.ScriptDom.csproj -c Debug
# Run specific test
dotnet test --filter "FullyQualifiedName~YourFeatureTest" -c Debug
# ALWAYS run full suite before committing
dotnet test Test/SqlDom/UTSqlScriptDom.csproj -c DebugReference: debugging_workflow.guidelines.instructions.md
Common issues:
- Tests fail after grammar changes: Likely modified a shared rule - create specialized version
- Script generation mismatch: Update
ScriptGeneratorfor your AST nodes - Version errors: Check validation code in
TSql80ParserBaseInternal.cs
Before marking the feature complete:
- Grammar rules added/modified in correct
TSql<version>.gorTSqlFabricDW.gfile - AST nodes defined in
Ast.xml(if new nodes needed) - Script generation implemented for new AST nodes
- Validation rules updated (if version-gated)
- Test script created in
TestScripts/(use appropriate suffix:.sqlorFabricDW.sql) - Baseline created in
Baselines<version>/orBaselinesFabricDW/ - Test method added to
Only<version>SyntaxTests.csorOnlyFabricDWSyntaxTests.cs - All tests pass (including full test suite)
- No regressions in unrelated tests
| Component | Path |
|---|---|
| Grammar files (SQL Server) | SqlScriptDom/Parser/TSql/TSql*.g |
| Grammar file (Fabric DW) | SqlScriptDom/Parser/TSql/TSqlFabricDW.g |
| Version detection | SqlScriptDom/Parser/TSql/SqlVersionFlags.cs |
| AST definition | SqlScriptDom/Parser/TSql/Ast.xml |
| Script generator | SqlScriptDom/ScriptDom/SqlServer/ScriptGenerator |
| Validation code | SqlScriptDom/Parser/TSql/TSql80ParserBaseInternal.cs |
| Test scripts | Test/SqlDom/TestScripts/ |
| Baselines | Test/SqlDom/Baselines<version>/ or BaselinesFabricDW/ |
| Test classes | Test/SqlDom/Only<version>SyntaxTests.cs or FabricDWSyntaxTests.cs |
When invoked, the agent should:
- Determine the latest parser version by reading
SqlScriptDom/Parser/TSql/SqlVersionFlags.cs - Interview the user using the questions in Step 1
- Ask about platform (SQL Server, Azure SQL DB, Fabric, Fabric DW, VNext)
- For Azure/Fabric/VNext → use latest parser version
- For Fabric DW → use TSqlFabricDW.g
- For SQL Server → ask for specific version
- Classify the feature type using Step 2 criteria
- Load the appropriate instruction file using
read_filetool - Guide through implementation by referencing specific sections of the loaded instruction file
- Execute the development workflow:
- Make grammar/validation changes
- Regenerate parser (build)
- Create test files
- Run tests
- Debug failures
- Verify completeness using Step 6 checklist
Never duplicate content from instruction files - always reference and quote specific sections.