Skip to content

Commit b57e97d

Browse files
Add AGENTS.md file with comprehensive AI agent guidelines
Co-authored-by: ronniegeraghty <[email protected]>
1 parent e593284 commit b57e97d

File tree

2 files changed

+316
-0
lines changed

2 files changed

+316
-0
lines changed

.github/copilot-instructions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# AZURE SDK FOR PYTHON - COPILOT INSTRUCTIONS
22

3+
> **Note**: For general AI agent guidelines and repository overview, see [AGENTS.md](../AGENTS.md) at the repository root.
4+
35
---
46

57
## CORE PRINCIPLES

AGENTS.md

Lines changed: 314 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
# AGENTS.md - Azure SDK for Python
2+
3+
This file describes how AI agents (e.g., GitHub Copilot, MCP servers, or LLM-based assistants) should interact with this repository.
4+
5+
## Repository Overview
6+
7+
**Purpose**: This repository contains the active development of the Azure SDK for Python, providing client libraries and management libraries for Azure services.
8+
9+
**Scope**:
10+
- 100+ Python packages for Azure services
11+
- Client libraries for data plane operations
12+
- Management libraries for Azure Resource Manager (ARM)
13+
- Shared core functionality (authentication, retries, logging, transport)
14+
- TypeSpec-based SDK generation from API specifications
15+
- Comprehensive testing, validation, and documentation infrastructure
16+
17+
**Main Branch**: `main`
18+
19+
**Key Documentation**:
20+
- [Azure SDK Python Design Guidelines](https://azure.github.io/azure-sdk/python_design.html)
21+
- [Contributing Guide](CONTRIBUTING.md)
22+
- [Developer Documentation](doc/dev/)
23+
24+
## Repository Structure
25+
26+
```
27+
azure-sdk-for-python/
28+
├── sdk/ # Service-specific libraries (e.g., sdk/storage/, sdk/ai/)
29+
├── eng/ # Engineering system tools and configurations
30+
├── doc/ # Developer documentation and guides
31+
├── scripts/ # Automation scripts
32+
├── .github/ # GitHub workflows and Copilot instructions
33+
│ └── copilot-instructions.md # Detailed Copilot-specific guidance
34+
└── tools/ # Development tools
35+
```
36+
37+
## AI Agent Guidelines
38+
39+
### Supported Actions
40+
41+
AI agents can assist with the following activities:
42+
43+
#### Code Generation & Development
44+
- **TypeSpec SDK Generation**: Generate Python SDKs from TypeSpec specifications
45+
- Follow the complete workflow in `.github/copilot-instructions.md`
46+
- Use MCP tools for environment verification, code generation, and validation
47+
- Time estimate: 10-15 minutes for full generation workflow
48+
49+
- **Code Fixes**: Address linting, type checking, and validation issues
50+
- Pylint, MyPy, Pyright, Verifytypes, Sphinx warnings
51+
- Follow official guidelines and existing patterns
52+
- Make minimal, surgical changes
53+
54+
- **Documentation**: Update CHANGELOG.md, README files, and API documentation
55+
- Follow existing formatting conventions
56+
- Include version information and release dates
57+
58+
#### Testing & Validation
59+
- **Run Tests**: Execute tox-based test suites
60+
- Unit tests, integration tests, samples
61+
- Support both local and CI environments
62+
63+
- **Static Analysis**: Run and fix issues from:
64+
- Pylint (code quality)
65+
- MyPy, Pyright (type checking)
66+
- Bandit (security)
67+
- Black (formatting)
68+
- Sphinx (documentation)
69+
70+
#### Pull Request Management
71+
- **PR Creation**: Create draft PRs with descriptive titles and descriptions
72+
- **PR Review**: Analyze PR feedback and make requested changes
73+
- **Status Checks**: Monitor CI/CD pipeline status and address failures
74+
75+
#### Issue Triage & Labeling
76+
- **Issue Analysis**: Review and categorize issues
77+
- **Service Labels**: Validate and create service labels (e.g., `Azure.AI.Projects`)
78+
- **CODEOWNERS**: Validate and update CODEOWNERS entries
79+
80+
### Key Workflows
81+
82+
#### 1. TypeSpec SDK Generation Workflow
83+
84+
**Prerequisites**:
85+
- GitHub CLI authenticated (`gh auth login`)
86+
- Feature branch (not `main`)
87+
- PowerShell installed (for MCP tools)
88+
- Python virtual environment active
89+
90+
**Steps**:
91+
1. **Environment Verification** - Use `verify_setup` MCP tool
92+
2. **SDK Generation** - Use azure-sdk-python-mcp generation tools (~2 minutes)
93+
3. **Static Validation** - Run sequential validation steps (~3-5 minutes each):
94+
- Pylint, MyPy, Pyright, Verifytypes
95+
- Sphinx, Mindependency, Bandit, Black
96+
- Samples, Breaking changes
97+
4. **Documentation Update** - Update CHANGELOG.md and version files
98+
5. **Commit & Push** - Stage, commit, and push changes
99+
6. **PR Creation** - Create draft PR with generated description
100+
7. **Handoff** - Provide PR link for azure-rest-api-specs agent
101+
102+
**Estimated Time**: 10-15 minutes
103+
104+
#### 2. Code Quality Workflow
105+
106+
**Running Validation**:
107+
```bash
108+
# Use tox with appropriate environment
109+
tox -e <environment> -c eng/tox/tox.ini --root .
110+
111+
# Examples:
112+
tox -e pylint -c eng/tox/tox.ini --root .
113+
tox -e mypy -c eng/tox/tox.ini --root .
114+
```
115+
116+
**Fixing Issues**:
117+
- Reference official guidelines:
118+
- [Pylint Guidelines](https://github.com/Azure/azure-sdk-tools/blob/main/tools/pylint-extensions/azure-pylint-guidelines-checker/README.md)
119+
- [MyPy Type Checking Guide](doc/dev/static_type_checking_cheat_sheet.md)
120+
- [Tox Usage Guide](doc/dev/tests.md#tox)
121+
- Make minimal changes that address specific warnings
122+
- Avoid adding new dependencies or large refactoring
123+
- Rerun validation after each fix
124+
125+
#### 3. SDK Release Workflow
126+
127+
**Check Release Readiness**:
128+
- Use `CheckPackageReleaseReadiness` MCP tool
129+
- Validates: API review status, changelog, package approval, release date
130+
131+
**Release Package**:
132+
- Use `ReleasePackage` MCP tool
133+
- Triggers release pipeline (requires approval)
134+
135+
**Release Blocking Checks**:
136+
- MyPy: PASS
137+
- Pylint: PASS
138+
- Sphinx: PASS
139+
- Tests - CI: PASS
140+
141+
### Automation Boundaries
142+
143+
#### Safe Operations
144+
✅ Generate SDK code from TypeSpec specifications
145+
✅ Run linting and static analysis tools
146+
✅ Fix code quality warnings (with high confidence)
147+
✅ Update documentation (CHANGELOG, README)
148+
✅ Create and update PRs in draft mode
149+
✅ Run existing test suites
150+
✅ Validate CODEOWNERS entries
151+
152+
#### Restricted Operations
153+
⚠️ Modifying generated code (requires review)
154+
⚠️ Adding new dependencies (requires justification)
155+
⚠️ Changing API signatures (requires design review)
156+
⚠️ Disabling or removing tests (requires explanation)
157+
⚠️ Large-scale refactoring (requires approval)
158+
159+
#### Prohibited Operations
160+
❌ Merging PRs without human review
161+
❌ Releasing packages to PyPI
162+
❌ Modifying CI/CD pipeline definitions
163+
❌ Changing security or authentication logic without security review
164+
❌ Committing secrets or credentials
165+
❌ Force pushing to protected branches
166+
167+
### Environment Requirements
168+
169+
**Required Tools**:
170+
- Python 3.9 or later
171+
- Node.js (for TypeSpec generation)
172+
- Tox (test automation)
173+
- GitHub CLI (for PR operations)
174+
- PowerShell (for MCP server on Windows)
175+
176+
**MCP Server Tools**:
177+
- `azure-sdk-python-mcp` - Python-specific SDK operations
178+
- `azure-sdk-mcp` - Cross-language SDK operations
179+
- `azsdk-tools` - Engineering system utilities
180+
181+
**Virtual Environment**:
182+
```bash
183+
# Create and activate virtual environment
184+
python -m venv .venv
185+
source .venv/bin/activate # Linux/macOS
186+
.venv\Scripts\activate # Windows
187+
```
188+
189+
### CI/CD Integration
190+
191+
**Pipeline System**: Azure DevOps
192+
193+
**Key Pipelines**:
194+
- **Python CI**: Core library tests and validation
195+
- **SDK Generation**: TypeSpec-based code generation
196+
- **Release**: Package publication to PyPI
197+
198+
**Status Monitoring**:
199+
- Use `get_pipeline_status` MCP tool
200+
- Check build logs for failures
201+
- Analyze failed tests with `get_failed_test_cases` tool
202+
203+
**Artifact Analysis**:
204+
- Download artifacts with `get_pipeline_llm_artifacts`
205+
- Review TRX test results
206+
- Analyze log files with `analyze_log_file` tool
207+
208+
### SDK-Specific Conventions
209+
210+
#### Package Naming
211+
- Client libraries: `azure-<service>-<component>` (e.g., `azure-storage-blob`)
212+
- Management libraries: `azure-mgmt-<service>` (e.g., `azure-mgmt-compute`)
213+
214+
#### Version Conventions
215+
- Semantic versioning: `MAJOR.MINOR.PATCH`
216+
- Preview versions: `MAJOR.MINOR.PATCHbN` (e.g., `1.0.0b1`)
217+
- Pre-release format in CHANGELOG: `## 1.0.0b1 (YYYY-MM-DD)`
218+
219+
#### Code Style
220+
- Follow [PEP 8](https://peps.python.org/pep-0008/)
221+
- Use Black for formatting
222+
- Type hints required (PEP 484)
223+
- Docstrings in NumPy/Google style
224+
225+
#### Testing
226+
- Use pytest framework
227+
- Separate live and recorded tests
228+
- Test recordings in `tests/recordings/`
229+
- Environment variables for credentials (never hardcode)
230+
231+
## Cross-References
232+
233+
**Detailed Copilot Instructions**: See [`.github/copilot-instructions.md`](.github/copilot-instructions.md) for:
234+
- Complete TypeSpec SDK generation workflow
235+
- Detailed validation steps and commands
236+
- Pylint and MyPy fixing guidelines
237+
- SDK health status interpretation
238+
- SDK release procedures
239+
240+
**Developer Documentation**: See [`doc/dev/`](doc/dev/) for:
241+
- [TypeSpec Generation Guide](doc/dev/ai/typespec_generation.md)
242+
- [Testing Guide](doc/dev/tests.md)
243+
- [Tox Usage](doc/dev/tests.md#tox)
244+
- [Pylint Checking](doc/dev/pylint_checking.md)
245+
- [Type Checking Cheat Sheet](doc/dev/static_type_checking_cheat_sheet.md)
246+
247+
## Example Prompts
248+
249+
### SDK Generation
250+
```
251+
"Generate a Python SDK using TypeSpec from tspconfig.yaml at <path>"
252+
"Start TypeSpec SDK generation workflow"
253+
"Generate SDK from my local TypeSpec project at sdk/cognitiveservices/azure-ai-projects"
254+
```
255+
256+
### Validation & Fixes
257+
```
258+
"Run pylint validation and fix any warnings"
259+
"Check if my SDK passes all static validation steps"
260+
"Fix the mypy errors in the generated SDK"
261+
```
262+
263+
### Release Management
264+
```
265+
"Check if azure-ai-projects is ready for release"
266+
"What is the health status of azure-storage-blob?"
267+
"Release azure-ai-inference version 1.0.0"
268+
```
269+
270+
### Repository Health
271+
```
272+
"Show me the health status for azure-ai-projects"
273+
"Which checks are blocking the release of this library?"
274+
"Are there any open customer issues for this package?"
275+
```
276+
277+
## Agent Behavior Guidelines
278+
279+
### Best Practices
280+
1. **Always verify environment first** - Run `verify_setup` before SDK operations
281+
2. **Inform users of time expectations** - SDK generation takes 10-15 minutes
282+
3. **Make minimal changes** - Only modify files with validation errors
283+
4. **Reference official documentation** - Link to Azure SDK design guidelines
284+
5. **Run validation iteratively** - Fix and rerun each step before proceeding
285+
6. **Use MCP tools when available** - Leverage specialized SDK tooling
286+
7. **Create draft PRs** - Never create PRs in ready-for-review state
287+
8. **Report progress frequently** - Use incremental commits
288+
289+
### Error Handling
290+
- For TypeSpec errors: Direct users to fix in source repository
291+
- For authentication failures: Guide through `gh auth login`
292+
- For missing dependencies: Provide installation instructions with links
293+
- For validation failures: Reference specific fixing guidelines
294+
- For pipeline failures: Analyze logs and provide actionable feedback
295+
296+
### Communication Style
297+
- Don't repeat instructions - reference documentation links
298+
- Be concise and actionable
299+
- Use markdown formatting for commands and code
300+
- Provide time estimates for long operations
301+
- Highlight release-blocking issues clearly
302+
303+
## Reporting Issues
304+
305+
To report issues with AI agent interactions or suggest improvements:
306+
- **GitHub Issues**: [Azure SDK for Python Issues](https://github.com/Azure/azure-sdk-for-python/issues)
307+
- **Label**: Use `Agent` label for agent-related issues
308+
- **Include**: Agent name/version, prompt used, expected vs actual behavior
309+
310+
## Version
311+
312+
**AGENTS.md Version**: 1.0.0
313+
**Last Updated**: 2025-01-22
314+
**Specification**: Follows [agents.md](https://agents.md) canonical structure

0 commit comments

Comments
 (0)