Agent skill
AILANG Debug
Debug AILANG code errors. Use when you encounter type errors, parse errors, or runtime failures in AILANG programs.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/ailang-debug
SKILL.md
AILANG Debug
Fix common AILANG errors quickly.
Quick Reference
| Error | Cause | Fix |
|---|---|---|
undefined variable: print |
Not in entry module | Use entry module or import std/io (print) |
undefined variable: println |
Wrong function name | Use print not println |
undefined variable: map |
Not imported | import std/list (map) or write recursive |
No instance for Num[string] |
print(42) |
Use print(show(42)) |
expected }, got let |
Missing semicolon | Add ; between statements |
unexpected token: for |
No loops in AILANG | Use recursion instead |
unexpected token: in |
No for x in xs |
Use match xs { ... } |
Decision Tree
Error message?
│
├─ "undefined variable: X"
│ └─ Is X a builtin?
│ ├─ Yes → Import it: ailang builtins list | grep X
│ └─ No → Check spelling, define it
│
├─ "expected }, got ..."
│ └─ Missing semicolon between statements
│ Fix: let x = 1; let y = 2; x + y
│
├─ "No instance for Num[string]"
│ └─ Passing number to string function
│ Fix: print(show(42)) not print(42)
│
├─ "unexpected token: for/while/in"
│ └─ AILANG has no loops!
│ Fix: Use recursion with match
│
└─ Parse error with braces
└─ Unmatched { } or missing expression
Fix: Check all blocks are closed
Common Fixes
1. Missing Semicolons
-- WRONG
export func main() -> () ! {IO} {
let x = 10
let y = 20
print(show(x + y))
}
-- CORRECT (semicolons between statements)
export func main() -> () ! {IO} {
let x = 10;
let y = 20;
print(show(x + y))
}
2. Print Needs String
-- WRONG: print expects string
print(42)
-- CORRECT: convert with show()
print(show(42))
3. No Loops - Use Recursion
-- WRONG: no for loops
for i in range(5) { print(show(i)) }
-- CORRECT: recursive function
export func printRange(n: int) -> () ! {IO} {
if n <= 0 then () else {
print(show(n));
printRange(n - 1)
}
}
4. Import Standard Library
-- WRONG: map not in scope
let doubled = map(\x. x * 2, nums)
-- CORRECT: import from std/list
import std/list (map)
let doubled = map(\x. x * 2, nums)
-- OR: write it yourself (recursion)
export func myMap[a,b](f: func(a) -> b, xs: [a]) -> [b] {
match xs {
[] => [],
hd :: tl => f(hd) :: myMap(f, tl)
}
}
Debugging Workflow
-
Type-check first (faster feedback):
bashailang check file.ail -
Read error location - line:column tells you where
-
Check the pattern above for your error type
-
Use REPL for quick tests:
bashailang repl > show(42) > 1 + 2 > :type \x. x * 2 -
List builtins to find imports (CLI is source of truth):
bash# SOURCE OF TRUTH: Full documentation with examples ailang builtins list --verbose --by-module # Search for specific function with full docs ailang builtins list --verbose | grep -A 10 "map" # See a specific module's functions ailang builtins list --verbose --by-module | grep -A 30 "std/list"
Resources
Always prefer CLI commands (ailang prompt, ailang builtins list --verbose) over static docs - they're always up-to-date.
See resources/error_catalog.md for additional error patterns.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?