ai-agent-core-loop

ai-agent-core-loop is a skill for Claude Code, Codex from j4flmao/agent-skills. It costs 87 tokens per session (1,991 once invoked), scanned A, original, MIT.

A guide to the basic loop used by autonomous AI agents: take in information, reason about it, perform an action, and inspect the result. It compares ReAct, which alternates reasoning and actions, with plan-first approaches.

In plain words
What is it for?
Use it to design or compare agent workflows, especially systems that call tools, receive feedback, and repeat steps until a task is complete.
Why use it?
It gives a clear way to think about agents that interact with an environment instead of replying only once. This helps when choosing how an agent should plan and respond to new results.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to design or compare agent workflows, especially systems that call tools, receive feedback, and repeat steps until a task is complete.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/j4flmao/agent-skills/core-architectures
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add j4flmao/agent-skills --skill core-architectures
Clone the repo
git clone --depth 1 https://github.com/j4flmao/agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ai-agent-core-loop

README.md
[![agentmods](https://agentmods.dev/badge/skills/j4flmao/agent-skills/core-architectures/github.svg)](https://agentmods.dev/skills/j4flmao/agent-skills/core-architectures)
Your own site
<a href="https://agentmods.dev/skills/j4flmao/agent-skills/core-architectures"><img src="https://agentmods.dev/badge/skills/j4flmao/agent-skills/core-architectures/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ai-agent-core-loop

Your own site · 80×15
<a href="https://agentmods.dev/skills/j4flmao/agent-skills/core-architectures"><img src="https://agentmods.dev/badge/skills/j4flmao/agent-skills/core-architectures.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 87 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,991 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00087 $0.01991
Opus 5.5 $0.00035 $0.00796
Sonnet 5.5 $0.00017 $0.00398
Haiku 4.5 $0.00009 $0.00199

Measured 17d ago against content hash 2c8e71d14926, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ai-agent-core-loop scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 17d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/ai/ai-agents/core-architectures/SKILL.md · 192 lines

How it starts

The opening of the file, as written. The whole thing — 192 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Core Loop

Purpose

Every agent reduces to a loop: build context from state, ask the model for the next action, execute it, record the observation, decide whether to stop. Reliability comes from the parts around the model call: how context is assembled, how actions are validated, how progress is measured, and when the loop terminates. This skill covers those mechanics and the trade-offs between ReAct, plan-and-solve, and reflection variants.

Agent Protocol

Trigger

"agent loop", "ReAct", "plan-and-solve", "re-planning", "self-reflection", "Reflexion", "agent stuck in a loop", "termination condition", "max iterations".

Input Context

  • Current loop code or framework config.
  • Typical task length and failure transcripts (where it loops, stalls, or stops early).
  • Tool list with side-effect classification.

Output Artifact

Loop specification or patch: state object, step function, termination rules, reflection policy.

Response Format

Variant: {react|plan-and-solve|plan-execute-replan|reflexion}
State: {fields}
Step: assemble_context -> decide -> validate -> execute -> observe -> update
Stop when: {success test} OR steps>={n} OR no_progress>={k} OR budget>={usd}
Reflection: {trigger, input signal, where lessons are stored}

Completion Criteria

  • Success is a checkable predicate, not "model says done".
  • Explicit caps and a no-progress detector.
  • Actions validated before execution.
  • Reflection uses an external signal (test result, error, evaluator), not introspection alone.

The Loop as a State Machine

flowchart TD
    Start([Goal]) --> Ctx[Assemble context: goal, plan, recent observations]
    Ctx --> Decide[Model proposes action or final answer]
    Decide --> Check{Final answer?}
    Check -- yes --> Verify{Success predicate holds?}
    Verify -- yes --> Done([Return])
    Verify -- no --> Reflect[Record failure reason] --> Ctx
    Check -- no --> Validate{Schema + policy valid?}
    Validate -- no --> Ctx
    Validate -- yes --> Exec[Execute tool] --> Obs[Append observation, update state]
    Obs --> Guard{Caps or no-progress hit?}
    Guard -- yes --> Abort([Abort with partial result])
    Guard -- no --> Ctx

Read the full file on GitHub · 192 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 17d ago Changed · +10 lines · -50 tokens per session 2c8e71d14926
  2. 1mo ago Changed · +140 lines · +111 tokens per session ba10f0733fee
  3. 3mo ago First seen · 42 lines · 26 tokens per session scan A 525d37b94e9b

Subscribe to this mod's changes

ai-agent-core-loop is a skill published in the GitHub repository j4flmao/agent-skills (47 stars, last pushed 17d ago), licensed MIT. It adds 87 tokens to every session and 1,991 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

ai-agent-core-loop compared with skills from other repositories

ai-agent-core-loop next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
ai-agent-core-loopj4flmao/agent-skillsSkill4717d agoMITA87Claude Code, Codex
frontend-ui-dark-tsmicrosoft/skillsSkill3.3kyesterdayMITA48Claude Code
nextjs-on-cloudflarecloudflare/skillsSkill3.6kyesterdayApache-2.0A96Claude Code
react-flow-node-tsmicrosoft/skillsSkill3.3kyesterdayMITA43Claude Code
zustand-store-tsmicrosoft/skillsSkill3.3kyesterdayMITA42Claude Code
implementing-command-palettesAgentWorkforce/relaySkill1.2ktodayApache-2.0A48Claude Code
formkitformkit/formkitSkill4.8k10d agoMITA28Codex