DOC: add copilot-instructions.md for coding-agent guidance#406
Conversation
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changesNo 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
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
bewithgaurav
left a comment
There was a problem hiding this comment.
@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:
#setup-dev-env→ Set up venv and dependencies#build-ddbc→ Build native extension- Make your changes
#run-tests→ Validate#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_STRINGenv var - NEVER use
pyodbcimports - 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_releasefor blocking ODBC operations - Update
mssql_python.pyitype 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. 👍
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
dlevy-msft-sql
left a comment
There was a problem hiding this comment.
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.
3393f5d to
ab117b6
Compare
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
ab117b6 to
89f2787
Compare
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>
Work Item / Issue Reference
Summary
adds
.github/copilot-instructions.md: a from-scratch, repo-wide guide for coding agents working on mssql-python. it covers the architecture (python -> pybindddbc_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.