Runcastle

Market Sizing Estimator

MIT0 downloads

by runcastle

v1.0.0

A single Claude Code agent reads your product and segment notes, then produces a defensible TAM/SAM/SOM estimate using both top-down and bottom-up methods — every assumption stated, a sensitivity table, and honest caveats — written to research/market-sizing.md.

Topology

Disclosures

Disclosures — declared side-effect surface

Everything below runs on your machine or inside the sandbox when you use this workflow. Mismatches between these declarations and the actual code block publishing.

Host hooks

Commands executed on YOUR host machine by Sandcastle lifecycle hooks.

None declared.

Sandbox hooks

Commands executed inside the sandbox container.

None declared.

Network access

None. The agent operates only on the local repository inside the sandbox.

Shell expansion

No shell-expansion blocks in prompt files.

Files

Diff vs the stock Sandcastle 0.12.0 template Dockerfile — green lines were added by the author, red lines were removed from stock.

+# Sandbox image for the Market Sizing Estimator workflow.
+# Node 22, git, and the Claude Code CLI, running as a non-root `agent` user.
FROM node:22-bookworm
# System dependencies.
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
jq \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Claude Code CLI (the agent runtime).
RUN npm install -g @anthropic-ai/claude-code
# Non-root agent user. `sandcastle docker build-image` aligns AGENT_UID/GID to
# the host user via --build-arg to avoid permission errors on bind mounts.
ARG AGENT_UID=1000
ARG AGENT_GID=1000
RUN groupadd --gid ${AGENT_GID} agent \
&& useradd --uid ${AGENT_UID} --gid ${AGENT_GID} --create-home --shell /bin/bash agent
USER agent
WORKDIR /workspace
Show full Dockerfile (highlighted)
# Sandbox image for the Market Sizing Estimator workflow.
# Node 22, git, and the Claude Code CLI, running as a non-root `agent` user.
FROM node:22-bookworm

# System dependencies.
RUN apt-get update && apt-get install -y --no-install-recommends \
      git \
      curl \
      jq \
      ca-certificates \
 && rm -rf /var/lib/apt/lists/*

# Claude Code CLI (the agent runtime).
RUN npm install -g @anthropic-ai/claude-code

# Non-root agent user. `sandcastle docker build-image` aligns AGENT_UID/GID to
# the host user via --build-arg to avoid permission errors on bind mounts.
ARG AGENT_UID=1000
ARG AGENT_GID=1000
RUN groupadd --gid ${AGENT_GID} agent \
 && useradd --uid ${AGENT_UID} --gid ${AGENT_GID} --create-home --shell /bin/bash agent

USER agent
WORKDIR /workspace

README

Market Sizing Estimator

Turn a page of product notes into a market size you can actually defend in a board meeting. One Claude Code agent, one Docker sandbox, no network, no hooks.

What it does

The agent reads a market.md file from your repository root — your product, target segment, geography, pricing, and whatever unit economics you already know — and writes a full TAM / SAM / SOM estimate to research/market-sizing.md. Crucially, it sizes the market two ways: top-down (narrowing a broad industry figure with explicit filters) and bottom-up (building up from reachable customers, adoption, and revenue per account), then reconciles the two into a working number.

The output is engineered to survive scrutiny: every assumption is listed with its value and rationale, a sensitivity table shows how the SOM swings under low/base/high inputs for the load-bearing variables, and named caveats spell out where the estimate is soft and what would sharpen it next.

How it works

main.ts calls run() once with maxIterations: 1 against an Opus agent — a single, one-shot analysis rather than a loop. Commits land directly on your current branch through the Docker bind mount, so there is no worktree or merge step. No shell expansion and no network access are used; the estimate is built entirely from the assumptions you provide and the ones the agent states.

Requirements

Add a market.md to your repo root (the richer, the better), set CLAUDE_CODE_OAUTH_TOKEN in .sandcastle/.env (run claude setup-token on your host), then build the image once with npx @ai-hero/sandcastle docker build-image and run it with npx tsx .sandcastle/main.ts. Read the result at research/market-sizing.md.