amber-lang

SKILL.md

This skill provides comprehensive knowledge of Amber (amber-lang.com), a modern programming language that compiles to Bash script. Use it to write, review, debug, convert, and explain Amber code.

Quick Reference

Amber compiles to Bash 3.2+ compatible scripts. It provides ECMAScript-inspired syntax, type safety, and mandatory error handling.

CLI: amber run <file.ab> | amber build <in.ab> <out.sh> | amber check <file.ab> | amber eval '<code>'

Shebang: #!/usr/bin/env amber | File extension: .ab

Types: Text, Int, Num (needs bc), Bool, Null, [T] (typed array, no nesting)

Key syntax patterns:

let x = 10                          // variable
const Y = 20                        // constant
fun add(a: Int, b: Int): Int { }    // typed function
fun risky(): Int? { fail 1 }        // failable function (? = can fail)
pub fun exported(): Null { }        // public/exportable
fun modify(ref arr: [Int]) { }     // pass by reference
$ command $                          // shell execution
$ cmd $ failed(code) { }            // error handling (MANDATORY)
$ cmd $?                             // propagate failure
import { fn } from "std/module"     // stdlib import
import { fn } from "./file.ab"     // local import
main (args) { }                     // entry point

Modifiers: silent (suppress output), trust (skip error handling), sudo (privilege escalation)

Control flow: if/else, if { cond: expr } (chain), ternary (x then a else b), loop, for i in 0..n, while

Code Style Guidelines

  1. Always handle errors — use failed, succeeded, exited, or ? for every failable operation
  2. Use typed function signatures for clarity
  3. Prefer stdlib over raw commands (e.g., file_read over $ cat file $)
  4. Use main blocks so scripts work correctly when imported
  5. Use const for values that don't change
  6. Avoid trust — handle errors explicitly
  7. Use ranges (0..n) instead of manual counter loops

Additional References

For detailed syntax, types, operators, and all language features, see references/syntax.md

For standard library documentation:

For real-world example scripts, see references/examples.md

Weekly Installs
7
First Seen
5 days ago
Installed on
opencode7
gemini-cli7
claude-code7
github-copilot7
codex7
kimi-cli7