F4: The .github Agentic OS β GitHub Copilotβs 7 Primitives
Table of Contents
- F4.1 Why .github Is No Longer Just a Folder
- F4.2 The 4-Layer Architecture
- F4.3 Layer 1 β Always-On Context (Instructions)
- F4.4 Layer 2 β On-Demand Capabilities
- F4.5 Layer 3 β Enforcement & Automation
- F4.6 Layer 4 β Distribution (Plugins)
- F4.7 FrootAIβs Implementation β 19 Files per Solution Play
- F4.8 Decision Guide β When to Use What
- F4.9 Building Your Own .github Agentic OS
- Learning Outcomes
- Prerequisites
- Applied Scenario: Compose a Governed Repository Assistant
- Knowledge Check
- Key Takeaways
Learning Outcomes
After completing this module, you can:
- Distinguish instructions, prompts, agents, skills, hooks, workflows, and plugins by ownership and lifecycle.
- Select the smallest GitHub customization primitive that satisfies a requirement.
- Wire reusable primitives through a manifest without duplicating source guidance.
- Review an agentic repository for scope, trust, and maintenance risks.
Prerequisites
Prerequisites: Complete F1: GenAI Foundations and understand GitHub repositories, Markdown, and Actions workflows.
F4.1 Why .github Is No Longer Just a Folder
GitHub Copilotβs .github folder has evolved from a single copilot-instructions.md file into a full agentic operating system β 7 composable primitives across 4 layers that turn any repository into an agent-native workspace.
This is not a future roadmap. This is happening now. Every AI-first team needs to understand and adopt these primitives to stay competitive.
The Mental Model
Think of .github as your repositoryβs operating system for AI agents:
| Traditional OS | .github Agentic OS |
|---|---|
| Kernel (always running) | Instructions (always-on context) |
| Applications (user-launched) | Prompt Files (slash commands) |
| Services (background processes) | Custom Agents (specialist personas) |
| Libraries (shared code) | Skills (self-contained logic) |
| Security policies | Hooks (lifecycle enforcement) |
| Cron jobs / systemd | Agentic Workflows (AI-driven CI) |
| Package manager | Plugins (bundle + distribute) |
F4.2 The 4-Layer Architecture
The 7 primitives are organized into 4 layers, each serving a distinct purpose:
| Layer | Primitives | Trigger | Scope |
|---|---|---|---|
| 1. Always-On | Instructions | Every prompt (automatic) | Passive context |
| 2. On-Demand | Prompts, Agents, Skills | User or agent invokes | Active capabilities |
| 3. Enforcement | Hooks, Workflows | Lifecycle events | Guardrails + automation |
| 4. Distribution | Plugins | Package + publish | Share across repos |
F4.3 Layer 1 β Always-On Context (Instructions)
Primitive 1: Instructions
Files: .github/copilot-instructions.md + .github/instructions/*.instructions.md
Instructions are passive memory β they apply to every prompt automatically without the user asking. Copilot reads these before generating any response.
Use for: Coding standards, framework rules, repo conventions, architectural constraints.
Single File (Legacy)
<!-- .github/copilot-instructions.md -->
You are working on an Azure-based RAG pipeline.
Always use Managed Identity. Never hardcode secrets.
Use config/*.json for all AI parameters.Modular Files (Modern)
.github/instructions/
βββ azure-coding.instructions.md # Azure SDK patterns, managed identity
βββ rag-patterns.instructions.md # Chunking, retrieval, anti-hallucination
βββ security.instructions.md # Secrets, PII, access controlWhy modular? Different files apply to different parts of the codebase. Copilot loads only the relevant instructions based on the file being edited, reducing noise and improving accuracy.
Best Practices
| Do | Donβt |
|---|---|
| Keep instructions short and specific | Write essays β agents lose focus |
| Use bullet points and rules | Use vague guidance (βbe carefulβ) |
Reference specific files (config/openai.json) | Reference abstract concepts |
| Update when patterns change | Set and forget |
F4.4 Layer 2 β On-Demand Capabilities
Primitive 2: Prompt Files
Files: .github/prompts/*.prompt.md
Prompt files are slash commands β manually invoked by the user or another agent. They define a specific task with context and steps.
<!-- .github/prompts/deploy.prompt.md -->
# Deploy to Azure
## Steps
1. Validate config files exist
2. Run az bicep build to validate template
3. Deploy infrastructure
4. Run smoke testInvocation: Type /deploy in Copilot Chat β Copilot reads and executes the prompt.
Use for: /security-review, /release-notes, /changelog, /deploy, /test, /evaluate
Primitive 3: Custom Agents
Files: .github/agents/*.agent.md
Custom agents are specialist personas with their own identity, tools, and MCP server bindings. Agents can be chained via handoffs:
planning agent β implementation agent β review agent<!-- .github/agents/builder.agent.md -->
# Builder Agent
You are the implementation agent for this solution.
## Your Tools
- FrootAI MCP Server (frootai-mcp)
- Azure CLI
- Python runtime
## Your MCP Servers
{"servers": {"frootai": {"command": "npx", "args": ["frootai-mcp"]}}}
## Rules
- Use values from config files, never hardcode
- Hand off to reviewer.agent.md when doneKey difference from instructions: Instructions are passive (always on). Agents are active (invoked for specific tasks) and have their own tool bindings.
Primitive 4: Skills
Files: .github/skills/<name>/SKILL.md
Skills are self-contained folders with instructions + scripts + references. Theyβre progressively loaded β Copilot reads the description first, loads the full instructions only when relevant.
.github/skills/
βββ deploy-azure/
β βββ SKILL.md # Description + prerequisites + references
β βββ deploy.sh # Executable script
βββ evaluate/
β βββ SKILL.md
β βββ eval.py
βββ tune/
βββ SKILL.md
βββ tune-config.shUse for: Repeatable runbooks, incident triage, IaC risk analysis, deployment procedures.
Progressive loading: Copilot reads SKILL.md header first. If the userβs question matches the skillβs domain, Copilot loads the full content. This saves tokens and reduces noise.
F4.5 Layer 3 β Enforcement & Automation
Primitive 5: Hooks
Files: .github/hooks/*.json
Hooks are deterministic shell commands triggered at lifecycle events. They enforce policies before, during, and after tool execution.
Three lifecycle events:
| Event | When | Use Case |
|---|---|---|
preToolUse | Before a tool executes | Approve or deny tool executions. Policy gates. |
postToolUse | After a tool completes | Audit logging, notifications. |
errorOccurred | When a tool fails | Suggest troubleshooting, auto-recover. |
{
"hooks": [
{
"event": "preToolUse",
"match": { "toolName": "write_file", "pathPattern": "**/*.env" },
"action": "deny_if_contains",
"patterns": ["api_key", "secret", "password"],
"message": "BLOCKED: Detected secrets. Use Key Vault."
}
]
}Why hooks are critical: They make the AI agent safe by default. Without hooks, an agent can write secrets to code, modify guardrails, or deploy to production. With hooks, you enforce policies deterministically β no LLM judgment involved.
Primitive 6: Agentic Workflows
Files: .github/workflows/*.md (compiled to YAML GitHub Actions)
Agentic workflows are natural language automation that compiles to GitHub Actions. They define AI-driven CI/CD pipelines.
<!-- .github/workflows/ai-review.md -->
# AI Code Review
## Trigger
On pull request to main branch.
## Steps
1. Validate TuneKit configs
2. Run evaluation pipeline
3. Post review summary as PR comment
4. Block merge if critical issues foundKey insight: The .md file is the source of truth β itβs human-readable and AI-editable. It compiles to YAML for GitHub Actions.
Use for: PR review automation, deployment pipelines, scheduled maintenance, issue triage.
Permissions: Always read-only unless explicitly elevated. Principle of least privilege.
F4.6 Layer 4 β Distribution (Plugins)
Primitive 7: Plugins
Plugins bundle agents + skills + commands into a distributable package. Two distribution modes:
| Mode | How | Example |
|---|---|---|
| Self-hosted | Host on your own repo | Team shares internal agent stacks |
| Marketplace | List in GitHub Marketplace | Public distribution, discoverability |
{
"plugin": "frootai-enterprise-rag",
"version": "1.0.0",
"agents": ["builder", "reviewer", "tuner"],
"skills": ["deploy-azure", "evaluate", "tune"],
"prompts": ["deploy", "test", "review", "evaluate"],
"hooks": ["guardrails"],
"mcp_servers": ["frootai"]
}plugin.json declares whatβs inside. Consumers install the plugin β get all agents, skills, prompts, and hooks preconfigured.
FrootAI solution plays can ship a plugin manifest with their agentic assets. The repository currently contains 101 numbered solution-play catalog directories. Treat each playβs checked-in manifest and specification as authoritative because maturity and packaged assets vary by play. Browse them at github.com/frootai/frootai/tree/main/solution-playsΒ .
F4.7 FrootAIβs Solution-Play Implementation
FrootAI projects a consistent .github agentic structure into solution plays. The following is the target structure; use the individual play manifest to determine which assets a specific play currently ships:
solution-plays/01-enterprise-rag/
βββ .github/
β βββ copilot-instructions.md # Layer 1
β βββ instructions/
β β βββ azure-coding.instructions.md # Coding standards
β β βββ rag-patterns.instructions.md # RAG-specific rules
β β βββ security.instructions.md # Security conventions
β βββ prompts/
β β βββ deploy.prompt.md # /deploy
β β βββ test.prompt.md # /test
β β βββ review.prompt.md # /review
β β βββ evaluate.prompt.md # /evaluate
β βββ agents/
β β βββ builder.agent.md # Implementation
β β βββ reviewer.agent.md # Code review
β β βββ tuner.agent.md # TuneKit verification
β βββ skills/
β β βββ deploy-azure/SKILL.md # Azure deployment
β β βββ evaluate/SKILL.md # Quality evaluation
β β βββ tune/SKILL.md # Config validation
β βββ hooks/
β β βββ guardrails.json # Policy enforcement
β βββ workflows/
β βββ ai-review.md # PR review automation
β βββ ai-deploy.md # Deployment automationDo not infer an ecosystem-wide file count from this example. Generated projections and play maturity change independently; validate a play from its manifest and quality-gate evidence.
Agent Chain (per play)
F4.8 Decision Guide β When to Use What
| I want to⦠| Use this primitive | Layer |
|---|---|---|
| Set coding standards for the whole repo | Instructions (.instructions.md) | 1 |
| Create a repeatable task (deploy, test) | Prompt File (.prompt.md) | 2 |
| Create a specialist AI persona | Custom Agent (.agent.md) | 2 |
| Package a runbook with scripts | Skill (SKILL.md + scripts) | 2 |
| Block dangerous tool actions | Hook (guardrails.json) | 3 |
| Automate PR reviews or deployments | Agentic Workflow (.md β Actions) | 3 |
| Share agent stacks across repos | Plugin (plugin.json) | 4 |
Layering Strategy
Start here β Layer 1 (Instructions)
β Need slash commands? β Layer 2 (Prompts)
β Need specialist agents? β Layer 2 (Agents + Skills)
β Need safety enforcement? β Layer 3 (Hooks)
β Need CI/CD automation? β Layer 3 (Workflows)
β Need to share across repos? β Layer 4 (Plugins)F4.9 Building Your Own .github Agentic OS
Step 1: Start with Instructions (5 minutes)
Create .github/copilot-instructions.md:
You are working on [PROJECT NAME].
Framework: [e.g., Python FastAPI + Azure]
Always use managed identity. Never hardcode secrets.
Follow the patterns in docs/architecture.md.Step 2: Add Modular Instructions (10 minutes)
Create .github/instructions/ with domain-specific files.
Step 3: Add Prompt Files (15 minutes)
Create .github/prompts/ for common tasks: deploy, test, review.
Step 4: Add Agents (20 minutes)
Create .github/agents/ with specialist personas for your codebase.
Step 5: Add Skills (20 minutes)
Create .github/skills/ with self-contained runbooks.
Step 6: Add Hooks (10 minutes)
Create .github/hooks/guardrails.json with preToolUse policies.
Step 7: Add Workflows (15 minutes)
Create .github/workflows/ with AI-driven CI/CD.
Total time: ~95 minutes for a complete .github agentic OS.
Or use FrootAI: run FrootAI: Initialize DevKit β get all 19 files instantly.
Applied Scenario: Compose a Governed Repository Assistant
Situation: A team wants Copilot to apply architecture rules, invoke a repeatable review capability, and run deterministic checks before merge.
Composition: Put durable rules in scoped instructions, package the review method as a skill, use an agent only when tool choice or orchestration is required, and keep deterministic enforcement in hooks or workflows.
Review gate: Every primitive must declare a narrow purpose, source owner, applicable paths, required tools, and a failure mode that does not silently bypass governance.
Validation: Test one matching file, one non-matching file, one denied tool call, and one workflow failure before distributing the package.
Key Takeaways
- The
.githubfolder is now an operating system β 7 primitives, 4 layers, one repo. - Layer 1 (Instructions) is the foundation β always start here. Passive memory that applies to every prompt.
- Layer 2 (Prompts, Agents, Skills) adds on-demand power β specialist personas, slash commands, self-contained logic.
- Layer 3 (Hooks, Workflows) adds safety β deterministic enforcement and AI-driven CI/CD.
- Layer 4 (Plugins) enables distribution β share agent stacks across repos and marketplace.
- Agent chaining (builder β reviewer β tuner) creates quality gates that catch issues before production.
- Hooks are non-negotiable β
preToolUsegates prevent secrets in code, policy violations, and unsafe operations. - FrootAI ships 380 files β 19 per solution play Γ 20 plays. Ready-to-use .github agentic OS for 20 AI solutions.
Next: O2: AI Agents & Agent Framework for deep agent architecture | O3: MCP, Tools & Function Calling for MCP server patterns
Knowledge Check
1. When should guidance be an instruction instead of an agent?
Expected evidence
When it is durable contextual policy and does not require autonomous tool choice or orchestration.
2. What belongs in a deterministic workflow rather than a prompt?
Expected evidence
Checks whose pass/fail result must be reproducible, auditable, and independent of model variability.
3. Why should primitives reference canonical knowledge instead of copying it?
Expected evidence
References preserve one source of truth and prevent duplicated guidance from drifting.