
Weekend Productivity Challenge: SchemaScribe — Your dbt Documentation Auto-Generator and Explainer
SchemaScribe turns any dbt model's SQL into a ready-to-commit schema.yml — column descriptions and sensible tests included — or a plain-English review of the model. Built in a weekend on AWS Amplify, API Gateway, Lambda, and Amazon Bedrock (Nova Lite).
Weekend Productivity Challenge: SchemaScribe — Your dbt Documentation Auto-Generator and Explainer
Vision: the chore every analytics engineer skips
I work as a data engineer and spend part of my week mentoring data-engineering interns. Between my own medallion-architecture dbt project (bronze → silver → gold on Airflow) and reviewing student pipelines, I see the same gap everywhere: models get written,
schema.yml files don't. Documentation and tests are the vegetables of analytics engineering — everyone agrees they matter, and everyone writes them last, badly, or never.SchemaScribe attacks that chore directly. You paste a dbt model's SQL into a web page and it returns one of two things:
- Document mode — a complete, ready-to-commit
schema.ymlblock: a model description that states the grain, a description for every output column, and dbt tests the SQL can actually justify (unique+not_nullon the key,accepted_valueswhere a CASE expression pins the domain,relationshipsonly when the target model is genuinelyref()'d in the SQL).
- Explain mode — a plain-English review: what the model does, its inputs, a CTE-by-CTE walkthrough, and a "things to watch" section that flags fan-out risks, null handling, and filters that silently drop rows.
I ran it on the silver-layer orders model from my own pipeline — a ~70-line model with two dimension joins, payment flags, and revenue-recognition logic — and it produced a schema block I committed with only minor edits. That's the productivity win: the boring 80% is generated, and I spend my time reviewing instead of typing.
How I built it
The architecture is deliberately boring — one static HTML file, one Lambda, one model call:
Browser (Amplify Hosting) → Amazon API Gateway (HTTP API, CORS at the gateway) → AWS Lambda (Python 3.12, single file) → Amazon Bedrock — Nova LiteThe Lambda uses Bedrock's
converse API, so the model is a one-line environment variable swap. The frontend is a single self-contained index.html — no framework, no build step, deployed to Amplify as a zip.The real engineering was in three places:
1. Prompt iteration against real dbt syntax. The first outputs looked plausible and were wrong in ways only a dbt user would catch:
accepted_values with a value: key instead of values: , tests drifting up to the model level with a column_name: argument, and relationships tests pointing at models that never appeared in the SQL. Each defect became an explicit rule with a worked example in the system prompt, and I validated the output by actually parsing it as YAML and asserting the structure. Lesson: with LLMs, "looks like YAML" and "is correct dbt" are very different bars.2. The public Lambda function URL that refused to be public. My original design used a Lambda function URL (auth
NONE ) instead of API Gateway. On my account, every request returned 403 Forbidden — with a provably correct resource policy ( lambda:InvokeFunctionUrl , principal * , the exact policy the console generates). Direct aws lambda invoke worked fine, so the function and role were healthy; the block was at the URL layer, apparently a restriction on newer/free-plan accounts. The fix was to put an API Gateway HTTP API in front of the Lambda — it speaks the same payload format 2.0, so the handler needed zero changes.3. The CORS preflight trap in API Gateway quick-create. Creating the HTTP API with
--target (quick create) silently adds a $default route that is ApiGatewayManaged — you cannot delete it — and it catches OPTIONS requests, forwarding browser CORS preflights to the Lambda, which correctly answers 400. Result: curl works, browsers don't. Rebuilding the API with an explicit integration, a single POST / route, and a $default stage let API Gateway answer preflights itself with a clean 204.AWS services used
- Amazon Bedrock (Nova Lite) — the generation engine. At ~$0.06 per million input tokens, a full document run costs fractions of a cent.
- AWS Lambda — Python 3.12 on arm64, 256 MB, 30 s timeout (the 3 s default kills Bedrock calls mid-generation — set this first).
- Amazon API Gateway (HTTP API) — public HTTPS endpoint, CORS and preflight handled at the gateway.
- AWS Amplify Hosting — static frontend via manual zip deploy:
create-deploymentreturns a pre-signed upload URL,start-deploymentpublishes. No Git connection needed.
- IAM — a scoped execution role: CloudWatch logs plus
bedrock:InvokeModel, nothing else.
What I learned
- Free Plan accounts gate Bedrock at the quota layer, not the access layer. "Model access: granted" and an applied quota of 0 tokens per day can coexist — every call throws
ThrottlingException: Too many tokens per dayuntil the account is upgraded to a paid plan. Surfacing that as a friendly HTTP 429 in the Lambda meant the app never looked broken while I sorted it out.
- Test the browser path, not just curl. Every one of my networking bugs (function URL 403, preflight hijacking) was invisible to curl and fatal to a real browser. Driving the deployed site headlessly with Playwright caught both.
- Constrain LLM output with rules + examples + validation. Generic "output YAML" prompts produce dbt-flavored fiction; exact syntax examples plus a parse-and-assert step produce committable files.
Try it
- Source code: https://github.com/tripleaceme/schemascribe
Paste in your gnarliest model and see what it says about your null handling.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article