HomeDocsGeneral Agent Prompt

General Agent Prompt

Paste everything between the markers into Claude Code (or another coding agent) to set up a working AF-backed agent. For a B2B2C build (your product has its own end users), use the dedicated B2B2C Coding-Agent Prompt instead.

Open your codebase in the coding agent and paste everything between the ===== PROMPT START ===== and ===== PROMPT END ===== markers below as a single message.

===== PROMPT START =====

You are integrating Agentic Fabriq (AF) into this codebase. The user wants a
working AF-backed agent that talks to AF's MCP server and calls tools on their
behalf. Your job is to set this up correctly the first time.

Source of truth

The authoritative reference is the Build an Agent with AF guide on the public
docs site: https://www.agenticfabriq.com/docs (also see MCP Client Setup
Guide and Token Broker Guide). The full docs are also published as plain text
for agents at https://www.agenticfabriq.com/llms-full.txt — fetch that to read
any guide reliably. Conform to it exactly:

Use from af_sdk import MCPClient — do not invent alternate import paths.
Use the four auth methods exactly as documented: method="cli" | "keycloak" | "idp" | "token".
Use the exact env-var names from the guide: AF_APP_ID, AF_APP_SECRET,
AF_GATEWAY_URL, AF_MCP_URL, AF_KEYCLOAK_URL, KC_REALM,
KC_ACCESS_TOKEN, KC_REFRESH_TOKEN, OKTA_ISSUER, OKTA_CLIENT_ID,
OKTA_CLIENT_SECRET, OKTA_REDIRECT_URI, OKTA_ID_TOKEN, AF_USER_TOKEN,
EXTERNAL_USER_ID, ORG_URL, plus the loop/backoff vars (LOG_LEVEL,
TICK_SECONDS, TOOL_RETRY_ATTEMPTS, MAX_TOOL_BACKOFF_SECONDS,
INITIAL_BACKOFF_SECONDS, MAX_BACKOFF_SECONDS, AUTH_BACKOFF_SECONDS,
RECONNECT_BACKOFF_SECONDS).
Do not hardcode gateway, Keycloak, MCP, or Okta URLs in code. Always read from
env.
Do not invent tool names. Confirm them against client.list_tools() output or
ask the user.
Before you do anything else, fetch https://www.agenticfabriq.com/llms-full.txt
(the full docs as plain text) and read the Build an Agent with AF section
end-to-end. The human docs site at /docs is a single-page app and may return an
empty shell to a plain fetch, so prefer llms-full.txt. If you still cannot read
it, ask the user to paste the guide text rather than guessing. Do not proceed
without the guide.

Hard rules

Never commit secrets. Don't write AF_APP_SECRET, OKTA_CLIENT_SECRET, or any
token value into a tracked file. If you create a .env for local use, also add
.env to .gitignore if it isn't already.
Never bake secrets into Docker images, CI configs, or .env.example.
.env.example may contain key names only, with empty or placeholder values.
Don't modify the user's auth provider configuration. You can suggest
Keycloak/Okta client settings (see the guide's tables) but the user must make
those changes themselves.
Don't run pip install or any other side-effecting command without asking
first. Propose, wait for approval, then run.
Don't generate fake values for AF_APP_ID, AF_APP_SECRET, redirect URIs, or
any other secret. Use placeholders the user will fill in, or stop and ask.
If something in the guide conflicts with what's already in the codebase,
surface the conflict to the user. Don't silently overwrite.

Step 1 — Discover the user's setup

Ask the user the following questions in one message, formatted as a numbered
list. Wait for their answers before continuing. If they answer some but not all,
ask the rest in a follow-up.

Auth method — which one fits your situation?
a) cli — you'll run this from your own laptop after afctl auth login
b) keycloak — humans sign in through your frontend; backend exchanges
Keycloak code -> tokens
c) idp — humans sign in via Okta (or another external IdP) SSO
d) token — B2B2C: your backend mints per-end-user AF tokens, no AF
accounts for end users (if so, use the B2B2C prompt instead — it covers
the external-user onboarding this prompt does not)
Sync or async — does the codebase already use asyncio, or do you need the
sync wrappers?
Shape of the agent — pick the closest:
a) One-shot script (list tools, call one tool, exit)
b) Long-running loop (tick on a schedule, react to events)
c) Request-driven service (FastAPI / Flask handler invokes the client per
request)
d) Other (describe)
Runtime target — where will this run in production?
a) Local laptop only (for now) b) Generic Docker container
c) Google Cloud Run d) Kubernetes / GKE e) AWS Lambda / Cloud Functions
f) Other (describe)
Secret loading — how should AF_APP_ID / AF_APP_SECRET reach the process
in production?
a) Plain env vars b) GCP Secret Manager c) AWS Secrets Manager
d) HashiCorp Vault e) Kubernetes Secret mounted as env vars
f) Don't worry about production yet — local .env is fine
Tools — which AF tool(s) does the agent need to call first? (e.g.
google_gmail_list_messages, slack_post_message). If unsure, say "list them
and I'll pick."
Existing code — where in this repo should the agent live? Give a path
(e.g. services/agent/) or say "you choose."
If the user answers c or d for question 1 (keycloak or idp), follow up with:

What's the frontend stack? (React/Vite, Next.js, plain HTML, none — backend
only)
What's the backend stack? (FastAPI, Flask, Django, Express, other)
What's the redirect_uri for each environment (dev / staging / prod)?
Have the redirect URIs been registered with AF/Okta yet?

Step 2 — Confirm the plan

Once you have answers, respond with:

Here's what I'll do:

Files I'll add: <list with one-line purpose each>
Files I'll modify: <list with what changes>
Dependencies I'll add: <list, with versions if relevant>
Env vars the user must set (in .env.example, empty): <list>
External setup the user needs to do (I will not touch): <Keycloak/Okta client settings, redirect URI registrations, secret manager entries, etc.>

I'll follow the guide's <cli / keycloak / idp / token> example as the
structural template.

OK to proceed?
Do not write any files until the user says "yes" or equivalent. If they ask for
changes, revise the plan and re-confirm.

Step 3 — Implement

When the user approves:

Stick to the guide's patterns. Copy the structure of the appropriate example
(the cli example, the Keycloak FastAPI callback example, the Okta callback
example, the B2B2C example, the long-running-loop example, the sync example, or
the full reference agent) and adapt names/imports to fit the user's project.
Don't invent new shapes when an example fits.
Read env vars at use sites, not in module init. Module-level
os.environ["..."] reads make imports fail. Wrap reads in functions or use
os.environ.get(..., default) where appropriate.
Add a .env.example with every env var the code reads, value blank, and a
one-line comment per variable explaining where it comes from. If .env isn't
in .gitignore, add it.
Add a minimal README section or RUN.md in the integration directory: install
command, env-var checklist, how to run, how to verify (e.g. python agent.py
prints tool count).
Wire error handling per the guide. Catch AuthenticationError,
MCPConnectionError, and MCPError at the right layers. For loops: outer
try/except for AuthenticationError / MCPConnectionError, inner retry for
MCPError.
Match the user's existing style. If the project uses Poetry, update
pyproject.toml. If it uses pip + requirements.txt, update that. Don't switch
tooling.
If the runtime target is containerized, add the Dockerfile and (for K8s)
deployment.yaml from the guide's "Deploying to production" section. Replace
placeholder values with sensible defaults, but leave secret-bearing fields
blank.

Step 4 — Show how to run and verify

After implementation, respond with:

Done. To run this:

Set env vars: <copy-paste shell block; secrets shown as 'fill_me_in'>
<auth-specific steps — e.g. afctl auth login, or "sign in via /auth/login then /run-agent">
Run: <exact command>
You should see: <expected output, e.g. "N tools available">
If you see <common failure>, check <thing>.

Things I did NOT do (you need to): <Keycloak client redirect URI registration, secret manager entry creation, etc.>

Step 5 — Stay honest

If you couldn't read the guide, say so. Don't guess at API shapes.
If a question isn't covered by the guide, say "the guide doesn't cover that;
here's what I'd do and why" rather than confabulating.
If you wrote something the guide doesn't explicitly endorse (a framework
choice, a directory layout), flag it as your own decision so the user can
override.
If a step fails when you run it, report the actual error verbatim. Don't claim
success without evidence.

Defaults if the user says "you decide"

Async over sync.
method="cli" for local dev, method="keycloak" for interactive web apps,
method="token" for B2B2C, method="idp" only if the user has Okta.
Long-running loop with exponential backoff (the full reference-agent shape) for
anything that isn't obviously a one-shot script.
Generic Docker container target if production matters but no specific platform
is named.
GCP Secret Manager for secrets if the project shows signs of GCP (look for
gcloud, cloudbuild.yaml, app.yaml); else Kubernetes Secret if there's a
k8s/ or helm/ directory; else "local .env, secrets-loading TBD."
Place agent code under services/agent/ (or agent/ if the repo is flat).
===== PROMPT END =====

Need help?

Our team is here to help you get started.