Skip to content

AgentScript - The New Era of AI-First Programming

Scale Beyond the Ordinary — Seize the Next Frontier with AgentScript

The AgentScript Manifesto

AgentScript is more than just another language—it’s a revolution, a promise, and a playground for both humans and AI. We believe that the future of code is collaborative, where AI can help generate, refactor, and maintain our programs without sacrificing readability or robust best practices. That’s why AgentScript blends functional programming, contract programming, and concurrency primitives into a sleek, AI-friendly syntax.

Why AgentScript?

Modern development is dominated by AI-driven code creation. Tools like Cursor, WindSurf, Cline, and beyond can spin up features rapidly, but often result in scattered code with minimal testing and shaky maintainability.
AgentScript aims to be the ultimate “intermediate pseudo-code language” that bridges human input, AI generation, and TypeScript interoperability—ensuring you get the benefits of automation with the solid foundation of best practices.

  • AI-First Design: Encourages minimal token usage, making code generation more cost-effective.
  • Declarative Contracts: Integrates contract programming, catching errors early via embedded assertions.
  • Embedded Testing: Bundles success, performance, concurrency, and smoke tests in the same file.
  • Functional + Concurrency: Adopts functional paradigms and concurrency checks to handle parallel tasks.
  • Human-Readable: Keeps syntax short while preserving clarity for quick reading, diffing, or AI-based refactoring.
  • Transpilable: Goes straight into TypeScript or modern JavaScript with minimal overhead.

At a Glance

Pioneering AI-First

Built from the ground up for AI code generation. Less tokens, more clarity, better results.

Robust Contracts

Out-of-the-box contract programming and state machines to stop bugs in their tracks before runtime.

Zero Overhead

Produces standard TypeScript. Deploy to Node.js, browsers, or serverless with no performance penalty.

Built for Tomorrow

Future-proof your code. Multiple concurrency constructs, inline tests, and clarity for AI-driven maintainability.


Introduction

AgentScript began as a bold response to a common frustration: AI-generation can save time, but it often leads to fragile or verbose code. TypeScript is powerful, but remains verbose for quick iteration or AI usage. We wanted the absolute best of both worlds: a language that is so succinct and context-rich that AI can handle it with ease, yet so structurally sound that humans trust it in production.

The Big Idea

  1. Minimize Syntax Overhead – AI thrives on smaller prompts. AgentScript keeps code short while embedding tests, concurrency strategies, and contracts.
  2. Maximize Clarity – Developers never lose track of error definitions, concurrency rules, or performance checks—they live right alongside the code.
  3. Transpile to TypeScript – No proprietary runtime or walled garden. Export to TypeScript seamlessly and harness the entire JavaScript ecosystem.

AgentScript in Action

function processPayment(amount: number, currency: string)
goal: "Process a secure payment transaction"
backstory: "Interacts with the payment gateway"
requires:
amount > 0: "Amount must be positive"
currency in ["USD", "EUR", "BTC"]: "Supported currencies only"
return: amount |> validateAmount |> convertCurrency |> processTransaction
errors:
InvalidAmount: "Amount must be positive" when amount <= 0
InvalidCurrency: "Unsupported currency" when currency not in ["USD", "EUR", "BTC"]
tests:
success: 100, "USD" -> { status: "completed", id: "tx_123" }
performance: expect < 100ms

In under a dozen lines, you see constraints, error handling, performance tests, and even the function’s goal. AI can latch onto these structured blocks, while humans quickly grasp the function’s responsibilities, constraints, and test coverage.


Core Concepts

  1. Minimal Syntax

    A crisp superset of TypeScript that strips away boilerplate while adding metadata blocks for tests, concurrency, and error handling.

  2. Intent & Context

    Each function starts with short metadata fields like goal and backstory for immediate clarity.

  3. Error Tags

    Common or custom errors are explicitly declared in each function, simplifying debugging and clarifying error pathways.

  4. State Machines

    Embedding state machine logic ensures concurrency patterns are crystal clear and testable—straight out of the box.

  5. Functional Patterns

    Pipeline operators and advanced pattern matching reduce complexity and keep your transformations explicit and AI-friendly.


Embedded Testing and Contract Programming

AgentScript enforces best practices at the language level.

  • requires blocks let you specify input constraints (like amount > 0), generating runtime checks in TypeScript.
  • Inline Tests (success, performance, concurrency, etc.) produce Vitest or k6 tests automatically at transpile time.
function fetchTodosByUser(userId: number)
goal: "Load tasks for a given user"
backstory: "Used by the main dashboard to show tasks"
requires:
userId >= 0: "User ID cannot be negative"
return: fetchFromDatabase("todos", userId)
errors:
UserNotFound: "No user found with the given ID"
tests:
success:
1 -> [{ id: 1, task: "Buy milk" }, ...]
performance:
execution: expect < 3ms
memory: expect < 5mb

By including these constraints and tests, AI (or you) can’t forget them during refactors or bug fixes.


Functional and Concurrency Primitives

  • Pipe Operator: |> for chaining transformations in a more readable, more AI-parsable style.
  • Pattern Matching:
    match (user.role) {
    case "admin" -> grantAccess(user)
    case "guest" -> promptSignup(user)
    }
  • Concurrency:
    • Native or library-based state machine syntax for advanced concurrency.
    • Built-in concurrency tests for parallel workloads.

Transpilation Flow

  1. AgentScript Source – You write your succinct, manifest-driven code.
  2. Parser & Transpiler – A specialized parser verifies embedded metadata and compiles to:
    • TypeScript for your main logic.
    • Vitest or k6 test scaffolding for performance and concurrency.
  3. Seamless Deployment – The TypeScript output leverages Node.js, browsers, serverless platforms, or anywhere JavaScript runs.

How Does It Stack Up?

FeatureTypeScriptRustAgentScriptWhy AgentScript?
ConcurrencyLibrary-basedRayon✅ Built-in concurrency patternsEverything is tested and reasoned about up front.
State MachinesLibrary-basedUsually external✅ Native constructsMake concurrency & transitions explicit, baked-in.
Type SafetyCan be strictStrong✅ High (built-in checks)AI relies on safe defaults, humans trust it in prod.
Error ManagementManual/ThrowsResults✅ Contract blocks + testsNo error left behind—declare them from the start.
AI-FriendlinessMediumMedium✅ HighMinimal syntax, explicit metadata, fewer tokens.
TestingOptional, externalInline (module tests)✅ Inline, enforcedAgents can’t skip coverage; tests are in the code.
Contract ProgrammingRuntime/manualPartial✅ Automatic requires checksInstantly catches invalid inputs at runtime.
Pipeline Operator✅ Pipeline operator (>)

Practical AI-Driven Benefits

  1. Reduced Token Footprint – AI can parse and edit smaller codebases more cheaply and effectively.
  2. Autonomous Refactoring – The language design ensures that AI tools won’t accidentally remove integral checks or tests.
  3. Boilerplate-Free – No time wasted writing repetitive code structures; AgentScript has them baked right in.
  4. Transparent Intent – Clear “intent” fields help AI refactor code with minimal confusion.

Implementation Workflow

  1. Define Requirements – Outline each function’s intent, context, and requires.
  2. Write Skeleton – Create AgentScript code with embedded tests, concurrency hints, and error definitions.
  3. Transpile – Convert to TypeScript. Watch your test suites and concurrency scaffolding auto-generate.
  4. Run Tests – Let Vitest or k6 do the heavy lifting for unit, performance, and concurrency checks.
  5. Refine – AI or humans can refine constraints, logic, and state machines. All the “contracts” live next to the code.

Long-Term Vision

AgentScript is a bold statement on how AI-driven software can be stable, maintainable, and unstoppable. We see a future where:

  • AI Productivity Skyrockets – The language’s clarity empowers LLMs to generate robust, bug-free code.
  • Best Practices Are Standard – Contract programming, concurrency patterns, and inline tests become the norm.
  • Industry-Wide Evolution – TypeScript or even other languages adopt these improved concurrency, contract, and testing patterns.

Why TypeScript as the Primary Target?

TypeScript is among the most popular and flexible languages today. By targeting TypeScript, AgentScript code gains all the ecosystem benefits—Node.js, Cloudflare, React Native, serverless, and more—without extra overhead. You get:

  1. Massive Community – Access to the thriving TypeScript ecosystem.
  2. Frequent Language Updates – Stay current with new ECMAScript features and type system advances.
  3. Broad Deployability – Wherever JavaScript can run, your AgentScript-based code can too.

Your Future Starts Now

AgentScript isn’t a side project; it’s a movement to reshape how humans and AI collaborate on code. Whether you’re a developer hungry for clarity or an AI agent eager for structure, we welcome you to explore, experiment, and build with us. The future of software starts with AgentScript—where unstoppable innovation meets bulletproof best practices.