agentleFS
MicrosoftKnown publishermicrosoft/PhiCookBook/AGENTS.md

PhiCookBook

AGENTS.md3.9k starsChanged 9 months agoMITView on GitHub

PhiCookBook is a comprehensive cookbook repository containing hands-on examples, tutorials, and documentation for working with Microsoft's Phi family of Small Language Models (SLMs). The repository demonstrates various use cases including inference, fine-tuning, quantization, RAG implementations, and multimodal applications across different platforms and frameworks. Key Technologies: - Languages: Python, C#/.NET, JavaScript/Node.js - Frameworks: ONNX Runtime, PyTorch, Transformers, MLX, OpenVINO, Semantic Kernel - Platforms: Microsoft Foundry, GitHub Models, Hugging Face, Ollama - Model Types: Phi-3, Phi-3.5, Phi-4 (text, vision, multimodal, reasoning variants)

  • Installs packages

Trending

Quiet since July.thin dataabout the whole repository

Dec 2025: 1 mentionJan 2026: 1 mentionFeb 2026: 3 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/PhiCookBook repository that our weekly crawl found: only 9 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about microsoft/PhiCookBook

The biggest 5 of 9 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 9

Talked about on GitHub (9 times).

On GitHub · 9

4 more on GitHub

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

38 rules. About 1 is common, 28 are distinctive, and 9 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈28

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Use the "Open in Dev Containers" badge from README

    line 28
  2. Distinctive:

    Verifying outputs: - Check that model responses are appropriate

    line 140
  3. Distinctive:

    Test example execution in the target environment

    line 144
  4. Distinctive:

    Verify dependencies install correctly

    line 145
  5. Distinctive:

    Check that model downloads/loads successfully

    line 146
  6. Distinctive:

    Follow language-specific conventions (PEP 8 for Python, C# standards for .NET)

    line 154
  7. Distinctive:

    Keep examples focused on demonstrating specific Phi model capabilities

    line 155
  8. Very specific:

    Use text format without extra spaces

    line 161
  9. Very specific:

    No country-specific locales in URLs (avoid /en-us/, /en/)

    line 163
  10. Distinctive:

    Use descriptive names with English characters, numbers, and dashes

    line 167
  11. Distinctive:

    Keep documentation synchronized with code changes

    line 172
  12. Distinctive:

    Use 📓 emoji to mark Jupyter notebook links in README

    line 173
  13. Distinctive:

    Keep related files (notebooks, scripts, configs) together in subdirectories

    line 179
  14. Distinctive:

    Update your local main branch before making changes

    line 193
  15. Distinctive:

    Must include translations for ALL files in the folder

    line 197
  16. Distinctive:

    Relative path validation: - All internal links must work

    line 204
  17. Distinctive:

    Test links locally: Ctrl+Click in VS Code

    line 205
  18. Very specific:

    Use path suggestions from VS Code (./ or ../)

    line 206
  19. Very specific:

    Remove /en-us/, /en/, or other language codes

    line 209
  20. Distinctive:

    Use generic international URLs

    line 210
  21. Distinctive:

    Broken URL check: - All URLs must return 200 status

    line 212
  22. Distinctive:

    Verify links are accessible before submitting

    line 213
  23. Distinctive:

    Check model compatibility with your hardware (CPU, GPU, NPU)

    line 234
  24. Distinctive:

    Use quantized models for resource-constrained environments

    line 263
  25. Distinctive:

    Use virtual environments for each example

    line 268
  26. Very specific:

    Check individual requirements.txt files

    line 269
  27. Distinctive:

    Consider using cloud environments (Codespaces, Azure)

    line 273
  28. Very specific:

    Check Hugging Face cache: ~/.cache/huggingface/

    line 274
  29. Distinctive:

    Ensure .NET 8.0 SDK is installed

    line 277
  30. Very specific:

    Use dotnet restore before building

    line 278
  31. Very specific:

    Use Node.js 18+ for compatibility

    line 282
  32. Distinctive:

    Check browser console for WebGPU compatibility issues

    line 284
  33. Distinctive:

    GitHub Discussions: Ask questions and share knowledge

    line 290
  34. Distinctive:

    All Phi model usage should follow Microsoft's Responsible AI principles:

    line 296
  35. Distinctive:

    Use Azure AI Content Safety for production applications

    line 300
  36. Distinctive:

    Do not manually edit translated files (auto-generated)

    line 308
  37. Very specific:

    Follow guidelines in CONTRIBUTING.md

    line 312
  38. Common:

    Keep security and credentials out of commits

    line 315

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

Project Overview

PhiCookBook is a comprehensive cookbook repository containing hands-on examples, tutorials, and documentation for working with Microsoft's Phi family of Small Language Models (SLMs). The repository demonstrates various use cases including inference, fine-tuning, quantization, RAG implementations, and multimodal applications across different platforms and frameworks.

Key Technologies:

  • Languages: Python, C#/.NET, JavaScript/Node.js
  • Frameworks: ONNX Runtime, PyTorch, Transformers, MLX, OpenVINO, Semantic Kernel
  • Platforms: Microsoft Foundry, GitHub Models, Hugging Face, Ollama
  • Model Types: Phi-3, Phi-3.5, Phi-4 (text, vision, multimodal, reasoning variants)

Repository Structure:

  • /code/ - Working code examples and sample implementations
  • /md/ - Detailed documentation, tutorials, and how-to guides
  • /translations/ - Multi-language translations (50+ languages via automated workflow)
  • /.devcontainer/ - Dev container configuration (Python 3.12 with Ollama)

Development Environment Setup

Using GitHub Codespaces or Dev Containers (Recommended)

  1. Open in GitHub Codespaces (fastest):
    • Click the "Open in GitHub Codespaces" badge in README
    • Container auto-configures with Python 3.12 and Ollama with Phi-3
  2. Open in VS Code Dev Containers:
    • Use the "Open in Dev Containers" badge from README
    • Container requires 16GB host memory minimum

Local Setup

Prerequisites:

  • Python 3.12 or later
  • .NET 8.0 SDK (for C# examples)
  • Node.js 18+ and npm (for JavaScript examples)
  • 16GB RAM minimum recommended

Installation:

git clone https://github.com/microsoft/PhiCookBook.git
cd PhiCookBook

For Python Examples: Navigate to specific example directories and install dependencies:

cd code/<example-directory>
pip install -r requirements.txt  # if requirements.txt exists

For .NET Examples:

cd md/04.HOL/dotnet/src
dotnet restore LabsPhi.sln
dotnet build LabsPhi.sln

For JavaScript/Web Examples:

cd code/08.RAG/rag_webgpu_chat
npm install
npm run dev  # Start development server
npm run build  # Build for production

Repository Organization

Code Examples (/code/)

  • 01.Introduce/ - Basic introductions and getting started samples
  • 03.Finetuning/ and 04.Finetuning/ - Fine-tuning examples with various methods
  • 03.Inference/ - Inference examples on different hardware (AIPC, MLX)
  • 06.E2E/ - End-to-end application samples
  • 07.Lab/ - Laboratory/experimental implementations
  • 08.RAG/ - Retrieval-Augmented Generation samples
  • 09.UpdateSamples/ - Latest updated samples

Documentation (/md/)

  • 01.Introduction/ - Intro guides, environment setup, platform guides
  • 02.Application/ - Application samples organized by type (Text, Code, Vision, Audio, etc.)
  • 02.QuickStart/ - Quick start guides for Microsoft Foundry and GitHub Models
  • 03.FineTuning/ - Fine-tuning documentation and tutorials
  • 04.HOL/ - Hands-on labs (includes .NET examples)

File Formats

  • Jupyter Notebooks (.ipynb) - Interactive Python tutorials marked with 📓 in README
  • Python Scripts (.py) - Standalone Python examples
  • C# Projects (.csproj, .sln) - .NET applications and samples
  • JavaScript (.js, package.json) - Web-based and Node.js examples
  • Markdown (.md) - Documentation and guides

Working with Examples

Running Jupyter Notebooks

Most examples are provided as Jupyter notebooks:

pip install jupyter notebook
jupyter notebook  # Opens browser interface
# Navigate to desired .ipynb file

Running Python Scripts

cd code/<example-directory>
pip install -r requirements.txt
python <script-name>.py

Running .NET Examples

cd md/04.HOL/dotnet/src/<project-name>
dotnet run

Or build entire solution:

cd md/04.HOL/dotnet/src
dotnet run --project <project-name>

Running JavaScript/Web Examples

cd code/08.RAG/rag_webgpu_chat
npm install
npm run dev  # Development with hot reload

Testing

This repository contains example code and tutorials rather than a traditional software project with unit tests. Validation is typically done by:

  1. Running the examples - Each example should execute without errors
  2. Verifying outputs - Check that model responses are appropriate
  3. Following tutorials - Step-through guides should work as documented

Common validation approach:

  • Test example execution in the target environment
  • Verify dependencies install correctly
  • Check that model downloads/loads successfully
  • Confirm expected behavior matches documentation

Code Style and Conventions

General Guidelines

  • Examples should be clear, well-commented, and educational
  • Follow language-specific conventions (PEP 8 for Python, C# standards for .NET)
  • Keep examples focused on demonstrating specific Phi model capabilities
  • Include comments explaining key concepts and model-specific parameters

Documentation Standards

URL Formatting:

  • Use [text](url) format without extra spaces
  • Relative links: Use ./ for current directory, ../ for parent
  • No country-specific locales in URLs (avoid /en-us/, /en/)

Images:

  • Store all images in /imgs/ directory
  • Use descriptive names with English characters, numbers, and dashes
  • Example: phi-3-architecture.png

Markdown Files:

  • Reference actual working examples in /code/ directory
  • Keep documentation synchronized with code changes
  • Use 📓 emoji to mark Jupyter notebook links in README

File Organization

  • Code examples in /code/ organized by topic/feature
  • Documentation in /md/ mirrors code structure when applicable
  • Keep related files (notebooks, scripts, configs) together in subdirectories

Pull Request Guidelines

Before Submitting

  1. Fork the repository to your account
  2. Separate PRs by type:
    • Bug fixes in one PR
    • Documentation updates in another
    • New examples in separate PRs
    • Typo fixes can be combined
  3. Handle merge conflicts:
    • Update your local main branch before making changes
    • Sync with upstream frequently
  4. Translation PRs:
    • Must include translations for ALL files in the folder
    • Maintain consistent structure with original language

Required Checks

PRs automatically run GitHub workflows to validate:

  1. Relative path validation - All internal links must work
    • Test links locally: Ctrl+Click in VS Code
    • Use path suggestions from VS Code (./ or ../)
  2. URL locale check - Web URLs must not contain country locales
    • Remove /en-us/, /en/, or other language codes
    • Use generic international URLs
  3. Broken URL check - All URLs must return 200 status
    • Verify links are accessible before submitting
    • Note: Some failures may be due to network restrictions

PR Title Format

[component] Brief description

Examples:

  • [docs] Add Phi-4 inference tutorial
  • [code] Fix ONNX Runtime integration example
  • [translation] Add Japanese translation for intro guides

Common Development Patterns

Working with Phi Models

Model Loading:

  • Examples use various frameworks: Transformers, ONNX Runtime, MLX, OpenVINO
  • Models are typically downloaded from Hugging Face, Azure, or GitHub Models
  • Check model compatibility with your hardware (CPU, GPU, NPU)

Inference Patterns:

  • Text generation: Most examples use chat/instruct variants
  • Vision: Phi-3-vision and Phi-4-multimodal for image understanding
  • Audio: Phi-4-multimodal supports audio inputs
  • Reasoning: Phi-4-reasoning variants for advanced reasoning tasks

Platform-Specific Notes

Microsoft Foundry:

  • Requires Azure subscription and API keys
  • See /md/02.QuickStart/AzureAIFoundry_QuickStart.md

GitHub Models:

  • Free tier available for testing
  • See /md/02.QuickStart/GitHubModel_QuickStart.md

Local Inference:

  • ONNX Runtime: Cross-platform, optimized inference
  • Ollama: Easy local model management (pre-configured in dev container)
  • Apple MLX: Optimized for Apple Silicon

Troubleshooting

Common Issues

Memory Issues:

  • Phi models require significant RAM (especially vision/multimodal variants)
  • Use quantized models for resource-constrained environments
  • See /md/01.Introduction/04/QuantifyingPhi.md

Dependency Conflicts:

  • Python examples may have specific version requirements
  • Use virtual environments for each example
  • Check individual requirements.txt files

Model Download Failures:

  • Large models may timeout on slow connections
  • Consider using cloud environments (Codespaces, Azure)
  • Check Hugging Face cache: ~/.cache/huggingface/

.NET Project Issues:

  • Ensure .NET 8.0 SDK is installed
  • Use dotnet restore before building
  • Some projects have CUDA-specific configurations (Debug_Cuda)

JavaScript/Web Examples:

  • Use Node.js 18+ for compatibility
  • Clear node_modules and reinstall if issues persist
  • Check browser console for WebGPU compatibility issues

Getting Help

  • Discord: Join the Microsoft Foundry Community Discord
  • GitHub Issues: Report bugs and issues in the repository
  • GitHub Discussions: Ask questions and share knowledge

Additional Context

Responsible AI

All Phi model usage should follow Microsoft's Responsible AI principles:

  • Fairness, reliability, safety
  • Privacy and security
  • Inclusiveness, transparency, accountability
  • Use Azure AI Content Safety for production applications
  • See /md/01.Introduction/01/01.AISafety.md

Translations

  • 50+ languages supported via automated GitHub Action
  • Translations in /translations/ directory
  • Maintained by co-op-translator workflow
  • Do not manually edit translated files (auto-generated)

Contributing

  • Follow guidelines in CONTRIBUTING.md
  • Agree to Contributor License Agreement (CLA)
  • Adhere to Microsoft Open Source Code of Conduct
  • Keep security and credentials out of commits

Multi-Language Support

This is a polyglot repository with examples in:

  • Python - ML/AI workflows, Jupyter notebooks, fine-tuning
  • C#/.NET - Enterprise applications, ONNX Runtime integration
  • JavaScript - Web-based AI, browser inference with WebGPU

Choose the language that best fits your use case and deployment target.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.