Show HN: AgentLoop – a Claude agent starter you can read

winphoto1 pts1 comments

GitHub - mnifzied-create/agentloop: A Claude agent starter you can actually read — streaming + tool use in ~150 lines. Next.js + the official Anthropic SDK. MIT. · GitHub

/" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

mnifzied-create

agentloop

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

main

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>2 Commits<br>2 Commits

app

app

lib

lib

.env.example

.env.example

.gitignore

.gitignore

LICENSE

LICENSE

README.md

README.md

next.config.mjs

next.config.mjs

package-lock.json

package-lock.json

package.json

package.json

tsconfig.json

tsconfig.json

View all files

Repository files navigation

🔁 AgentLoop

The AI agent starter you can actually read.<br>The full agent loop — streaming + tool use — in ~150 lines. No framework, no 40-file SaaS template to gut. Clone, add a key, deploy.

Quickstart · How it works · Add a tool · Pro

The AI-starter shelf is crowded with two kinds of repo: black-box frameworks that hide the loop, and giant SaaS kits you spend a day deleting. AgentLoop is neither. It's the actual agent loop — model calls a tool, you run it, the result goes back, repeat — written plainly enough to learn from and solid enough to build on.

What you get (free, MIT)

✅ Streaming chat — tokens render as they arrive. Plain fetch + ReadableStream, zero UI deps, no SDK lock-in.

✅ Real tool use — a working agent loop, not a single if.

✅ Two example tools (get_current_time, calculate) + a one-function extension point.

✅ Typed & commented — Next.js App Router + the official Anthropic SDK. Current with today's Claude models.

✅ One-command deploy to Vercel.

Quickstart

git clone https://github.com/mnifzied-create/agentloop.git<br>cd agentloop<br>npm install<br>cp .env.example .env.local # then paste your ANTHROPIC_API_KEY<br>npm run dev # http://localhost:3000

Get a key at console.anthropic.com. Ask the agent what is (12 * 9) + 7? and watch it call the calculate tool.

Deploy

Set ANTHROPIC_API_KEY in your Vercel project env vars and you're live.

How it works

The whole agent lives in app/api/chat/route.ts:

Stream a Claude turn, forwarding text tokens to the browser as they arrive.

When the model emits a tool_use block, run the matching tool from lib/tools.ts.

Feed the tool result back as the next turn and loop (bounded to 5 steps).

Stop when the model returns a normal text answer.

That's the entire pattern behind "AI agents" — no framework required.

Add your own tool

Two edits, one file:

// lib/tools.ts<br>export const tools = [<br>// ...existing tools<br>name: "get_weather",<br>description: "Get the current weather for a city.",<br>input_schema: {<br>type: "object",<br>properties: { city: { type: "string" } },<br>required: ["city"],<br>},<br>},<br>];

export async function runTool(name, input) {<br>switch (name) {<br>// ...existing cases<br>case "get_weather":<br>return JSON.stringify(await fetchWeather(input.city));

Claude reads your description to decide when to call it. That's the whole contract.

Tech

Next.js (App Router) · TypeScript · @anthropic-ai/sdk · zero UI dependencies.

🔁 AgentLoop Pro

The free core is the loop. Pro is every pattern you'll reach for next — each one as minimal and readable as the core. Not a bloated SaaS kit; the same teach-by-reading philosophy, leveled up.

Pattern<br>Free<br>Pro

Streaming + single-tool loop

Parallel & multi-tool orchestration

Structured outputs (typed JSON)

Persistent memory (SQLite threads)

Retries, timeouts & error handling

Human-in-the-loop approval gate

Sub-agents / delegation

Eval harness (catch regressions)

Written guide explaining every pattern

→ Get AgentLoop Pro — $29 one-time: ko-fi.com/aimnifzied

MIT core. Built in public by an indie dev shipping fast.

About

A Claude agent starter you can actually read — streaming + tool use in ~150 lines. Next.js + the official Anthropic SDK. MIT.

ko-fi.com/aimnifzied

Topics

agent

typescript

nextjs

starter-template

ai-agents

claude

tool-use

llm

anthropic

Resources

Readme

License

MIT license

Uh oh!

There was an error while loading....

tool agent agentloop next json loop

Related Articles