fabric ·nu.cc

Claude Code, as a Ref.

Declare a PromptRef on a Service, bind it with options once, then prompt Claude Code from inside your Nu tree.

See it.

Ask Claude Code anything, right from your Nu program. Wrap a few asks in a Session and it remembers what you said before.

Prompts from inside your Nu tree.

PromptRef.method() declares the endpoint; nu.cc.bind(Agent, ...) hands it a ClaudeAgentOptions template — model, cwd, tools, system prompt, permissions.

nu.cc.Session(...) is a bracket. The first prompt starts a fresh cc session, the rest continue it via resume=session_id. Sibling brackets stay independent.

agent.py
python · 14 locpy
import nu
class Agent(nu.Service):
ask = nu.cc.PromptRef.method()
# two independent sessions, two prompts each
app = nu.With(
nu.cc.bind(Agent, permission_mode="bypassPermissions"),
body=nu.cc.Session(
Agent.ask(prompt="my favorite color is teal. remember it."),
Agent.ask(prompt="what color did i tell you? one word."),
),
)
await nu.arun(app)

What you can do with it.

Everything cc can do — tools, agent loops, edits, custom system prompts — reachable from a plain Ref call.

options template

Bind once, prompt many times.

Model, cwd, allowed_tools, system_prompt, permission_mode, max_turns — set on bind, override per call when you need to.

sessions

Scope multi-turn work with a bracket.

nu.cc.Session wraps a subtree. Prompts inside share one cc session so context carries. Two sibling brackets = two clean contexts.

text + meta

Every call returns cost, turns, session id.

Prompt yields a dict: text, session_id, total_cost_usd, duration_ms, num_turns. Log it, cache it, put it in a UI — like any Ref result.

Try Nu.

One command gets you the wheel with every fabric. Then follow the movies tutorial to build a real app in an afternoon.

01 Install

pip install "nustack-py[all]"

02 Run the demo

nu demo movies

03 Build your app

Browse examples

Like what you see?

The project is young. Star it, join the room, watch what we ship next.