← Back to Documentation

AI Development Guide

How to use AI assistants effectively with ARO. This guide covers commands, patterns, and best practices for AI-assisted development.

CLAUDE.md

ARO includes a CLAUDE.md file in the repository root that provides context for AI assistants like Claude Code. This ensures the AI understands ARO's syntax and architecture.

Build Commands

These are the commands you'll use most frequently when developing with ARO:

$ swift build
# Build the ARO compiler and runtime
$ swift test
# Run all tests
$ aro run ./Examples/UserService
# Run a multi-file ARO application
$ aro build ./MyApp --optimize
# Compile to native binary with optimizations

Architecture Overview

Understanding the project structure helps AI assistants provide better suggestions:

Sources/
├── AROParser/          # Core parser library
├── ARORuntime/         # Runtime execution (interpreter)
│   ├── Actions/        # Action protocol, registry, built-ins
│   ├── Core/           # ExecutionEngine, Context
│   ├── Events/         # EventBus, event types
│   ├── HTTP/           # Server (SwiftNIO), Client
│   ├── FileSystem/     # File operations, FileMonitor
│   ├── Sockets/        # TCP server/client
│   └── OpenAPI/        # Contract-first routing
├── AROCompiler/        # Native compilation (C code generation)
├── AROCRuntime/        # C-callable Swift runtime bridge
└── AROCLI/             # CLI (run, compile, check, build)

Examples/
├── HelloWorld/         # Single-file example
├── HTTPServer/         # HTTP server example
├── FileWatcher/        # File monitoring example
└── UserService/        # Multi-file application

Proposals/              # 29 evolution proposals
Documentation/          # Developer guides

Application Structure

An ARO application is a directory containing .aro files:

MyApp/
├── openapi.yaml       # OpenAPI contract (required for HTTP server)
├── main.aro           # Contains Application-Start (required)
├── users.aro          # Feature sets for user operations
├── orders.aro         # Feature sets for order operations
└── events.aro         # Event handler feature sets

Key Rules

ARO Syntax Quick Reference

Feature Set

(Feature Name: Business Activity) {
    Action the <result> from/with/to the <object>.
    Return an <OK: status> with <result>.
}

Comments

(* This is a comment *)

(*
   Multi-line comments
   are also supported
*)

Event Handlers

(* Feature sets named after operationIds handle HTTP requests *)
(listUsers: User API) { ... }
(createUser: User API) { ... }

(* Handler suffix for domain events *)
(Send Email: UserCreated Handler) { ... }
(Process File: FileCreated Handler) { ... }

Action Semantic Roles

RoleDirectionExample Verbs
REQUESTExternal → InternalExtract, Retrieve, Request
OWNInternal → InternalCreate, Compute, Transform, Validate
RESPONSEInternal → ExternalReturn, Throw
EXPORTInternal → ExternalStore, Publish, Log, Send, Emit

Happy Case Design

ARO code contains only the happy case. Errors are handled by the runtime. For example, when a user cannot be retrieved from the repository, the server returns: Can not retrieve the user from the user-repository where id = 530.

Not for Production

This approach is terribly insecure for production code. ARO is designed for prototyping and learning, not production deployments.

Creating Custom Actions

When extending ARO with new actions, follow this pattern:

public struct MyAction: ActionImplementation {
    public static let role: ActionRole = .own
    public static let verbs: Set<String> = ["MyVerb"]
    public static let validPrepositions: Set<Preposition> = [.with, .from]

    public init() {}

    public func execute(
        result: ResultDescriptor,
        object: ObjectDescriptor,
        context: ExecutionContext
    ) async throws -> any Sendable {
        // Get input from context
        let input: String = try context.require(object.identifier)

        // Process and bind result
        let output = process(input)
        context.bind(result.identifier, value: output)

        // Emit event
        context.emit(MyEvent(value: output))

        return output
    }
}

// Register
ActionRegistry.shared.register(MyAction.self)

Concurrency

All core types (SymbolTable, Token, AST nodes, ActionImplementation) are Sendable for Swift 6.3 concurrency safety.

Tips for AI Assistants

Full Reference

For the complete AI development guide, see the CLAUDE.md file in the repository.