Market Sizing Estimator
MIT↓ 0 downloadsA 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
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=1000ARG AGENT_GID=1000RUN groupadd --gid ${AGENT_GID} agent \&& useradd --uid ${AGENT_UID} --gid ${AGENT_GID} --create-home --shell /bin/bash agentUSER agentWORKDIR /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
# Auth for the Claude Code analyst agent.
# Run `claude setup-token` on your host to generate a token, then paste it here
# in your local .sandcastle/.env (never commit the real .env).
CLAUDE_CODE_OAUTH_TOKEN=
import { run, claudeCode } from "@ai-hero/sandcastle";
import { docker } from "@ai-hero/sandcastle/sandboxes/docker";
// A single-pass market sizing estimator. One Opus analyst reads the repo's
// market.md notes and writes a full TAM/SAM/SOM estimate. maxIterations is 1
// because this is a one-shot analysis, not a loop — the agent produces the
// artifact and commits it once. Default `head` branch strategy on docker means
// the commit lands directly on the current branch.
const result = await run({
name: "market-sizing-estimator",
agent: claudeCode("claude-opus-4-8", { effort: "high" }),
sandbox: docker(),
promptFile: ".sandcastle/prompt.md",
maxIterations: 1,
});
console.log(`Market sizing written in ${result.commits.length} commit(s) on ${result.branch}.`);
Market sizing estimate
You are a market-sizing analyst. Produce a rigorous, defensible market size estimate for the product described in this repository.
Input
Read market.md in the repository root. It describes the product, the customer
segment, the geography, pricing, and any known unit economics or reference
figures. If market.md is missing or thin, state clearly what is missing and
make your best-effort estimate from the information available — never invent
data silently.
Your task
Write research/market-sizing.md with the following sections:
- Summary — headline TAM, SAM, and SOM figures with a one-line definition of each in the context of this product.
- Top-down estimate — start from a broad industry/population figure and
narrow it with explicit filters (geography, segment, willingness to pay).
Show each step as
figure x rate = result. - Bottom-up estimate — build up from unit economics: number of reachable customers x adoption rate x average revenue per account. Show the arithmetic.
- Reconciliation — compare the two methods. Where they diverge, explain why and pick a defensible working number.
- Assumptions — a numbered list of every assumption you made, each with the value used and a one-line rationale. This section is the point of the whole document — be exhaustive and explicit.
- Sensitivity table — a compact markdown table showing how SOM moves under low / base / high values for your 2–3 most load-bearing assumptions.
- Caveats — named risks to the estimate (data quality, segment definition, timing, competitive response) and what would sharpen the numbers next.
Prefer transparent, checkable arithmetic over precision theatre. Round sensibly
and label units and time periods (annual vs. one-time). Commit the file with a
message like research: market sizing estimate.
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.