Files
windmill/system_prompts/base/code-mode.md
caddc3f4ad feat: let AI harnesses solve tasks with code, then save and reuse it (#12472)
* feat: let AI harnesses solve tasks with code, then save and reuse it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjsYvufUfjaH7aRMxVWTue

* fix: page code mode searches locally and name the job in the chat's run result

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjsYvufUfjaH7aRMxVWTue

* chore: point the EE ref at the code_mode feature usage registration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjsYvufUfjaH7aRMxVWTue

* fix: follow the search cursor and match words in any script

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjsYvufUfjaH7aRMxVWTue

* fix: count only test_run_code runs and save only their previews

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjsYvufUfjaH7aRMxVWTue

* refactor: drop save_preview and keep code mode programs with write_script

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjsYvufUfjaH7aRMxVWTue

* docs: trim code mode guidance and cover it with ai_evals cases

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjsYvufUfjaH7aRMxVWTue

* fix: show the staged name of drafts found by a list_workspace_items search

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjsYvufUfjaH7aRMxVWTue

* chore: update ee-repo-ref to 6e6a9f3ed1e3023da46dc6f6af8f465abb5da001

This commit updates the EE repository reference after PR #988 was merged in windmill-ee-private.

Previous ee-repo-ref: 82008bd50305789174eb50ed06d9c12b25b74d9e

New ee-repo-ref: 6e6a9f3ed1e3023da46dc6f6af8f465abb5da001

Automated by sync-ee-ref workflow.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
2026-11-17 11:01:37 +01:00

34 lines
2.0 KiB
Markdown

# Solving a task with code
When the user asks for something done against the systems their workspace connects to (look
something up in an API, move data, check a status), answer it with a Windmill script run as a
preview: it executes on the workspace's workers, with its resources. A script that worked can be
saved and run as is the next time.
1. **Look for a saved script first**, by the user's words and by the system the task touches. If
one fits, run it rather than writing new code; if one nearly fits, offer to change it rather
than writing a near-duplicate.
2. **Otherwise write one script and run it as a preview.** Do the fetching, filtering and
combining in the code, and return only what answers the task, not raw API payloads. Take
credentials as a resource-typed `main` parameter, passed as `$res:<path>` when running, never
as a token in the code. Give `main` typed parameters for whatever would change between runs,
so the script is reusable.
3. **Offer to save it** when the task is likely to come back, without saving it unasked. Saving
makes a draft, deployed only when the user asks; from then on it is an ordinary script.
<!-- chat-only -->
For a third-party API, look up its hub integration for its resource type and how to call it.
<!-- /chat-only -->
<!-- cli-only -->
Load the `write-script-<language>` skill before writing the script; the resource's fields are in
`rt.d.ts` (`wmill resource-type generate-namespace`). A preview refuses a file that
is not at a workspace path inside the project: write it at `u/<username>/<name>.ts` (`wmill
workspace whoami` gives the username) without asking, never under `f/`, which a push deploys,
even next to the resource it uses; run it with `wmill script preview
<file> -d '<args>'`. Search with `wmill script list` and `wmill flow list`; run a deployed one
with `wmill script run <path>`. Never push the file on your own. Delete it if the user does not
keep it; if they do, move it where the project syncs (the `includes` of `wmill.yaml`, `f/**` by
default) and push only on their go.
<!-- /cli-only -->