- 13. Integrating SQLcl Project with GitHub Copilot
This guide explains how to integrate the SQLcl Project Copilot instructions into your own repository so that GitHub Copilot (Agent mode) understands your SQLcl Liquibase-based deployment pipeline and can assist with it effectively.
The instructions encode transferable patterns for project stage, project export, and project stage add-custom workflows so Copilot behaves correctly — running only what is safe to run autonomously and prompting you for steps that must remain under your control.
With this integration, Copilot can:
- Check for an active database connection before attempting any SQLcl project commands.
- Export database objects directly via MCP on SQLcl 26.1+, or provide the command for you to copy-paste on older versions. Includes smart APEX app handling (pre-deletes stale files before export).
- Run
project stageautomatically via MCP on SQLcl 26.1+, then immediately split the generated changeset files. On older versions, defers to you and walks you through what to do next. - Create custom DML files (seed data, reference data) using
project stage add-customdirectly via MCP. - Populate DML files with properly formatted Liquibase changesets following the correct template (initial population vs. incremental updates).
- Split changeset files per schema object — each DDL statement into its own numbered changeset.
- Deploy to target environments — run
@install.sql, analyze output, validate object counts, and troubleshoot failures. - Set up APEX workspaces and admin users via
project stage add-customscripts. - Respect branch immutability — never editing changeset files from deployed branches.
Copilot will not:
- Create files under
dist/releases/manually (always usesproject stageorproject stage add-custom). - Run project commands without a verified active database connection.
- Guess which schema to use — if it cannot determine the schema from
copilot-instructions.mdor.dbtools/project.config.json, it stops and asks.
- SQLcl installed and available as
sqlon yourPATH.- SQLcl 26.1 or later is strongly recommended. On older versions, Copilot cannot run
project exportorproject stagedirectly and will defer those commands to you.
- SQLcl 26.1 or later is strongly recommended. On older versions, Copilot cannot run
- VS Code with GitHub Copilot extension (Agent mode / MCP support).
- Your SQLcl Project repository set up per 1. Installation and Configuration.
Copy .github/sqlcl_project_copilot_instructions.md from this sample repo into your own repo's .github/ folder:
your-repo/
└── .github/
└── sqlcl_project_copilot_instructions.md ← copy this file here
This file contains the core instructions Copilot reads to understand your SQLcl Project workflows. You should not need to edit it — project-specific settings go in your copilot-instructions.md (see 13.5. Project-Specific Configuration).
In your own .github/copilot-instructions.md, add a link to the instructions file so Copilot picks them up:
See [SQLcl Project Copilot Instructions](sqlcl_project_copilot_instructions.md)Your copilot-instructions.md is also where you add project-specific settings like the database connection name. For example:
# My Project
## Project Configuration
**Database Connection:** This project uses the `my_connection` connection for all SQLcl operations.
See [SQLcl Project Copilot Instructions](sqlcl_project_copilot_instructions.md)Add the following to .vscode/mcp.json in your repo:
{
"servers": {
"sqlcl.local": {
"type": "stdio",
"command": "sql",
"args": ["-R", "0", "-mcp"]
}
}
}This tells VS Code to start SQLcl as an MCP server, allowing Copilot to run SQLcl commands (queries, project stage add-custom, etc.) on your behalf without leaving the editor.
After linking the shared instructions, customize your own .github/copilot-instructions.md with any project-specific settings:
| Setting | Where to Add | Example |
|---|---|---|
| Database connection name | copilot-instructions.md |
**Database Connection:** This project uses the \my_connection` connection.` |
| Schema names | copilot-instructions.md |
List your tracked schemas (e.g. **Schemas:** MYAPP, MYAPP_API). Copilot uses this to set current_schema before queries — if it can't determine the schema, it will stop and ask rather than guess. |
| Any project-specific overrides | copilot-instructions.md |
Additional rules or context Copilot should know. |
Copilot reads both files and merges the context. If schema names are not in copilot-instructions.md, Copilot will fall back to inspecting .dbtools/project.config.json. For projects with a single schema this is sufficient; for multi-schema projects, listing them explicitly in copilot-instructions.md avoids Copilot stopping to ask.
After completing setup, open GitHub Copilot Chat in Agent mode and try:
List my current SQLcl connections.
Copilot should use the MCP server to call list-connections and return the result. If you see an error or Copilot has no tools available, check:
.vscode/mcp.jsonexists andsqlis on yourPATH(runsql -Vin a terminal to verify).- VS Code has loaded the MCP server — check Output → MCP for startup messages.
- The Copilot extension is updated to a version that supports MCP/Agent mode.
The instructions encode a deliberate division of responsibility:
| Action | Copilot behaviour |
|---|---|
project export -o <OBJECTS> |
SQLcl ≥ 26.1: Runs directly via MCP (async), polls until complete. Older SQLcl: Provides the command for you to copy-paste, with an upgrade nudge. |
project stage add-custom |
Runs automatically via MCP, then populates the generated file. |
project stage |
SQLcl ≥ 26.1: Runs via MCP after confirming your work is committed — then immediately proceeds to split the generated changesets. Older SQLcl: Defers to you and guides you through the next steps. |
| Changeset splitting | Applies automatically after project stage, or on demand when you ask. Each DDL statement becomes its own numbered changeset. |
Deployment (@install.sql) |
Connects to the target environment, runs the install script, analyzes output, validates object counts, and reports or troubleshoots failures. Always confirms the target environment before deploying. |
| Editing deployed branch changesets | Never does this — branch immutability is enforced. |
| Running commands without a connection | Refuses — always checks for an active connection first. |
| Schema selection | Reads from copilot-instructions.md, falls back to .dbtools/project.config.json. If still unclear — stops and asks, never guesses. |
See copilot/copilot-testing-sqlclproject.md for a set of test cases you can run against your own configured repo to verify Copilot is behaving correctly. The test cases cover:
- Exporting tables to the repository
- Creating and populating DML files
- Adding records and regenerating DML
- Splitting changeset files
- Multi-step feature branch workflows
Run through these scenarios (substituting your own schema/table names) to confirm your setup is working end to end.