Skip to content

DOC: add copilot-instructions.md for coding-agent guidance#406

Merged
bewithgaurav merged 4 commits into
microsoft:mainfrom
dlevy-msft-sql:docs/llm-usage-guide
Jul 16, 2026
Merged

DOC: add copilot-instructions.md for coding-agent guidance#406
bewithgaurav merged 4 commits into
microsoft:mainfrom
dlevy-msft-sql:docs/llm-usage-guide

Conversation

@dlevy-msft-sql

@dlevy-msft-sql dlevy-msft-sql commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

Work Item / Issue Reference

GitHub Issue: #247


Summary

adds .github/copilot-instructions.md: a from-scratch, repo-wide guide for coding agents working on mssql-python. it covers the architecture (python -> pybind ddbc_bindings -> odbc, with py-core/tds for bulk copy), the validated build/test/validation-gate commands, the C++ shutdown/init/arch hazards, the credential-scanning localhost rule, PR conventions, and a trust-and-validate close. it references the existing .github/prompts/ files instead of duplicating them, and every path plus the CI-enforced title prefixes were checked against the current tree.

Copilot AI review requested due to automatic review settings January 19, 2026 22:34
@github-actions

github-actions Bot commented Jan 19, 2026

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

80%


📈 Total Lines Covered: 6743 out of 8343
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 59.9%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.connection.connection.cpp: 76.2%
mssql_python.pybind.ddbc_bindings.cpp: 76.2%
mssql_python.__init__.py: 77.3%
mssql_python.row.py: 77.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.connection.py: 83.6%
mssql_python.logging.py: 85.5%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive LLM guidance documentation to help AI coding assistants work effectively with the mssql-python driver. It includes two new documentation files: llms.txt for end-user code suggestions and .github/copilot-instructions.md for repository contributors.

Changes:

  • Added llms.txt (269 lines) with usage examples, connection patterns, query syntax, error handling, and migration guidance
  • Added .github/copilot-instructions.md (257 lines) with build instructions, architecture overview, CI/CD details, and contributing guidelines

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
llms.txt Provides comprehensive usage documentation for LLMs suggesting mssql-python code to end users, including connection strings, CRUD operations, and error handling
.github/copilot-instructions.md Guides AI coding agents contributing to the repository with build system details, testing procedures, and architecture information

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/copilot-instructions.md Outdated
Comment thread llms.txt Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/copilot-instructions.md Outdated
@dlevy-msft-sql dlevy-msft-sql added the pr-size: small Minimal code update label Jan 22, 2026

@bewithgaurav bewithgaurav left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlevy-msft-sql - this is a great addition, I used copilot to review this PR on some more context that I have been working with, below are the details I'd like to add in this PR for both the files

Review Feedback - Elevating the LLM Guidance

Here are suggestions to make these instructions even more effective:

1. Reference Existing Prompts (copilot-instructions.md)

The repo already has excellent .prompt.md files in .github/prompts/. Instead of duplicating build/test instructions, reference them:

Development Workflows

This repository includes detailed prompt files for common tasks. Use these with `#`:

Task Prompt When to Use
First-time setup #setup-dev-env New machine, fresh clone
Build C++ extension #build-ddbc After modifying .cpp/.h files
Run tests #run-tests Validating changes
Create PR #create-pr Ready to submit changes

Workflow order for new contributors:

  1. #setup-dev-env → Set up venv and dependencies
  2. #build-ddbc → Build native extension
  3. Make your changes
  4. #run-tests → Validate
  5. #create-pr → Submit

2. Add Anti-Patterns Section (copilot-instructions.md)

Telling AI what NOT to do is as important as what to do:

Critical Anti-Patterns (DO NOT)

  • NEVER hardcode connection strings - always use DB_CONNECTION_STRING env var
  • NEVER use pyodbc imports - this driver doesn't require external ODBC
  • NEVER modify files in mssql_python/libs/ - these are pre-built binaries
  • NEVER skip conn.commit() after INSERT/UPDATE/DELETE operations

3. Add Exception Hierarchy (copilot-instructions.md)

Critical for error handling guidance:

Error (base)
├── DatabaseError
│   ├── InterfaceError      # Driver/interface issues
│   ├── OperationalError    # Connection/timeout issues  
│   ├── IntegrityError      # Constraint violations
│   ├── ProgrammingError    # SQL syntax errors
│   └── DataError           # Invalid data processing
└── Warning

4. Add AI Agent Behavioral Instructions (copilot-instructions.md)

When Modifying Code

Python Changes

  • Preserve existing error handling patterns from exceptions.py
  • Use context managers (with) for all connection/cursor operations
  • Update __all__ exports if adding public API
  • Add corresponding test in tests/test_*.py

C++ Changes

  • Follow RAII patterns for resource management
  • Use py::gil_scoped_release for blocking ODBC operations
  • Update mssql_python.pyi type stubs if changing Python API

5. Add Debugging Quick Reference (copilot-instructions.md)

Symptom Likely Cause Solution
ImportError: ddbc_bindings Extension not built Run #build-ddbc
Connection timeout Missing env var Set DB_CONNECTION_STRING
dylib not found (macOS) Library paths Run configure_dylibs.sh

6. Resolve Black Version Comment

The existing review comment about Black version pinning is unresolved - either remove the version pin or add explicit rationale.


Overall:
The distinction between llms.txt (user-facing API docs) and copilot-instructions.md (contributor-facing) is well thought out! The existing .prompt.md files are nice and well-used - consider cross-referencing them to avoid duplication. 👍

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread llms.txt Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread llms.txt Outdated
Comment thread llms.txt Outdated
Comment thread llms.txt Outdated
Comment thread .github/copilot-instructions.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/copilot-instructions.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

bewithgaurav
bewithgaurav previously approved these changes Feb 6, 2026

@dlevy-msft-sql dlevy-msft-sql left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against the repo style guide and existing patterns. A few issues — mostly around audience separation (dev vs. user), stale references, and some code sample issues. Details in inline comments.

Comment thread llms.txt Outdated
Comment thread llms.txt Outdated
Comment thread llms.txt Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Add two documentation files to help AI coding assistants work effectively
with the mssql-python driver:

llms.txt (user-facing, 256 lines):
- Installation, Quick Start, connection string patterns
- CRUD operations, parameterized queries, transactions
- Stored procedures with OUTPUT param workaround
- Error handling with full exception hierarchy
- Connection pooling, pyodbc comparison and migration
- Platform support matrix (SUSE x64-only noted)

.github/copilot-instructions.md (contributor-facing, 263 lines):
- Cross-references to .github/prompts/ workflow files
- Build system instructions (Windows/macOS/Linux)
- Project architecture with complete file tree
- CI/CD pipeline details (5 GitHub workflows, ADO pipelines)
- Anti-patterns, debugging quick reference
- PR requirements and contributing guidelines
dlevy-msft-sql and others added 2 commits March 6, 2026 17:23
rewrites .github/copilot-instructions.md from scratch against the current
repo: the python -> pybind ddbc_bindings -> odbc call stack (py-core/TDS for
bulkcopy), the validated build/test/validation-gate commands, the C++
shutdown and static-handle and error-code hazards, the credential-scanning
localhost rule, PR conventions, and a trust-and-validate close. every path
and the CI-enforced title prefixes were checked against the tree.

drops llms.txt: it's a website-root convention, isn't shipped in the wheel
(not in package_data) and nothing discovers it from a repo root, so it's
inert here. the contributor instructions file is the surface that's actually
consumed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bewithgaurav bewithgaurav changed the title DOC: Add llms.txt and copilot-instructions.md for LLM guidance DOC: add copilot-instructions.md for coding-agent guidance Jul 15, 2026
@bewithgaurav
bewithgaurav merged commit 0966b05 into microsoft:main Jul 16, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: small Minimal code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants