> ## Documentation Index
> Fetch the complete documentation index at: https://docs.declaw.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cookbook

> Runnable examples for every Declaw feature, organized by category.

Browse 49 end-to-end examples. Every example has a `main.py` (and `main.ts` where noted) you can run against your own Declaw deployment.

## Getting Started

<CardGroup cols={2}>
  <Card title="Hello World" icon="hand-wave" href="/cookbook/getting-started/hello-world">
    Create a sandbox, run a command, print output. Python + TypeScript.
  </Card>

  <Card title="Sandbox Lifecycle" icon="arrows-rotate" href="/cookbook/getting-started/sandbox-lifecycle">
    Create, inspect, extend timeout, kill. Both SDKs.
  </Card>

  <Card title="Multi-Sandbox Isolation" icon="shield-halved" href="/cookbook/getting-started/multi-sandbox-isolation">
    Prove two sandboxes have fully isolated filesystems and processes.
  </Card>
</CardGroup>

## Built-in Templates

<CardGroup cols={2}>
  <Card title="base — shell tools" icon="terminal" href="/cookbook/templates/base-shell-tools">
    Run `git`, `curl`, and `jq` end-to-end inside the minimal sandbox.
  </Card>

  <Card title="python — pandas analysis" icon="python" href="/cookbook/templates/python-pandas-analysis">
    Pipe a CSV through `pandas` and read JSON results back.
  </Card>

  <Card title="node — TypeScript script" icon="js" href="/cookbook/templates/node-typescript-script">
    Compile a `.ts` file with `tsc` and run it under Node 20.
  </Card>

  <Card title="ai-agent — frameworks check" icon="robot" href="/cookbook/templates/ai-agent-frameworks">
    Verify the major LLM-framework SDKs import inside the agent sandbox.
  </Card>

  <Card title="ai-agent — KYC with CrewAI" icon="shield-check" href="/cookbook/templates/ai-agent-kyc-crewai">
    Fintech: four-agent CrewAI KYC pipeline with PII + injection defense.
  </Card>

  <Card title="ai-agent — prior auth with LangGraph" icon="file-medical" href="/cookbook/templates/ai-agent-prior-auth-langgraph">
    Health-tech: LangGraph workflow with PHI redact + rehydrate around a real GPT-4.1 call.
  </Card>
</CardGroup>

## Commands

<CardGroup cols={2}>
  <Card title="Run Command" icon="terminal" href="/cookbook/commands/run-command">
    Run commands with env vars, working directories, and error handling.
  </Card>

  <Card title="Stream Command" icon="wave-pulse" href="/cookbook/commands/stream-command">
    Stream command output in real-time via SSE callbacks.
  </Card>

  <Card title="Background Process" icon="circle-play" href="/cookbook/commands/background-process">
    Start, list, and kill background processes by PID.
  </Card>

  <Card title="Multi-Language Execution" icon="code" href="/cookbook/commands/multi-language-execution">
    Run shell, Python scripts, and pipelines in a single sandbox.
  </Card>
</CardGroup>

## Filesystem

<CardGroup cols={2}>
  <Card title="File Operations" icon="folder-open" href="/cookbook/filesystem/file-operations">
    Write, read, list, rename, batch-write, and remove files. Both SDKs.
  </Card>

  <Card title="Upload Dataset & Analyze" icon="arrow-up-to-line" href="/cookbook/filesystem/upload-dataset-analyze">
    Upload a CSV, run an analysis script, read back JSON results.
  </Card>

  <Card title="Download Results" icon="arrow-down-to-line" href="/cookbook/filesystem/download-results">
    Generate files in a sandbox and iterate over them on the host.
  </Card>
</CardGroup>

## Network Policies

<CardGroup cols={2}>
  <Card title="Network Deny All" icon="ban" href="/cookbook/network/network-deny-all">
    Block all outbound traffic. Compare against an open sandbox.
  </Card>

  <Card title="Domain Allowlist" icon="list-check" href="/cookbook/network/network-domain-allowlist">
    Allow only specific domains; block everything else.
  </Card>

  <Card title="Exfiltration Prevention" icon="lock" href="/cookbook/network/network-exfiltration-prevention">
    Deny-all networking prevents data from leaving the sandbox.
  </Card>

  <Card title="Metadata Blocking" icon="server" href="/cookbook/network/network-metadata-blocking">
    Block cloud metadata service (169.254.169.254) to prevent SSRF.
  </Card>
</CardGroup>

## PII Protection

<CardGroup cols={2}>
  <Card title="PII Redaction" icon="eye-slash" href="/cookbook/pii/pii-redaction">
    Configure PII scanning and redaction on outbound HTTP traffic.
  </Card>

  <Card title="PII Actions" icon="sliders" href="/cookbook/pii/pii-actions">
    Compare redact, block, and log-only PII action modes.
  </Card>

  <Card title="PII Rehydration" icon="rotate-left" href="/cookbook/pii/pii-rehydration">
    Transparent PII deanonymization in API responses.
  </Card>

  <Card title="Streaming Rehydration" icon="satellite-dish" href="/cookbook/pii/pii-streaming-rehydration">
    PII rehydration with SSE streaming responses and chunk buffering.
  </Card>
</CardGroup>

## Security Features

<CardGroup cols={2}>
  <Card title="Injection Defense" icon="shield-virus" href="/cookbook/security/injection-defense">
    Configure prompt injection detection and blocking.
  </Card>

  <Card title="Transformation Rules" icon="wand-magic-sparkles" href="/cookbook/security/transformation-rules">
    Regex-based request and response body transformations.
  </Card>

  <Card title="Audit Logging" icon="clipboard-list" href="/cookbook/security/audit-logging">
    Enable and retrieve security audit logs from a sandbox.
  </Card>
</CardGroup>

## LLM Providers

<CardGroup cols={2}>
  <Card title="OpenAI Code Interpreter" icon="robot" href="/cookbook/llm-providers/openai-code-interpreter">
    GPT-4o-mini generates code; Declaw executes it safely.
  </Card>

  <Card title="Anthropic Code Interpreter" icon="robot" href="/cookbook/llm-providers/anthropic-code-interpreter">
    Claude generates code; Declaw executes it in an isolated sandbox.
  </Card>

  <Card title="Groq Code Interpreter" icon="bolt" href="/cookbook/llm-providers/groq-code-interpreter">
    Llama via Groq generates code; Declaw executes it.
  </Card>

  <Card title="Gemini Code Interpreter" icon="google" href="/cookbook/llm-providers/gemini-code-interpreter">
    Google Gemini generates code; Declaw executes it.
  </Card>

  <Card title="Local LLM Code Interpreter" icon="house-laptop" href="/cookbook/llm-providers/local-llm-code-interpreter">
    Ollama or vLLM local LLM with Declaw code execution.
  </Card>
</CardGroup>

## Framework Integrations

<CardGroup cols={2}>
  <Card title="LangGraph" icon="diagram-project" href="/cookbook/frameworks/langgraph-python">
    LangGraph ReAct agent with a Declaw `@tool`.
  </Card>

  <Card title="CrewAI" icon="users" href="/cookbook/frameworks/crewai-python">
    CrewAI agent with a Declaw code execution tool.
  </Card>

  <Card title="AutoGen" icon="gear" href="/cookbook/frameworks/autogen-python">
    AutoGen `CodeExecutor` backed by Declaw sandboxes.
  </Card>

  <Card title="OpenAI Agents SDK" icon="robot" href="/cookbook/frameworks/openai-agents-python">
    OpenAI Agents SDK with a Declaw function tool.
  </Card>

  <Card title="Phidata / Agno" icon="leaf" href="/cookbook/frameworks/phidata-python">
    Agno (Phidata) toolkit wrapping Declaw sandboxes.
  </Card>

  <Card title="Haystack" icon="haykal" href="/cookbook/frameworks/haystack-python">
    Haystack pipeline component for Declaw code execution.
  </Card>

  <Card title="Mastra (TypeScript)" icon="js" href="/cookbook/frameworks/mastra-typescript">
    Mastra agent with a Declaw tool — TypeScript only.
  </Card>
</CardGroup>

## Agent-in-Sandbox

<CardGroup cols={2}>
  <Card title="Basic Agent" icon="robot" href="/cookbook/agent-in-sandbox/basic">
    Upload and run an autonomous agent script inside a sandbox.
  </Card>

  <Card title="OpenAI Agent" icon="robot" href="/cookbook/agent-in-sandbox/openai">
    OpenAI-powered agent running inside a locked-down sandbox.
  </Card>

  <Card title="Anthropic Agent" icon="robot" href="/cookbook/agent-in-sandbox/anthropic">
    Anthropic Claude agent executing inside a sandbox.
  </Card>

  <Card title="CrewAI Agent" icon="users" href="/cookbook/agent-in-sandbox/crewai">
    CrewAI multi-agent workflow running sandboxed.
  </Card>

  <Card title="With Network Policy" icon="network-wired" href="/cookbook/agent-in-sandbox/with-network-policy">
    Agent in sandbox with network access restrictions.
  </Card>

  <Card title="Fully Secured" icon="shield-check" href="/cookbook/agent-in-sandbox/secured">
    Agent with PII + injection defense + audit + network policy.
  </Card>
</CardGroup>

## Real-World Patterns

<CardGroup cols={2}>
  <Card title="CI/CD Sandbox" icon="circle-check" href="/cookbook/patterns/ci-cd-sandbox">
    Run tests in a sandbox to simulate a CI pipeline.
  </Card>

  <Card title="Data Analysis" icon="chart-bar" href="/cookbook/patterns/data-analysis">
    Upload dataset, run analysis, download results. Both SDKs.
  </Card>

  <Card title="Web Scraping" icon="globe" href="/cookbook/patterns/web-scraping-sandbox">
    Web scraping with a domain-restricted network policy.
  </Card>

  <Card title="MCP Server in Sandbox" icon="server" href="/cookbook/patterns/mcp-server-in-sandbox">
    Run an HTTP API server inside a sandbox.
  </Card>

  <Card title="Multi-Agent Sandboxed" icon="diagram-project" href="/cookbook/patterns/multi-agent-sandboxed">
    Multi-agent pipeline where each agent runs in its own sandbox.
  </Card>

  <Card title="Git Clone & Fix" icon="code-branch" href="/cookbook/patterns/git-clone-and-fix">
    Clone a repo, find a bug, apply a fix, run tests.
  </Card>
</CardGroup>

## Security Demos

<CardGroup cols={2}>
  <Card title="Prompt Injection Attack" icon="triangle-exclamation" href="/cookbook/security-demos/prompt-injection-attack">
    Prompt injection attack scenarios and how Declaw defends.
  </Card>

  <Card title="Supply Chain Attack" icon="box-archive" href="/cookbook/security-demos/supply-chain-attack">
    Malicious package containment inside an isolated sandbox.
  </Card>

  <Card title="Credential Leak Prevention" icon="key" href="/cookbook/security-demos/credential-leak-prevention">
    PII scanning + deny-all prevents credential exfiltration.
  </Card>

  <Card title="With vs. Without Declaw" icon="scale-balanced" href="/cookbook/security-demos/with-vs-without-declaw">
    Side-by-side: unsecured execution vs. fully secured Declaw sandbox.
  </Card>
</CardGroup>
