Skip to content
Shafin Zaman

Full products

Vertical copilot

A domain-specific copilot (pick legal, medical, sales, or support) that combines RAG over domain documents, tools, and guardrails into one focused, trustworthy assistant.

Advanced 2 to 3 weeksFree stack

Copy or download the full plan and paste it into your AI coding agent to build it.

Why build it

A general chatbot is a mile wide and an inch deep, which is useless in domains where being wrong has consequences. The valuable products are vertical copilots: assistants that know one field deeply, ground every answer in that field's real documents, take real actions through tools, and refuse to go outside their lane. Depth beats breadth, and a copilot that a lawyer, doctor, or support rep actually trusts is worth far more than a clever demo. Building one forces you to combine retrieval, tool use, and guardrails, which is the full modern AI-engineering skill set in a single project.

Who it's for: Developers who have built a RAG app and want to level up to a real, guardrailed, tool-using product. Pick a domain you understand or can get sample documents for.

What you'll build

Core (MVP)

  • Pick one domain (legal, medical, sales, or support) and commit to its language and workflows
  • RAG (retrieval-augmented generation) over a curated set of that domain's documents, with citations
  • Tools the copilot can call: look up a record, draft a document, file a ticket, schedule something
  • Guardrails that keep answers in scope and refuse or escalate out-of-domain or risky requests
  • A required-citation policy so every factual claim points to a source
  • A clear disclaimer and an escalate-to-a-human path for high-stakes questions
  • A chat UI showing sources, the tools it used, and when it declined and why
  • Conversation history so a session builds on earlier turns

Stretch

  • A confidence signal that hedges or escalates when retrieval is weak
  • Structured outputs for the domain (a filled form, a summary in a fixed schema)
  • An audit log of every question, source, tool call, and decision for review
  • Feedback capture (thumbs up/down with a reason) to improve retrieval over time
  • Role-based views so different users see different tools and documents

Step-by-step build

  1. 1

    Choose the domain and gather documents

    Commit to one vertical and collect a realistic set of its documents: policies, manuals, contracts, or a knowledge base. The quality of this corpus caps the quality of the copilot, so curate it rather than dumping everything. Note what questions real users in this domain actually ask.

  2. 2

    Build grounded retrieval

    Chunk and embed the documents, store them in pgvector, and retrieve the top passages per question. Force answers to come only from retrieved context and require citations, because in a serious domain an uncited claim is worthless.

  3. 3

    Write the domain system prompt

    Define the copilot's role, tone, scope, and hard limits in the domain's own language. State plainly what it will not do and when it must defer to a human. This prompt is the copilot's personality and its first line of defense.

  4. 4

    Add tools

    Give the copilot a few real tools using the AI SDK's tool calling: look up a record, draft a document, create a ticket, or schedule something. Define each tool's inputs strictly and validate them, so a wrong argument fails safely instead of doing damage.

  5. 5

    Build the guardrail layer

    Add checks around the model: an input classifier that catches out-of-scope or risky requests before they reach the LLM, and an output check that verifies citations exist and no forbidden content slipped through. Combine cheap rules with an LLM classifier for the fuzzy cases.

  6. 6

    Handle refusal and escalation

    When a request is out of scope, unsafe, or high-stakes, the copilot should decline clearly and offer the human escalation path rather than guess. Make declining a first-class, well-worded behavior, not an error. In serious domains, a good refusal is a feature.

  7. 7

    Design the trust-building UI

    Show sources under every answer, show which tools ran and with what result, and show when and why the copilot declined. Add the domain disclaimer and the escalate button. Transparency is what turns a black box into something a professional will trust.

  8. 8

    Evaluate against a question set

    Write 20 to 30 realistic questions with known good answers, plus deliberately out-of-scope and adversarial ones. Run them and check accuracy, citation correctness, and whether guardrails fired when they should. Iterate on retrieval and prompts until the set passes.

  9. 9

    Add memory and audit logging

    Keep conversation history in Redis so follow-ups work, and log every question, retrieved source, tool call, and decision. The audit trail is what makes the copilot defensible and reviewable, which matters enormously in regulated domains.

  10. 10

    Deploy and document

    Ship it live on Vercel with data in Postgres. In the README, put the live URL, a demo showing a grounded answer with citations, a tool call, and a clean refusal, and one paragraph on the domain and the guardrail design. Show that you built for trust, not just capability.

Done when

  • Every factual answer cites a real source from the domain corpus, and the citations are correct.
  • At least one tool works end to end, with invalid inputs failing safely rather than acting.
  • Out-of-scope and risky questions are declined clearly and offered the human escalation path.
  • Your 20-plus question evaluation set passes on accuracy, citations, and guardrail behavior.
  • The live URL works for someone else, and the UI makes sources, tools, and refusals visible.

Ship it

Deploy the Next.js copilot on Vercel with document chunks and vectors in Postgres on Neon or Supabase and conversation state in Redis, all free tiers. In the README, lead with the live URL and a short demo that shows a grounded, cited answer, a real tool call, and a clean refusal, then a paragraph on the domain and the guardrail design.

What it proves: You can combine RAG, tool use, and guardrails into a focused, trustworthy product for a real domain, which is the complete modern AI-engineering skill set in one build.

Hand it to your AI agent

Paste this into Cursor, Claude, or ChatGPT and build it step by step.

You are my senior AI engineer pair. Help me build a "Vertical copilot" step by step: a domain-specific assistant (I will pick legal, medical, sales, or support) that combines retrieval, tools, and guardrails. Stack: Next.js (UI + API routes), the Vercel AI SDK for streaming and tool calling, Groq (free LLM API), Postgres + pgvector (Neon or Supabase free tier) with all-MiniLM-L6-v2 embeddings, a guardrail layer of rules plus an LLM classifier, and Redis for conversation state.

Requirements:
1. RAG (retrieval-augmented generation) over a curated domain corpus, with required citations on every factual claim.
2. A domain system prompt that defines scope, tone, and hard limits.
3. A few real tools (look up a record, draft a document, file a ticket) with strictly validated inputs.
4. Guardrails: an input classifier that catches out-of-scope or risky requests and an output check that verifies citations.
5. Clear refusal plus a human escalation path for high-stakes questions.
6. A UI that shows sources, tool calls, and refusals, plus conversation memory and an audit log.

Work in this order: gather documents, then retrieval, then the system prompt, then tools, then guardrails, then refusal/escalation, then the UI, then an evaluation set. STOP after each step so I can test. Do not write the whole app at once.

More in Full products

Building this? I post a new AI project plan on LinkedIn most weeks. Follow along and share what you ship.