ACL.md
code:acl.md
# Agent Communication Language (ACL)
## Version 3.5
---
## 1. Introduction
### 1.1 Purpose
Agent Communication Language (ACL) is a Domain-Specific Language (DSL) for concise, structured communication with AI agents. It provides a simple syntax for instructing agents in development workflows.
### 1.2 Core Principle: Context Over Formalism
**ACL prioritizes intent and context over strict syntax rules.**
This is not a language for static parsing—it's a communication protocol for LLMs. The agent should:
1. **Understand intent first** - Focus on what the user wants
2. **Interpret from context** - Use conversation history and project state
3. **Be flexible** - Adapt to variations in syntax and expression
### 1.3 Design Goals
- **Simplicity**: Easy to learn and use
- **Brevity**: Minimal verbosity
- **Flexibility**: Context-aware interpretation
- **Composability**: Chain operations naturally
- **Persistence**: Retain knowledge across sessions
### 1.4 Scope
ACL is for:
- Development workflow automation
- Agent behavior customization
- Knowledge management
- Error handling and recovery
---
## 2. Core Concept: scope.action(details)
### 2.1 Basic Structure
All ACL expressions follow a simple pattern:
`
scope.action(details)
`
**Components**:
- **scope**: Where the action takes place (optional for global functions)
- **action**: What to do
- **details**: Parameters or context (optional)
**Examples**:
`acl
fix("failing tests") # Global function (no scope)
project.build() # Object method
test("auth/**") # Global with parameter
note("convention") # Global with parameter
project.note("convention") # Object method with parameter
`
### 2.2 Variations
**Multiple parameters**:
`acl
refactor("UserService", "extract authentication")
`
**Chaining**:
`acl
project.build() && test() && project.deploy()
`
**Property access**:
`acl
fix(test().failures)
`
**Promise-like handling**:
`acl
project.deploy()
.then("notify team")
.catch("rollback")
.finally("cleanup")
`
**Event handlers**:
`acl
on(alert, "stop and analyze the issue")
`
### 2.3 Interpretation Rules
The agent should interpret ACL expressions flexibly:
- Missing scope → assume global function or infer from context
- Unknown method → check for typos, aliases, or context clues
- Ambiguous syntax → prioritize user intent over strict parsing
---
## 3. Global Functions
### 3.1 Overview
Global functions work across all projects and are called without a scope prefix.
**Available Functions**:
- begin(goal) - Begin working on task with git branch and TODO planning
- fix(issue) - Analyze and fix problems
- refactor(targets, direction) - Refactor safely with tests
- think(issue) - Analyze without modifying files
- test(pattern?) - Run tests
- alert(message) - Alert agent about violations or mistakes
- retry() - Retry last failed task
- fetch(url) - Fetch web resources
- note(message) - Save to user-level CLAUDE.md
- docs(targets) - Understand targets and enrich documentation
### 3.2 Usage
`acl
# Fix issues
fix("typescript errors")
fix("failing unit tests")
# Safe refactoring
refactor("auth module", "separate concerns")
# Analysis only (no changes)
think("optimal caching strategy")
# Run tests
test() # All tests
test("integration/**") # Pattern filter
# Agent feedback
alert("You violated the security policy")
# Retry after fixing
project.deploy() # Fails
fix("credentials")
retry() # Retries deploy
# Fetch external data
# Save user-level notes
note("Use TypeScript strict mode")
note("Prefer composition over inheritance")
# Enrich documentation
docs("authentication module")
docs("API endpoints")
docs("UserService class")
`
### 3.3 Behavior
- **fix**: Diagnoses and resolves issues
- **refactor**: Ensures tests pass before and after changes
- **think**: Read-only analysis, provides insights
- **test**: Analyzes tests first, generates minimal specs if coverage seems insufficient, then runs tests. Returns object with .failures, .errors, .passed
- **alert**: Triggers on(alert) handlers, stops current work
- **retry**: Automatically detects and retries last failed operation
- **fetch**: Returns object with .content, .status, .headers
- **note**: Saves to user-level ~/.claude/CLAUDE.md, persists across all projects
- **docs**: Understands specified targets (modules, classes, APIs) and enriches their documentation
---
## 4. Objects
### 4.1 ACL Object
**Purpose**: System initialization and management
**Methods**:
- ACL.init() - Initialize project, create CLAUDE.md, scan build tools
- ACL.update() - Re-scan and update method definitions
- ACL.list() - Show all available methods
- ACL.undef(methods...) - Disable specified methods
**Examples**:
`acl
ACL.init() # Setup project
ACL.list() # See available methods
ACL.undef(project.deploy, project.publish) # Disable dangerous methods
`
### 4.2 project Object
**Purpose**: Project context and knowledge
**Core Methods**:
- project.note(message) - Save to .claude/CLAUDE.md or CLAUDE.md
**Dynamic Methods** (generated by ACL.init()):
- project.build(), project.lint(), project.deploy(), etc.
- Auto-generated from package.json, Makefile, justfile, etc.
**Properties**:
- project.name, project.root, project.config
**Examples**:
`acl
project.note("This project uses TypeScript strict mode")
project.build()
project.deploy()
`
**Scope**: Current project only
### 4.3 session Object
**Purpose**: Current conversation analysis
**Methods**:
- session.summary() - Generate session summary
- session.insights() - Extract actionable insights
**Properties**:
- session.id, session.duration
**Examples**:
`acl
project.note(session.insights()) # Save to project
note(session.summary()) # Save to user-level
`
**Scope**: Current conversation only
### 4.4 Standard Objects
Context-dependent objects (available when relevant):
- app - Application control: app.serve(), app.build()
- chrome/browser - Browser operations: chrome.inspect(app)
- server - Server operations: server.start(), server.stop()
---
## 5. Chaining & Handlers
### 5.1 Sequential Chaining
Use && to chain operations:
`acl
project.build() && test() && project.deploy()
`
Execution stops if any step fails.
### 5.2 Promise-like Chains
Handle success, failure, and cleanup:
`acl
method()
.then(action_on_success)
.catch(action_on_failure)
.finally(action_for_cleanup)
`
**Execution**:
- Success: method → then → finally
- Failure: method → catch → finally
**Examples**:
`acl
project.deploy()
.then("send Slack notification")
.catch("rollback and alert team")
.finally("update deployment log")
project.build()
.then(test())
.then(project.deploy())
.catch(fix("build or test failures"))
`
### 5.3 Event Handlers
Define custom behavior for events:
`acl
on(event_name, action)
`
**Supported Events**:
- alert - Triggered by alert() calls
**Examples**:
`acl
on(alert, "Stop all work and analyze the issue")
alert("You modified the wrong file")
# → Triggers handler
`
**Scope**: Current session only
---
## 6. Knowledge Management
### 6.1 Hierarchy
`
User Level (~/.claude/CLAUDE.md)
↓ Personal preferences, coding standards
Managed via: note()
Project Level (.claude/CLAUDE.md or CLAUDE.md)
↓ Project conventions, architecture
Managed via: project.note()
Session Level (temporary)
↓ Current conversation insights
Analyzed via: session.insights(), session.summary()
`
### 6.2 Persistence
| Method | File | Scope | Use Case |
|--------|------|-------|----------|
| note() | ~/.claude/CLAUDE.md | All projects | Personal preferences |
| project.note() | .claude/CLAUDE.md or CLAUDE.md | Current project | Project conventions |
| session.insights() | Return value | Temporary | Extract learnings |
### 6.3 Method Definitions
Project CLAUDE.md contains ACL method definitions:
`markdown
# ACL Method Definitions
project: {
build: exec("pnpm run build")
lint: exec("pnpm run lint")
deploy: exec("pnpm run deploy")
}
`
**Management**:
- Created by ACL.init()
- Updated by ACL.update()
- Listed by ACL.list()
---
## 7. Common Patterns
### 7.1 Quick Fixes
`acl
fix("failing tests")
fix("typescript errors")
fix(lint().errors)
`
### 7.2 Safe Refactoring
`acl
refactor("auth module", "extract logic")
refactor("API routes", "consolidate error handling")
`
### 7.3 Build Pipelines
`acl
project.build() && test() && project.deploy()
project.build()
.then(test())
.then(project.deploy())
.catch(fix("pipeline failure"))
`
### 7.4 Error Handling
`acl
project.deploy()
.then("notify team")
.catch("rollback")
.finally("cleanup resources")
`
### 7.5 Knowledge Capture
`acl
note("Use TypeScript strict mode")
note("Prefer composition over inheritance")
project.note("This project uses feature-based folders")
project.note(session.insights())
`
### 7.6 Web Resources
`acl
think(apiData.content)
`
### 7.7 Method Composition
`acl
fix(test().failures)
refactor(lint().errors, "improve code quality")
think(project.analyze().bottlenecks)
`
### 7.8 Documentation
`acl
docs("authentication module")
docs("UserService class")
docs("REST API endpoints")
`
### 7.9 Custom Behaviors
`acl
on(alert, "Stop and analyze")
ACL.undef(project.deploy, project.publish)
`
---
## 8. Best Practices
### 8.1 When to Use ACL
- ✅ Quick workflows
- ✅ Build pipelines
- ✅ Error handling
- ✅ Knowledge persistence
- ✅ Agent customization
### 8.2 When to Use Natural Language
- ✅ Complex explanations
- ✅ Exploratory questions
- ✅ Unclear mappings
### 8.3 Naming
- Use camelCase: buildAndTest()
- Be descriptive but concise
- Follow project conventions
### 8.4 Knowledge Management
- note() for personal preferences (user-level)
- project.note() for project-specific rules
- ACL.update() after changing build scripts
- session.insights() at end of work
### 8.5 Error Handling
- Use .then/.catch/.finally for critical operations
- Use alert() for agent mistakes
- Define on(alert) handlers early in session
### 8.6 Method Safety
- Use ACL.undef() to disable dangerous methods
- Undefine at session start
- Common: disable production deploys, destructive operations
---
## 9. Declaration Syntax
### 9.1 Object Declaration
`acl
objectName := expression
`
**Example**:
`acl
`
### 9.2 Method Definition
`acl
objectName: {
methodName: exec("command")
otherMethod: "natural language instruction"
}
`
**Example**:
`acl
project: {
build: exec("pnpm run build")
deploy: exec("pnpm run deploy")
verify: project.build && test
}
`
---
## 10. Reserved Keywords
- exec - Command execution
- on - Event handler definition
- then - Promise success handler
- catch - Promise error handler
- finally - Promise cleanup handler
---
## 11. File Locations
| File | Location | Purpose |
|------|----------|---------|
| User CLAUDE.md | ~/.claude/CLAUDE.md | User-wide configuration |
| Project CLAUDE.md | .claude/CLAUDE.md or CLAUDE.md | Project configuration |
| ACL definitions | Within CLAUDE.md files | Method definitions |
---
## 12. Future Extensions
- Conditional execution: if condition then command
- Loops: for item in items do command
- Pattern-based undef: ACL.undef(project.*)
- Nested promise chains
- Promise.all() / Promise.race() equivalents
- Additional events: on(error), on(complete)
---
**Version**: 3.5
**Last Updated**: 2025-10-07