agentleFS
MicrosoftKnown publishermicrosoft/generative-ai-with-javascript/AGENTS.md

generative-ai-with-javascript

AGENTS.md1.3k starsChanged 14 months agoMITView on GitHub

This repository is a comprehensive learning course called "Generative AI for Beginners with JavaScript". It teaches developers how to integrate Generative AI into JavaScript applications through a time-traveling narrative where learners interact with historical figures. Key Technologies: - JavaScript/Node.js (ES Modules) - TypeScript (for some lessons) - OpenAI SDK - Model Context Protocol (MCP) - Express.js (for web applications) - GitHub Models (free AI model access) - Azure OpenAI (optional alternative) Architecture: - Multi-package learning repository (not a monorepo, but…

  • Reads credentials
  • Installs packages

Trending

Quiet this year.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/generative-ai-with-javascript repository that our weekly crawl found: only 3 in all, so this is a hint, not a trend. There is no adoption data for this file yet.
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

Show its rules and text

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

30 rules. About 0 are common, 15 are distinctive, and 15 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 15

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create a Codespace from your fork

    line 92
  2. Very specific:

    Ensure Node.js 20+ is installed

    line 102
  3. Very specific:

    Run npm install followed by npm start

    line 105
  4. Distinctive:

    Must be set manually for local development

    line 111
  5. Distinctive:

    No scopes/permissions needed for the token when using GitHub Models

    line 112
  6. Very specific:

    Ensure GITHUB_TOKEN is set

    line 174
  7. Distinctive:

    Run any lesson sample that calls OpenAI APIs

    line 175
  8. Distinctive:

    Verify responses are generated successfully

    line 176
  9. Very specific:

    Use ES Modules (type: "module" in package.json)

    line 182
  10. Very specific:

    Use async/await for asynchronous operations

    line 183
  11. Very specific:

    Prefer const over let, avoid var

    line 184
  12. Distinctive:

    Use template literals for string interpolation

    line 185
  13. Distinctive:

    Follow existing code patterns in each lesson

    line 186
  14. Distinctive:

    Keep lesson code self-contained within lesson directories

    line 190
  15. Very specific:

    Place shared resources in /docs/ or /assets/

    line 191
  16. Distinctive:

    Use camelCase for variables and functions

    line 215
  17. Distinctive:

    Use PascalCase for classes and constructors

    line 216
  18. Distinctive:

    Use kebab-case for directory names

    line 218
  19. Very specific:

    Create lesson directory: lessons/XX-lesson-name/

    line 306
  20. Distinctive:

    Add README.md with lesson content

    line 307
  21. Very specific:

    Create sample-app/ with starter code

    line 308
  22. Very specific:

    Create solution/ with complete code

    line 309
  23. Very specific:

    Add package.json with required dependencies

    line 310
  24. Very specific:

    Update main README.md and _sidebar.md

    line 311
  25. Very specific:

    Place in public/audio/ as <character-name>.mp3

    line 348
  26. Distinctive:

    Follow existing code patterns and structure

    line 405
  27. Very specific:

    Add translations in lessons/<lesson>/translations/

    line 406
  28. Very specific:

    Use issue templates in .github/ISSUE_TEMPLATE/

    line 407
  29. Distinctive:

    Keep lesson samples lightweight and focused

    line 419
  30. Distinctive:

    Use streaming for better UX in production apps (see lesson 10)

    line 420

≈ “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

This repository is a comprehensive learning course called "Generative AI for Beginners with JavaScript". It teaches developers how to integrate Generative AI into JavaScript applications through a time-traveling narrative where learners interact with historical figures.

Key Technologies:

  • JavaScript/Node.js (ES Modules)
  • TypeScript (for some lessons)
  • OpenAI SDK
  • Model Context Protocol (MCP)
  • Express.js (for web applications)
  • GitHub Models (free AI model access)
  • Azure OpenAI (optional alternative)

Architecture:

  • Multi-package learning repository (not a monorepo, but lesson-based structure)
  • Each lesson in /lessons/ contains standalone sample applications
  • Main companion app in /app/ directory for character interactions
  • Video content and demos in /videos/
  • Documentation in /docs/

Repository Structure

/
├── app/              # Main companion app for interacting with historical characters
├── lessons/          # 8 lesson directories, each with sample code and solutions
│   ├── 01-intro-to-genai/
│   ├── 02-first-ai-app/
│   ├── 03-prompt-engineering/
│   ├── 04-structured-output/
│   ├── 05-rag/
│   ├── 06-tool-calling/
│   ├── 07-mcp/
│   └── 08-mcp-advanced/
├── docs/             # Setup guides and additional resources
├── videos/           # Video session content and demos
└── .devcontainer/    # GitHub Codespaces configuration

Setup Commands

Prerequisites:

  • Node.js 20 or higher
  • GitHub account (for GitHub Models access)
  • Optional: Personal Access Token (PAT) if running locally

Initial Setup:

# Clone the repository
git clone https://github.com/microsoft/generative-ai-with-javascript.git
cd generative-ai-with-javascript

# Install root dependencies
npm install

# For GitHub Codespaces users (recommended):
# The environment is pre-configured - no additional setup needed
# Use built-in GITHUB_TOKEN environment variable

# For local development:
# 1. Create a GitHub Personal Access Token (PAT) at https://github.com/settings/tokens
# 2. Set it as an environment variable: export GITHUB_TOKEN=your_token_here

Running the Main Companion App:

cd app
npm install
npm start
# Access at http://localhost:3000 or use "Open in Browser" in Codespaces

Working with Individual Lessons:

Each lesson has its own package.json. Navigate to the specific lesson directory:

cd lessons/02-first-ai-app/sample-app
npm install
npm start

Development Workflow

GitHub Codespaces (Recommended)

  1. Fork the repository
  2. Create a Codespace from your fork
  3. Pre-configured environment includes:
    • Node.js 20
    • VSCode extensions (EditorConfig, Code Runner, REST Client)
    • Ollama with phi3 and all-minilm models
    • GITHUB_TOKEN automatically available
  4. Navigate to any lesson or app directory and run npm install && npm start

Local Development

  1. Ensure Node.js 20+ is installed
  2. Set GITHUB_TOKEN environment variable
  3. Navigate to the directory you want to work with
  4. Run npm install followed by npm start

Environment Variables

  • GITHUB_TOKEN - Required for GitHub Models API access
    • Automatically available in GitHub Codespaces
    • Must be set manually for local development
  • No scopes/permissions needed for the token when using GitHub Models

Working with Lessons

Each lesson follows a consistent structure:

  • README.md - Main lesson content with narrative and technical instructions
  • sample-app/ or code/ - Starting code for exercises
  • solution/ - Complete solution code
  • translations/ - Lesson translations in various languages

To work on a lesson:

cd lessons/<lesson-number>-<lesson-name>/sample-app
npm install
npm start

For TypeScript-based lessons (MCP lessons 07-08):

cd lessons/07-mcp/solution
npm install
npm run build    # Compiles TypeScript to build/ directory
npm run client   # Runs the MCP client
npm run inspect  # Runs MCP inspector tool

Testing Instructions

Current Testing Setup:

This is primarily an educational repository focused on tutorial content. There are no automated unit or integration tests for the code samples.

Manual Testing Approach:

  1. Validate lesson code by running it:
    cd lessons/<lesson-name>/sample-app
    npm install
    npm start
  2. Test the companion app:
    cd app
    npm install
    npm start
    # Interact with characters through the web interface
  3. For MCP lessons, use the inspector tool:
    cd lessons/07-mcp/solution
    npm run build
    npm run inspect
    # Test individual tools:
    npx @modelcontextprotocol/inspector --cli node build/index.js --method tools/call --tool-name add --tool-arg a=1 --tool-arg b=3
  4. Verify GitHub Models integration:
    • Ensure GITHUB_TOKEN is set
    • Run any lesson sample that calls OpenAI APIs
    • Verify responses are generated successfully

Code Style Guidelines

JavaScript/TypeScript Conventions:

  • Use ES Modules (type: "module" in package.json)
  • Use async/await for asynchronous operations
  • Prefer const over let, avoid var
  • Use template literals for string interpolation
  • Follow existing code patterns in each lesson

File Organization:

  • Keep lesson code self-contained within lesson directories
  • Place shared resources in /docs/ or /assets/
  • Character data stored in app/public/characters.json
  • TypeScript source in src/, compiled output in build/

TypeScript (where applicable):

  • Target: ES2022
  • Module: Node16
  • Strict mode enabled
  • Output to build/ directory

Import/Export Patterns:

// ES Module imports
import { OpenAI } from 'openai';
import express from 'express';

// Default exports for apps
export default app;

Naming Conventions:

  • Use camelCase for variables and functions
  • Use PascalCase for classes and constructors
  • Prefix directories with numbers for lessons (e.g., 01-intro-to-genai)
  • Use kebab-case for directory names

Build and Deployment

Building TypeScript Lessons:

cd lessons/07-mcp/solution
npm run build
# Output: build/ directory with compiled JavaScript

Deployment:

The repository uses GitHub Pages for documentation hosting:

npm run build     # Builds documentation site
# Deployment handled by .github/workflows/deploy.yml

GitHub Actions Workflows:

  • deploy.yml - Deploys to GitHub Pages
  • links.yml - Checks for broken links (weekly schedule)
  • profanity.yml - Filters inappropriate content in PRs
  • spelling.yml - Spell checks documentation

GitHub Models Integration

Primary AI Service:

This course uses GitHub Models for free access to AI capabilities. All code examples are configured to work with GitHub Models by default.

API Configuration:

import { OpenAI } from 'openai';

const openai = new OpenAI({
  baseURL: "https://models.inference.ai.azure.com",
  apiKey: process.env.GITHUB_TOKEN,
});

Available Models:

Monorepo Navigation Tips

While not a true monorepo, this repository contains multiple independent packages:

Finding Lesson Packages:

# List all lesson directories
ls lessons/

# Find all package.json files
find . -name "package.json" -not -path "*/node_modules/*"

# Jump to a specific lesson
cd lessons/03-prompt-engineering/sample-app

Package Locations:

  • Root: /package.json (minimal dependencies: openai, tsx)
  • Main App: /app/package.json (Express app with OpenAI)
  • Each Lesson: lessons/<lesson>/sample-app/package.json or code/package.json
  • Solutions: lessons/<lesson>/solution/package.json

Working Across Packages:

Each package is independent - install dependencies in each directory you work with:

cd lessons/05-rag/sample-app && npm install
cd ../../06-tool-calling/solution && npm install

Common Development Tasks

Adding a New Lesson Sample:

  1. Create lesson directory: lessons/XX-lesson-name/
  2. Add README.md with lesson content
  3. Create sample-app/ with starter code
  4. Create solution/ with complete code
  5. Add package.json with required dependencies
  6. Update main README.md and _sidebar.md

Running Spell Check:

# Triggered via GitHub Actions workflow
# Checks: README.md and lessons/01-intro-to-genai/README.md

Testing Links:

# Runs automatically weekly via GitHub Actions
# Or trigger manually via workflow_dispatch

Character App Specifics

The companion app (/app/) allows interaction with historical AI characters.

Key Files:

  • app.js - Express server and OpenAI integration
  • public/characters.json - Character definitions and system prompts
  • public/index.html - Frontend interface
  • views/ - EJS templates

Character Configuration:

Edit public/characters.json to:

  • Add new characters
  • Modify character descriptions (used as system prompts)
  • Change character personalities

Adding Background Audio (Optional):

  1. Download royalty-free music
  2. Place in public/audio/ as <character-name>.mp3
  3. Uncomment audio code in index.html

Troubleshooting

"Cannot find module" errors:

# Ensure you're in the correct directory with package.json
cd lessons/<lesson-name>/sample-app
npm install

GitHub Models authentication issues:

# Verify token is set
echo $GITHUB_TOKEN

# For Codespaces: Token is automatically available
# For local: Create PAT at https://github.com/settings/tokens

TypeScript compilation errors:

cd lessons/07-mcp/solution
# Check tsconfig.json exists
npm install
npm run build

Port already in use:

# Kill process on port 3000
lsof -ti:3000 | xargs kill -9

# Or use a different port in your app configuration

Additional Notes

Responsible AI:

This repository contains fictional AI-generated content. Historical characters generate responses via AI based on training data, not actual historical views. Content is for educational and entertainment purposes only.

Educational Focus:

  • Each lesson builds progressively on previous concepts
  • Narrative-driven learning with time-travel story
  • Hands-on coding exercises with solutions provided
  • Video content supplements written lessons

Contributing:

  • See .github/CONTRIBUTING.md for contribution guidelines
  • Follow existing code patterns and structure
  • Add translations in lessons/<lesson>/translations/
  • Use issue templates in .github/ISSUE_TEMPLATE/

Community Resources:

Performance Considerations:

  • GitHub Codespaces requires 16GB RAM (configured in devcontainer.json)
  • Ollama models (phi3, all-minilm) pre-installed in Codespaces
  • Keep lesson samples lightweight and focused
  • Use streaming for better UX in production apps (see lesson 10)

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.