Human-in-the-loop agent framework

AI does the work. You keep the decision.

Lexis-Two is an open framework for agent workflows where AI plans, builds and reviews — while humans stay in control of the critical turns.

$ npx @draig/lexis-two install
Open source · Portable · Human-controlled
HUMAN / INTENT Define the goal and constraints.
01 / DISCOVER Understand the problem.
02 / PLAN Define the smallest solution.
03 / BUILD Agent executes one slice.
04 / REVIEW Check against intent.
05 / HUMAN CHECKPOINT Approve, modify or reject — then continue.
AGENT WORKFLOW / READY FOR HUMAN DECISION ↻ back to 01 on the next turn
The problem

Autonomous doesn't have to mean unsupervised.

Agents can plan, write, review and operate tools. The question is not whether they can act alone, but where human judgment should enter the system.

WITHOUT A CONTROLLED LOOP

Human Prompt Agent Output

WITH LEXIS-TWO

Intent Agent loop Human checkpoint Result
The principle

Humans don't need to supervise every step. They need to own the important ones.

The Lexis loop

A workflow designed around decisions.

Structure agent work into explicit stages so the system knows what to do, what to check and when to involve a human.

01

Discover

Understand the problem before writing code.

02

Plan

Define the smallest valid solution.

03

Build

Agent executes one task, then stops.

⏸ awaits your OK
04

Review

Check implementation against intent.

01

Discover

Same: define the MVP before specifying.

02

Plan

Generate spec and tasks without intermediate pause.

03

Build all

Run the full task list in one pass, scoped by Discovery.

no pause
04

Review end

One review over the whole batch before closing.

Human checkpoint

The agent knows when to stop.

Not every action needs approval. Critical decisions do. This is where the human moves from supervisor to decision-maker.

AGENT / IMPLEMENTATION ● PAUSED

I found two valid approaches for this feature.

OPTION A

Use the native platform API. No new dependency. Smaller implementation.

OPTION B

Add a modal library. Less implementation code, but introduces a dependency.

Recommendation: OPTION A
✓ Decision recorded. Agent resuming…
Agent architecture

One loop. Several specialized agents.

Separate responsibilities without losing a shared workflow. Each role has explicit permissions — auditors are read-only by design.

CONTROL HUMAN / LOOP
lexis-one writes

Implements, edits, runs bash inside the gate.

lexis-review read-only

Evaluates changes against the spec. Never edits.

ui-architect read-only

Advises on design. Does not implement.

refactor-agent writes

Large-scale restructuring within a scoped task.

security-auditor read-only

Runs audits. Reports, does not fix.

design-auditor read-only

Detects generic AI UI drift. Only writes DESIGN-AUDIT.md.

Engineering principles

Agents need constraints, not more prompts.

Lexis biases the loop toward simpler, smaller and more maintainable solutions.

YAGNI

Build what is needed.

Don't introduce functionality before there is a concrete need.

KISS

Prefer the simple path.

Use native capabilities before adding an abstraction.

DRY

One source of truth.

Avoid duplicated knowledge and parallel implementations.

SOLID

Keep boundaries explicit.

Clear responsibilities, maintainable interfaces.

Decision ladder

Before adding code, ask whether the code should exist.

01
YAGNI Does it need to exist at all?
02
Platform Can the platform already do it?
03
Existing dependency Can the project already provide it?
04
Minimum code What is the smallest implementation that works?
Commands explained

/lexis, /specx and /desx are not the same thing.

Each command controls a different layer of the workflow.

/lexis Intensity

Changes how aggressively the lazy ruleset gates the agent. Use it to keep daily work lean, during refactors, or to turn rules off.

/specx Specs

The spec-driven lifecycle for features that touch 3+ files: proposal, plan, implement one task at a time, review, close.

/desx Design

A read-only design audit after UI work. Detects visual slop and token drift, then applies fixes outside the spec loop.

Proof in the loop

The agent doesn't just write code. It questions the code.

A representative decision: use a native browser capability instead of adding an abstraction.

WITHOUT LEXIS 74 lines
function Modal({ open, onClose, title, children }) {
  useEffect(() => {
    document.addEventListener("keydown", onEscape);
    document.body.style.overflow = "hidden";
    return () => { /* cleanup */ };
  }, [open]);
  return createPortal(
    <div className="modal-overlay" onClick={onClose}>
      <div role="dialog">
        <h2>{title}</h2>
        {children}
      </div>
    </div>,
    document.body,
  );
}
WITH LEXIS 24 lines
// lexis: native <dialog> — focus trap
// and backdrop already included
<dialog ref={dialogRef}>
  <h2>Confirm deletion</h2>
  <form method="dialog">
    <button value="cancel">Cancel</button>
    <button value="confirm">Delete</button>
  </form>
</dialog>

The agent chose the platform before the library — without being asked every turn.

Portable by design

Bring your own agent.

Lexis-Two doesn't replace the agent you already use. It gives it a shared way of working.

OpenCode
Claude Code
Cursor
Codex
Gemini CLI
Copilot
Agnostic by design

Same philosophy. Your stack, your host, your agent.

Lexis-Two doesn't lock you into a framework, an editor, or an orchestrator. The core stays universal; the specifics are detected per task and per host.

Stack

Stack-agnostic

Philosophy lives in AGENTS.md. Conventions live in stacks/<id>.md and are detected from the task's files — Node/TS shipped, Python/Go/Rust/Astro planned.

Host

Host-agnostic

One skills/ catalog and thin adapters across OpenCode, Claude Code, Cursor, Codex, Gemini CLI, Copilot, pi, and plain AGENTS.md.

Agent

Agent-agnostic

A portable ruleset, not a product lock-in. Any agent that reads instructions can follow the loop without a private orchestrator.

With numbers, not just promises

What changes when the loop has discipline.

OpenCode Go benchmark, median LOC across 5 coding tasks, 3 runs per cell.

−68%
LOC reduction vs baseline
9
documented before/after cases — Next.js, Express, FastAPI
9
hosts with full support

Results from a single run — model- and task-specific, not a universal promise.

The direction

From rules to orchestration.

Lexis-Two is the portable foundation. The longer-term direction is a programmable orchestration layer for human + agent workflows.

TODAY

Lexis-Two

Principles, skills, commands, adapters and structured agent workflows.

NEXT

Lexis-Core

Orchestration, state, agent coordination, shared context and configurable human checkpoints.

VISION

Agent systems

A programmable layer for intelligent workflows that know when to act and when to ask.

What if agents could work until your judgment is needed?

The goal is not maximum autonomy. It is useful autonomy with explicit human control at the right moments.

Get started

Start with the agent you already use.

npx @draig/lexis-two install
OpenCodeClaude CodeCursorCodexGemini CLICopilotAGENTS.md
Lexis-Two

Let the agent work. Keep the decision.