Implementing a feature in an existing project
The generated AGENTS.md gives coding agents required project conventions and a checklist to run before finishing a change. Read kscript.json, the generated symbol index and one neighboring feature first. The manifest sets the entry point, native sources and generator paths. The index shows which types and operations already exist. Follow the project's configured folders and script format. Look up command and method signatures in the generated package reference or MCP.
| When the feature needs | Where the code belongs |
|---|---|
| An email address, UUID, duration or URL | Give the parameter or field its built-in type. Its constructor and methods implement the format. |
| A value with an application-specific rule | Use kscript make native for a project-wide refinement. Define its normalization, validation and value-specific methods once. Project natives load automatically. |
| A known group of fields | Use kscript make type, import the record, and accept it at the function boundary. For external JSON use ->convert(from: json, as: Type). Keep map for data with genuinely open keys. |
| A route that accepts a JSON body | Use kscript make route and kscript make request. The route selects the controller. The controller receives json: RequestType and the framework validates the body. |
| Persistent data | Use a model and the project's migrations. Keep shared domain behavior with the type or in a library module. Put rendering in a view or page component. |
Define an item key once and use it as the type of the request field.
| Command | What it does |
|---|---|
kscript make native ItemKey --base string --normalize '$value->trim()' --pattern '/^item_[a-zA-Z]+$/' | A native type for item keys. |
kscript make request CreateItem --fields 'key: ItemKey' | A request body that uses it. |
The default layout puts these files in natives/item-key.kscript and requests/create-item.kscript. The request can use ItemKey directly. A controller imports the request file and declares fn store(json: CreateItem). A malformed key fails request validation before the controller runs. A worker or CLI command can take key: ItemKey and get the same checks.
Test a valid normalized value, an invalid value, and the feature's observable result. Handle specific errors where the program can recover or report failure. Run kscript check --output json --warnings-as-errors, kscript test, and kscript fmt --check. Refresh the generated guidance with kscript agents and report the verification results. Project layout and generators · Semantic types