A community-driven registry for Claude, Cursor, Windsurf, Cline & more. Not affiliated with Anthropic.
Are you the author? Sign in to claim
Demystify AI agents by building them yourself. Local LLMs, no black boxes, real understanding of function calling, memor
Learn to build AI agents locally without frameworks. Understand what happens under the hood before using production frameworks.

This repository teaches you to build AI agents from first principles using local LLMs and node-llama-cpp. By working through these examples, you'll understand:
A Python version of this tutorial is available here: https://github.com/pguso/agents-from-scratch
Philosophy: Learn by building. Understand deeply, then use frameworks wisely.
This repository now has a matching companion website:
The website is not a replacement for this repo, but a conceptual companion that:
Recommended workflow:
Think of the site as the map and this repo as the terrain.
./models/ folder, details in DOWNLOAD.mdnpm install
node intro/intro.js
node simple-agent/simple-agent.js
node react-agent/react-agent.js
Follow these examples in order to build understanding progressively:
intro/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: Model loading, context, inference pipeline, token generation
openai-intro/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: Inference endpoints, network latency, cost vs control, data privacy, vendor dependence
translation/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: System prompts, agent specialization, behavioral constraints, prompt engineering
think/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: Reasoning agents, problem decomposition, cognitive tasks, reasoning limitations
batch/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: Parallel execution, sequences, batch size, throughput optimization
coding/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: Streaming, token-by-token generation, response control, real-time feedback
simple-agent/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: Function calling, tool definitions, agent decision making, action-taking
This is where text generation becomes agency!
simple-agent-with-memory/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: Persistent memory, state management, memory systems, context augmentation
react-agent/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: ReAct pattern, iterative reasoning, observation-action cycles, multi-step agents
This is the foundation of modern agent frameworks!
aot-agent/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: AoT planning, atomic operations, dependency resolution, plan validation, structured reasoning
error-handling/ | Code | Code Explanation | Concepts
What you'll learn:
AgentWorkflowError) and correlation ids for supportKey concepts: Error taxonomy, retry policies, timeouts, fallbacks, degraded mode, observability, user-safe messaging
tree-of-thought/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: Tree of Thought, beam search, branch pruning, verifiable objectives, search controllers
graph-of-thought/ | Code | Code Explanation | Concepts
What you'll learn:
must_include, must_avoid, conflict_notes)Key concepts: Graph of Thought, DAG orchestration, multi-source fusion, merge-before-generate, policy reconciliation
Decision guide: use ToT when you need to search competing paths; use GoT when you need to combine multiple sources into one consistent policy. Compare both in:
chain-of-thought/ | Code | Code Explanation | Concepts
What you'll learn:
Key concepts: Chain of Thought, structured reasoning traces, policy-constrained decisions, explainability, review-ready workflows
tool-routing-embeddings/ | Code | Code Explanation | Concepts
What you'll learn:
session.promptKey concepts: Tool routing, embedding similarity, exemplar design, context/token savings, pinned tools, retrieval-style agent design
Each example folder contains:
<name>.js - The working code exampleCODE.md - Step-by-step code explanationCONCEPT.md - High-level conceptsAI Agent = LLM + System Prompt + Tools + Memory + Reasoning Pattern
─┬─ ──────┬────── ──┬── ──┬─── ────────┬────────
│ │ │ │ │
Brain Identity Hands State Strategy
1. intro → Basic LLM usage
2. translation → Specialized behavior (system prompts)
3. think → Reasoning ability
4. batch → Parallel processing
5. coding → Streaming & control
6. simple-agent → Tool use (function calling)
7. memory-agent → Persistent state
8. react-agent → Strategic reasoning + tool use
Simple Agent (Steps 1-5)
User → LLM → Response
Tool-Using Agent (Step 6)
User → LLM ⟷ Tools → Response
Memory Agent (Step 7)
User → LLM ⟷ Tools → Response
↕
Memory
ReAct Agent (Step 8)
User → LLM → Think → Act → Observe
↑ ↓ ↓ ↓
└──────┴──────┴──────┘
Iterate until solved
helper/prompt-debugger.js
Utility for debugging prompts sent to the LLM. Shows exactly what the model sees, including:
Usage example in simple-agent/simple-agent.js
ai-agents/
├── README.md ← You are here
├─ examples/
├── 01_intro/
│ ├── intro.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 02_openai-intro/
│ ├── openai-intro.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 03_translation/
│ ├── translation.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 04_think/
│ ├── think.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 05_batch/
│ ├── batch.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 06_coding/
│ ├── coding.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 07_simple-agent/
│ ├── simple-agent.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 08_simple-agent-with-memory/
│ ├── simple-agent-with-memory.js
│ ├── memory-manager.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 09_react-agent/
│ ├── react-agent.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 10_aot-agent/
│ ├── aot-agent.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 11_error-handling/
│ ├── error-handling.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 12_tree-of-thought/
│ ├── tree-of-thought.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 13_graph-of-thought/
│ ├── graph-of-thought.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 14_chain-of-thought/
│ ├── chain-of-thought.js
│ ├── CODE.md
│ └── CONCEPT.md
├── 15_tool-routing-embeddings/
│ ├── tool-routing-embeddings.js
│ ├── CODE.md
│ └── CONCEPT.md
├── helper/
│ └── prompt-debugger.js
├── models/ ← Place your GGUF models here
└── logs/ ← Debug outputs
This is a learning resource. Feel free to:
Educational resource - use and modify as needed for learning.
Built with ❤️ for people who want to truly understand AI agents
Start with intro/ and work your way through. Each example builds on the previous one. Read both CODE.md and CONCEPT.md for full understanding.
Happy learning!
💻 A curated list of papers and resources for multi-modal Graphical User Interface (GUI) agents.
An AI-powered custom node for ComfyUI designed to enhance workflow automation and provide intelligent assistance
Deterministic multi-agent pipeline for end-to-end software development, orchestrating CLI-based AI tools (e.g. Gemini, C
Pocket Flow: Codebase to Tutorial