Codemode
++ Let the model write code that orchestrates BashKit tools in batches. +
+Overview
+
+ Codemode wraps selected BashKit tools behind one Cloudflare Codemode
+ tool. Instead of asking the model to call Glob, then{" "}
+ Grep, then Read one turn at a time, the
+ model can write a small JavaScript async arrow function that calls
+ those tools with loops, branches, and parallel work.
+
+ BashKit does not run the code itself. It delegates to Cloudflare + Codemode's executor, while the code still calls BashKit's + policy-wrapped tools. That means context layers, plan-mode gates, + output policy, and sandbox restrictions keep applying. +
+Setup
+
+ Install Cloudflare Codemode alongside BashKit, then provide an
+ executor through codemode config.
+
+ Cloudflare Codemode currently targets AI SDK v6, so BashKit's + codemode adapter follows that path. +
+Batched Workflows
++ Codemode is useful when the model needs to fan out across files, + combine results, or retry/narrow a search. The generated code can + batch those steps into one tool call. +
++ That would normally take many model/tool turns. With Codemode, the + model can express the workflow as code and return a structured + result. +
+Tool Selection
+
+ Keep the inner tool set narrow. includeTools is the
+ safest default because generated code can loop and fan out calls.
+
+ BashKit always excludes client-intervention tools from Codemode:
+ AskUser, EnterPlanMode,{" "}
+ ExitPlanMode, tools without an execute{" "}
+ function, and tools with needsApproval.
+
Namespaces
+
+ The tool exposed to the model is named codemode by
+ default. Inside the generated JavaScript, selected BashKit tools are
+ exposed under BashKit's bashkit.* namespace. Tool
+ methods keep BashKit's public tool names, so the grep tool is{" "}
+ bashkit.Grep(...).
+
+ Use providers when you want separate namespaces for
+ custom tool groups. Each provider gets its own object inside the
+ generated code, which keeps domain-specific helpers easier to scan.
+
+ Executable-only and needsApproval filtering applies to
+ every namespace. Top-level includeTools narrows the
+ default bashkit.* namespace; providers can define their
+ own includeTools or excludeTools.
+
Policy
+
+ Codemode receives the same wrapped tools that normal model tool
+ calls receive. If plan mode is active, Bash,{" "}
+ Write, and Edit are still blocked by the
+ execution policy even when generated code calls them.
+