npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

agent-loop-flow

v0.1.0

Published

AI coding agent utility CLI that orchestrates skill flows with conditionals and loops

Readme

agent-loop-flow

npm version license

AI coding agent utility CLI that orchestrates skill flows with conditionals and loops, defined in JSONC files.

Overview

Agent-loop-flow lets you compose agent workflows by chaining skills:

skill A -> skill B -> skill C ...

Define flows in JSONC files with support for:

  • Sequential execution -- run skills in order
  • Conditional branching -- route execution based on conditions
  • Loops -- while-loops and for-each iteration
  • JSON Schema validation -- validated flow definitions with IDE autocompletion

Quick Start

Install

npm install -g agent-loop-flow

Or use with npx:

npx agent-loop-flow run my-flow.jsonc

For use as a library:

npm install agent-loop-flow

Define a Flow

Create a .jsonc file (e.g., my-flow.jsonc):

{
  "$schema": "./flow-schema.json",
  "name": "my-flow",
  "description": "Analyze and fix code",
  "variables": {
    "targetFile": "src/index.ts",
  },
  "steps": [
    {
      "type": "skill",
      "name": "analyze",
      "skill": "code-analysis",
      "prompt": "Analyze {{targetFile}} for issues",
    },
    {
      "type": "conditional",
      "name": "check-results",
      "condition": "lastResult.success",
      "then": [
        {
          "type": "skill",
          "name": "fix",
          "skill": "code-fix",
          "prompt": "Fix issues found in {{targetFile}}",
        },
      ],
    },
  ],
}

Run a Flow

# Run a flow
agent-loop-flow run my-flow.jsonc

# Run with variables
agent-loop-flow run my-flow.jsonc --var targetFile=src/app.ts

# Validate without executing
agent-loop-flow validate my-flow.jsonc

Flow Definition

Step Types

Skill Step

Executes a single skill with a prompt. Supports {{variable}} interpolation.

{
  "type": "skill",
  "name": "analyze-code",
  "skill": "code-analysis",
  "prompt": "Analyze {{targetFile}}",
}

Conditional Step

Branches execution based on a condition.

{
  "type": "conditional",
  "name": "check-result",
  "condition": "hasIssues",
  "then": [
    // steps when condition is true
  ],
  "else": [
    // steps when condition is false (optional)
  ],
}

Supported conditions:

  • Variable truthiness: "variableName"
  • Equality: "variable == \"value\""
  • Inequality: "variable != \"value\""
  • Last result: "lastResult.success"
  • Output contains: "lastResult.output contains \"error\""

While Loop

Repeats steps while a condition is true.

{
  "type": "while-loop",
  "name": "retry-loop",
  "condition": "shouldRetry",
  "maxIterations": 5,
  "steps": [
    // steps to repeat
  ],
}

For-Each Loop

Iterates over items in a variable.

{
  "type": "for-each",
  "name": "process-files",
  "items": "fileList",
  "as": "currentFile",
  "steps": [
    {
      "type": "skill",
      "name": "process",
      "skill": "processor",
      "prompt": "Process {{currentFile}}",
    },
  ],
}

Variables

Variables can be defined at the flow level and overridden via CLI:

{
  "variables": {
    "targetFile": "src/index.ts",
    "mode": "strict",
  },
}
agent-loop-flow run flow.jsonc --var targetFile=src/app.ts --var mode=lenient

Programmatic API

import { parseFlowFile, createFlowEngine } from "agent-loop-flow";
import type { SkillExecutor } from "agent-loop-flow";

// Define how skills are executed
const skillExecutor: SkillExecutor = async ({ skill, prompt, variables }) => {
  // Integrate with OpenCode SDK, Claude Agent SDK, etc.
  return { output: "result", success: true };
};

// Parse and run a flow
const flow = await parseFlowFile({ filePath: "my-flow.jsonc" });
const engine = createFlowEngine({ skillExecutor });
const result = await engine.executeFlow({ flow });

console.log(result.success);
console.log(result.results);

Examples

See the examples/ directory for sample flow definitions:

  • simple-sequential.jsonc -- Basic skill chain
  • conditional-fix.jsonc -- Conditional branching
  • loop-processing.jsonc -- For-each and while loops

Development

pnpm install
pnpm check     # fmt + lint + typecheck
pnpm test      # run tests
pnpm build     # build for distribution

License

MIT