Vex agent workflow
Use this workflow when writing, porting, debugging or reviewing Vex .vx code. Vex is a separate systems language. Start from its documented syntax and APIs even when the task resembles Rust, Go, C++ or TypeScript.
Establish the project
Read the project's instructions, vex.json and nearby working code. Check vex --version before choosing commands or interpreting diagnostics. Keep the user's requested target and dependency constraints. The documentation targets 0.4.0; recorded example checks identify their actual compiler separately in verification evidence.
For a new project, follow the first-project walkthrough. For an existing project, reuse its layout and test entry points. Finish this step with an identified entry file, compiler version and relevant test command.
Read for the task
Read only the references needed for the change. Start with the corresponding row, then follow a package link for its exact imports, signatures and ownership.
| Task | Read |
|---|---|
| Write or translate a function | Syntax, variables, functions |
| Work with records or variants | Structs, enums, error handling |
| Return, retain or mutate data | Ownership workflows |
| Choose a package or parse input | Standard-library entry path, package map, then the selected API guide |
| Validate JSON configuration | Checked fields and a complete tested program |
| Add a regression or benchmark | Testing and the project's existing tests |
| Coordinate async work | Concurrency overview, then the relevant channel/task recipe |
| Call a native library | First native integration |
| Generate declarations | Comptime recipes |
| Use tensors, graphs or devices | Capability map, then the specific execution guide |
Use Vex contracts
- Bind with
let; uselet!when rebinding or mutation is required. Read the receiver signature before choosing a shared or mutable borrow. - Use
fn name(...): ReturnTypeand the documentedimport { Name } from "module";form. Prelude types such asVec,Map,OptionandResultneed no invented package import. Package names such as"fs"and"serde/json"come from their guides. - Use
$printlnand$formatfor builtin formatting. Builtin namespacesMath,BitandCryptoare distinct from imported packages. - Distinguish owning
stringfrom borrowedstr. Keep owners alive while retaining views, spans or pointers; use the package's owning conversion when data must outlive its input. Follow ownership workflows for return values, collections, callbacks and async boundaries. - Preserve
Optionabsence andResulterrors. Use?only where the enclosing return type supports propagation. Select the actual return type from the reference instead of adding.unwrap()by analogy. - For external data, select a checked parser with explicit resource limits where available. Wire-format validation and application-schema validation are separate steps. The serde guide describes the dynamic parse and field/type/range checks used at input boundaries.
Before using an unfamiliar API, locate its declaration or current reference. If the installed version differs, preserve the diagnostic and resolve that specific mismatch against its source or versioned documentation.
Make the change verifiable
Use the smallest complete program or existing test that exercises the desired behavior. Keep imports, setup and expected output with the example. Distinguish copyable programs from fragments that depend on surrounding bindings.
Run the relevant check, program or test with the identified compiler. For parsers, include a malformed input; for an owning/borrowed conversion, exercise the intended lifetime; for concurrency, check completion and shutdown. Choose checks that establish the requested behavior rather than reproducing the implementation line by line.
When execution is unavailable, report what was source-checked and what remains unexecuted. Passing a CPU example does not qualify a GPU path, a parser example does not qualify a protocol session, and successful compilation does not prove native-library interoperability. Report the files changed, the command and observed result, and any remaining task-relevant limitation.