Inferensys

Prompt

Multi-Factor Authentication Flow Documentation Prompt

A practical prompt playbook for using Multi-Factor Authentication Flow Documentation Prompt in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the precise job-to-be-done, ideal user profile, required inputs, and explicit boundaries for the MFA flow documentation prompt.

This prompt is designed for security engineers and API product managers who have already finalized the design of a multi-factor authentication (MFA) system and now need to convert that specification into unambiguous, structured documentation. The job-to-be-done is producing developer-facing or auditor-ready reference material that covers every state in the MFA lifecycle: enrollment of TOTP, WebAuthn, and backup codes; challenge flows for each factor; fallback chain logic when a primary factor is unavailable; account recovery procedures; and a complete catalog of error states with actionable remediation steps. If your MFA flow design is still in flux, this prompt is premature—it assumes the architecture decisions are locked and the task is documentation, not design exploration.

The ideal user brings a defined MFA specification to the prompt, which may exist as internal design docs, API endpoint definitions, sequence diagrams, or a working implementation. Required context includes the list of supported factors, the enrollment and challenge API contracts, session and token lifecycle rules, rate limiting and lockout policies, and the recovery flow for lost factors. The prompt uses this context to generate documentation that leaves no gap in the user journey: every redirect, every error response, every fallback decision point is described. The output is structured for downstream consumption by API consumers, integration partners, and compliance auditors who need to verify that the documented flow matches the implemented security properties.

Do not use this prompt for general authentication overviews, OAuth grant type documentation, session management guides, or social login integration docs. It is specifically scoped to MFA enrollment and challenge flows. It also should not be used to generate marketing copy, user-facing help center articles, or UI microcopy—the output is technical reference documentation. If your documentation needs include auth terminology standardization, completeness audits, or sequence diagram generation, those are separate prompt playbooks. Before running this prompt, ensure you have the MFA flow design finalized and the necessary API contracts, error catalogs, and recovery procedures defined. The prompt will produce documentation that is only as complete as the specification you provide.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to decide if the MFA Flow Documentation Prompt is the right tool for your current task.

01

Good Fit: Structured Flow Documentation

Use when: you need to generate step-by-step user journeys for MFA enrollment or challenge flows, including TOTP, WebAuthn, and backup code paths. Guardrail: Provide a clear [FLOW_TYPE] and [AUTH_METHODS] list to constrain the output to specific paths.

02

Good Fit: Error State and Recovery Mapping

Use when: documenting failure modes like expired tokens, locked accounts, or lost devices. Guardrail: Include an [ERROR_CATALOG] input with known error codes to ensure the prompt covers every documented failure state and its recovery path.

03

Bad Fit: Security Policy Authoring

Avoid when: you need to define the security policy itself (e.g., deciding which MFA factors to require). This prompt documents flows, not policy decisions. Guardrail: Use a separate policy design prompt first, then feed the approved policy as [POLICY_CONTEXT] into this documentation prompt.

04

Bad Fit: Real-Time Incident Response

Avoid when: you need live troubleshooting steps during an active MFA outage. This prompt produces static documentation, not diagnostic runbooks. Guardrail: Route incident response to an operational runbook prompt and use this output only as reference material.

05

Required Input: Complete Fallback Chain

Risk: The prompt may omit backup or recovery paths if the input does not explicitly define them. Guardrail: Always provide a [FALLBACK_CHAIN] input that enumerates primary, secondary, and tertiary methods, plus account recovery procedures.

06

Operational Risk: Stale Documentation Drift

Risk: Generated docs can become outdated as MFA flows change, creating a security risk if developers rely on stale instructions. Guardrail: Version-lock the prompt output to an [API_VERSION] or [DOC_REVISION] field and schedule a recurring review cycle triggered by auth system changes.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A ready-to-use prompt for generating comprehensive MFA flow documentation, with placeholders for your specific authentication details.

This prompt template is designed to generate thorough, security-focused documentation for multi-factor authentication flows. It guides the model to produce step-by-step user journeys covering enrollment, challenge, and recovery paths while maintaining strict attention to error states, fallback chains, and security considerations. Replace each square-bracket placeholder with your specific MFA implementation details before use.

code
You are a senior security documentation engineer. Generate comprehensive MFA flow documentation based on the following specifications.

## MFA Configuration
- Primary Method: [PRIMARY_MFA_METHOD: TOTP / WebAuthn / SMS / Push Notification]
- Secondary Methods: [SECONDARY_MFA_METHODS: comma-separated list]
- Recovery Options: [RECOVERY_OPTIONS: backup_codes / recovery_email / admin_reset]
- Token Lifetime: [TOKEN_LIFETIME: e.g., 30 seconds for TOTP, 5 minutes for SMS]
- Max Attempts: [MAX_ATTEMPTS: number]
- Lockout Policy: [LOCKOUT_POLICY: e.g., 15-minute cooldown after 5 failures]

## User Journey Context
- Application Type: [APP_TYPE: web / mobile / CLI / API]
- User Authentication State: [AUTH_STATE: initial_enrollment / re-authentication / step-up / device_change]
- Platform Constraints: [PLATFORM_CONSTRAINTS: e.g., no biometrics, FIDO2 required]

## Documentation Requirements
Generate documentation covering these sections in order:

### 1. Enrollment Flow
- Prerequisites and setup steps
- Step-by-step enrollment with user actions and system responses
- QR code or registration challenge details for [PRIMARY_MFA_METHOD]
- Secondary method enrollment sequence
- Recovery option setup (backup code generation and storage guidance)
- Enrollment completion confirmation and next steps

### 2. Authentication Challenge Flow
- Trigger conditions for MFA challenge
- Primary method challenge sequence with timeout handling
- Fallback chain: what happens when primary method fails or is unavailable
- Secondary method fallback with clear user messaging
- Error states: invalid code, expired token, network failure, device lost
- Lockout and rate limiting behavior with user-facing messages

### 3. Recovery Flow
- Recovery initiation conditions
- Step-by-step recovery using [RECOVERY_OPTIONS]
- Identity verification steps before recovery
- New device enrollment after recovery
- Session handling during recovery

### 4. Error Reference
- Complete error code table with HTTP status codes
- User-facing error messages for each state
- Troubleshooting guidance for common issues
- Support escalation criteria

### 5. Security Considerations
- Token transmission security (HTTPS requirements)
- Storage recommendations for secrets and recovery codes
- Session binding after successful MFA
- Brute force protection details
- Phishing resistance notes for [PRIMARY_MFA_METHOD]

## Output Format
- Use clear heading hierarchy (H2 for major sections, H3 for subsections)
- Include code blocks for API request/response examples
- Use callouts (⚠️ WARNING, ℹ️ NOTE, 🔒 SECURITY) for critical information
- Provide Mermaid sequence diagrams in text for enrollment and challenge flows
- Mark all placeholder values with [BRACKETED_PLACEHOLDERS] that need replacement

## Constraints
- Never include hardcoded secrets, keys, or real credentials in examples
- Flag any security-sensitive configuration choices with rationale
- Document all failure modes, not just happy paths
- Ensure recovery path documentation is as detailed as primary flow
- Include rate limit headers in all API response examples
- Specify exact cookie attributes (HttpOnly, Secure, SameSite) where applicable

After pasting this template, replace each bracketed placeholder with your actual MFA implementation details. For production use, add a validation step that checks the generated documentation against a checklist: all error states documented, recovery paths complete, no hardcoded secrets, and consistent terminology throughout. For high-security environments, route the output through a human security review before publication.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the MFA flow documentation prompt. Each variable must be supplied with enough detail to avoid ambiguity in the generated output. Validate inputs before passing them to the model.

PlaceholderPurposeExampleValidation Notes

[MFA_METHODS]

List of MFA methods to document in the flow

["TOTP", "WebAuthn", "Backup Codes"]

Must be a non-empty JSON array of strings. Allowed values: TOTP, WebAuthn, Backup Codes, SMS, Email OTP, Push Notification, Security Key. Reject if array contains unknown methods.

[FLOW_TYPE]

Specifies whether to document enrollment, challenge, or recovery flow

"challenge"

Must be one of: enrollment, challenge, recovery. Reject if value is not in the allowed set. Controls which step sequence the prompt generates.

[USER_JOURNEY_STEPS]

Ordered list of user-facing steps in the flow

["User enters credentials", "System detects MFA requirement", "User selects TOTP method", "User enters 6-digit code", "System validates and grants access"]

Must be a JSON array of strings with at least 3 steps. Each step should describe a discrete user action or system response. Reject if steps are missing or describe implementation details instead of user actions.

[ERROR_STATES]

Known error conditions that must be documented for this flow

["Invalid TOTP code", "WebAuthn device not recognized", "Backup code already used", "Rate limit exceeded", "Session timeout during challenge"]

Must be a JSON array of strings. At least 2 error states required. Each error should be specific to the MFA methods listed. Reject if errors are generic (e.g., 'Error occurred') without MFA context.

[FALLBACK_CHAIN]

Ordered fallback methods when primary MFA fails or is unavailable

["TOTP", "Backup Codes", "Account Recovery with identity verification"]

Must be a JSON array of strings ordered from first to last fallback. Values must be a subset of [MFA_METHODS] plus optional 'Account Recovery'. Reject if fallback chain is empty or references methods not in [MFA_METHODS].

[TOKEN_LIFETIME_SECONDS]

Lifetime of the MFA challenge token in seconds

300

Must be a positive integer. Typical range: 60-900. Reject if value is 0, negative, or non-numeric. Used to generate timeout and expiration documentation.

[ACCOUNT_RECOVERY_PATH]

Description of the account recovery process when all MFA methods fail

"User must contact support with government ID and answer security questions. Recovery takes 24-48 hours."

Must be a non-empty string. Should describe the process, required evidence, and expected timeline. Reject if string is empty or contains only placeholder text like 'TBD'.

[COMPLIANCE_REQUIREMENTS]

Regulatory or policy requirements that constrain the MFA flow

"SOC 2 Type II requires MFA for all admin access. PCI DSS 4.0 requires MFA for CDE access."

Optional. If provided, must be a string. If null, prompt skips compliance section. Validate that any cited standards are real and relevant to authentication flows.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the MFA flow documentation prompt into a security documentation generation pipeline with validation, retries, and human review gates.

This prompt is designed to be called programmatically as part of a security documentation generation workflow, not as a one-off chat interaction. The implementation harness wraps the prompt in a pipeline that validates structural completeness, enforces MFA-specific safety checks, and routes outputs to human review before publication. Treat this prompt as a function with typed inputs and outputs: it accepts a structured context object (flow type, enrollment method, recovery paths, error catalog) and returns a documentation artifact that must pass automated evals before reaching a technical reviewer.

Pipeline integration steps: 1) Assemble the context object from your auth system's configuration, API specs, and existing documentation. 2) Inject the context into the prompt template's [CONTEXT] placeholder along with the [FLOW_TYPE], [ENROLLMENT_METHODS], [RECOVERY_PATHS], and [ERROR_CATALOG] variables. 3) Call the model with response_format set to a JSON schema that enforces the required sections (Overview, Enrollment Flow, Challenge Flow, Recovery Flow, Error Reference, Security Considerations). 4) Run automated evals: check that every error code in the catalog appears in the output, verify that all enrollment methods have corresponding challenge descriptions, confirm backup code and recovery paths are documented, and flag any missing fallback chain documentation. 5) If evals fail, retry with the eval failure messages injected as additional [CONSTRAINTS] context. 6) Route passing outputs to a human security reviewer with a diff against the previous documentation version.

Model choice and tool use: Use a model with strong structured output support (GPT-4o, Claude 3.5 Sonnet, or equivalent) and enable strict JSON mode. This prompt does not require RAG or external tool calls during generation—the context object should contain all necessary information. However, consider a pre-generation retrieval step that pulls the current auth documentation, API error code definitions, and relevant RFC sections (RFC 6238 for TOTP, RFC 4226 for HOTP, WebAuthn spec) to populate the context object accurately. Retry strategy: Implement up to 3 retries with escalating temperature (0.0 → 0.2 → 0.4) on eval failure. If all retries fail, log the failure, capture the partial output, and create a manual documentation ticket. Logging and audit: Log every generation attempt with the prompt version, model, context hash, eval results, and reviewer decision. This is critical for security documentation where change traceability matters for compliance reviews. What to avoid: Do not ship MFA documentation without human review—missing or incorrect fallback chain documentation can lock users out of accounts. Do not use this prompt for real-time documentation generation in user-facing products; it is a drafting tool, not a live reference.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the MFA flow documentation generated by the prompt. Use this contract to validate the model output before publishing.

Field or ElementType or FormatRequiredValidation Rule

MFA Flow Title

string

Must match the [FLOW_TYPE] input exactly (e.g., 'TOTP Enrollment', 'WebAuthn Challenge').

Prerequisites Section

markdown list

Must enumerate all required states before the flow begins (e.g., 'Valid session token', 'Unenrolled TOTP device'). Parse check: minimum 1 item.

Step-by-Step User Journey

ordered markdown list

Each step must contain an action, a system response, and a state transition. Count must match the number of distinct interactions in the source spec.

TOTP Path Instructions

markdown block

Required when [FLOW_TYPE] includes TOTP. Must include QR code provisioning step, secret storage warning, and 6-digit code entry. Null allowed for WebAuthn-only flows.

WebAuthn Path Instructions

markdown block

Required when [FLOW_TYPE] includes WebAuthn. Must reference platform authenticator and security key options. Null allowed for TOTP-only flows.

Backup Code Path Instructions

markdown block

Must document backup code generation, single-use semantics, and secure storage guidance. Parse check: must contain the phrase 'one-time use' or 'single use'.

Error State Table

markdown table

Must include rows for: invalid code, expired challenge, rate limit exceeded, and device not recognized. Schema check: columns must be 'Error', 'HTTP Status', 'User Message', 'Recovery Action'.

Account Recovery Section

markdown block

Must describe the fallback chain when all MFA methods are unavailable. Must reference admin reset or identity verification. Approval required: human review for security accuracy.

PRACTICAL GUARDRAILS

Common Failure Modes

MFA documentation prompts fail in predictable ways. These cards cover the most common breaks and how to prevent them before they reach a developer portal or security audit.

01

Missing Fallback Chain Documentation

What to watch: The prompt generates a clean TOTP happy path but omits backup codes, WebAuthn fallback, or account recovery. Users locked out of their primary method have no documented path forward. Guardrail: Add a required output section for 'Fallback and Recovery Paths' in the prompt schema. Validate that every primary method has at least one documented alternative before publication.

02

Error State Omission

What to watch: The generated documentation describes successful enrollment and challenge flows but skips error responses entirely. Developers integrating the flow hit undocumented 400s and 429s with no guidance. Guardrail: Require an explicit error reference table in the output schema. Cross-check against the API spec's error codes and flag any undocumented error response during review.

03

Token Lifetime Ambiguity

What to watch: The prompt produces vague language like 'the code expires after a short period' instead of exact TOTP step windows, challenge TTLs, or backup code single-use semantics. Integrators build incorrect timeout logic. Guardrail: Include a constraint requiring exact numeric values with units for every time-bound element. Validate output with a regex check for duration patterns before accepting.

04

Cross-Channel Inconsistency

What to watch: SMS, email, and push notification MFA paths are documented with different structures, terminology, or detail levels. The same concept is called a 'verification code' in one section and a 'one-time password' in another. Guardrail: Provide a terminology glossary in the system prompt. Run a post-generation consistency check that flags divergent terms for the same concept across sections.

05

Enrollment vs. Challenge Confusion

What to watch: The prompt conflates the enrollment flow (setting up MFA for the first time) with the challenge flow (verifying identity during login). The resulting documentation mixes setup steps with authentication steps, confusing both users and developers. Guardrail: Structure the prompt with separate, clearly labeled sections for enrollment and challenge. Validate that no enrollment-only steps appear in the challenge section and vice versa.

06

Security Property Hand-Waving

What to watch: The prompt generates documentation that says 'this is secure' without explaining why. Missing details on phishing resistance for WebAuthn, TOTP seed storage requirements, or backup code hashing. Auditors reject the documentation as insufficient. Guardrail: Add a required 'Security Properties' subsection for each MFA method. Require concrete statements about threat models addressed and residual risks, not generic assurances.

IMPLEMENTATION TABLE

Evaluation Rubric

Score each criterion on a pass/fail basis. All criteria must pass before the MFA flow documentation prompt is considered production-ready.

CriterionPass StandardFailure SignalTest Method

Flow Completeness

All MFA paths (TOTP, WebAuthn, backup codes) are documented with distinct steps.

Missing path for at least one factor type; fallback chain is incomplete.

Manual review against [AUTH_METHODS] list; automated check for required section headers.

Error State Coverage

Every documented step includes error responses for invalid input, expired tokens, and rate limiting.

Happy-path only documentation; error codes or user-facing messages are absent.

Parse output for error code references; verify each step block contains an error subsection.

Fallback Chain Integrity

The documentation explicitly defines the order of fallback methods and conditions for each transition.

Fallback logic is implied or circular; no clear primary-to-secondary factor progression.

Trace the documented fallback graph; confirm no dead ends or loops exist.

Token and Code Lifecycle

TOTP code validity windows, WebAuthn challenge expiry, and backup code single-use semantics are specified.

Expiration durations, replay protection, or one-time use rules are missing.

Schema check for expires_in, single_use, or validity_window fields in output.

Recovery Path Documentation

Account recovery flow is documented with identity verification steps and fallback to support escalation.

Recovery section is absent or assumes the user has access to a lost factor.

Keyword search for 'recovery', 'lost access', 'support escalation'; verify non-empty content.

Security Consideration Warnings

Documentation includes warnings about phishing resistance, WebAuthn attestation, and backup code storage.

No security advisory language; missing guidance on factor strength or threat model.

Check for a dedicated security considerations section with at least three distinct warnings.

Placeholder and Variable Hygiene

All placeholders use square-bracket syntax and are defined in an input variables table.

Unresolved template tokens, hardcoded example values presented as real, or undefined variables.

Regex scan for {{, <<, or bare tokens; cross-reference against declared [VARIABLES] list.

Output Schema Compliance

Generated documentation conforms to the declared [OUTPUT_SCHEMA] with all required fields present.

Missing required sections; extra fields not in schema; malformed JSON structure.

Automated schema validation against [OUTPUT_SCHEMA] definition; reject on validation errors.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet) and minimal validation. Focus on generating the happy-path enrollment and challenge flows first. Replace [AUTH_SYSTEM_SPEC] with a brief text description of your MFA methods. Skip the eval harness initially.

Prompt modification

  • Remove the [OUTPUT_SCHEMA] constraint and ask for markdown with headings.
  • Replace [CONSTRAINTS] with: "Cover TOTP and backup codes only. Skip WebAuthn for now."
  • Add: "If you are uncertain about a flow step, mark it with [NEEDS REVIEW] and continue."

Watch for

  • Missing error states and recovery paths in the generated flow
  • Overly generic descriptions that don't match your actual implementation
  • No distinction between enrollment and challenge phases
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.