Feature Flow Auditor
Purpose
Produce a complete, evidence-based explanation of how a feature works, then challenge it with an independent audit. Prefer read-only analysis unless the user explicitly asks to modify code.
Default Output
Deliver, in this order:
- Executive summary.
- Scope and assumptions.
- File/component map with absolute paths.
- Domain model/entity explanation.
- End-to-end flow narrative.
- Mermaid diagrams:
- context/component diagram,
- sequence diagram,
- state diagram if stateful,
- class/entity diagram when models are involved,
- batch/job/integration diagram when async or external systems exist.
- Key functions/classes and their responsibilities.
- External integrations, payloads, settings/env, and failure paths.
- Operational behavior: commands/jobs/queues/retries/logs/observability.
- Critical audit findings prioritized from most urgent to least.
- Quick wins vs larger refactors.
- Open questions and validation gaps.
Workflow
1. Frame the feature
Identify:
- feature/module name,
- user-visible entrypoints,
- internal modules/packages,
- external systems,
- background jobs or commands,
- persistence/state fields,
- security-sensitive data.
If scope is ambiguous, make a reasonable assumption and state it. Ask only when the wrong scope would make the analysis misleading.
2. Launch independent subagents when available
Use subagents only when the user explicitly asks for agents, delegation, or parallel analysis. Spawn distinct explorers with non-overlapping questions. Do not ask all agents to inspect the same thing.
Recommended agents:
- Model/Data Explorer: models/entities/state/relationships.
- Entrypoints Explorer: routes, controllers/views, forms, UI, templates, admin, public APIs.
- Integration Explorer: external services, payloads, env/settings, clients, middleware, error handling.
- Operations Explorer: jobs, commands, queues, retries, logs, observability, deployment config.
- Critical Auditor: after synthesis, challenge the result and prioritize improvements.
Use references/agent-prompts.md for ready-to-copy prompts.
While agents run, inspect non-overlapping files locally. Do not block immediately unless the next step depends on their result.
3. Inspect locally with source evidence
Use fast repository searches:
- filenames and directories related to the feature,
- URL/route definitions,
- model/entity definitions,
- commands/jobs/tasks,
- settings/env names,
- HTTP clients and external SDKs,
- templates/static assets,
- tests.
Record absolute paths and concrete class/function names. Prefer citing exact symbols over vague descriptions.
4. Build the flow model
For every major path, identify:
- trigger: user action, API call, command, cron, event, webhook,
- validator/form/schema,
- domain objects read/written,
- service/client calls,
- transaction/log/audit behavior,
- success state,
- failure state,
- retry/recovery path.
For batch systems, explicitly check whether batching is real or merely one-item async processing. Flag “one batch per item” as a design smell unless the external API requires it.
5. Create diagrams
Use Mermaid. Keep diagrams explanatory, not exhaustive.
Prefer these diagram types:
flowchart TD
A[Entry point] --> B[Validate]
B --> C[Persist state]
C --> D[External call]
sequenceDiagram
actor User
participant App
participant DB
participant External
User->>App: Action
App->>DB: Save state
App->>External: Request
External-->>App: Response
stateDiagram-v2
[*] --> Pending
Pending --> Sent
Sent --> Approved
Sent --> Rejected
classDiagram
class Entity
class TransactionLog
Entity --> TransactionLog
6. Run the critical audit
After the primary explanation is drafted, run a separate critical pass. It must not merely repeat the flow. It should look for:
- secrets in repo, DB, payload logs, admin screens, or runtime logs,
- authentication/authorization gaps,
- side effects on GET or unsafe endpoints,
- idempotency/concurrency issues,
- state ambiguity and missing state machine,
- retry/backoff/timeout gaps,
- duplicate legacy commands or divergent entrypoints,
- hardcoded placeholders/business constants,
- PII retention and log redaction,
- operational observability,
- testability and separation of concerns,
- real batching vs one-item batches.
Prioritize findings by risk and business impact.
7. Synthesize, do not dump
Integrate agent findings into a coherent explanation. Resolve contradictions by checking source code. If unresolved, label them as uncertainties.
Use headings and concise diagrams. Avoid pasting large source blocks.
Quality Checklist
Before finalizing, verify:
- All important paths use absolute file paths.
- Every diagram maps to actual code paths.
- The flow includes both success and failure paths.
- External integrations include endpoint, payload shape, auth/secrets, and error behavior.
- State fields are explained semantically.
- Batch/queue behavior is described honestly.
- Critical improvements are ordered from urgent to less urgent.
- Quick wins are separated from major refactors.
- Security and idempotency are explicitly covered.
1---2name: feature-flow-auditor3description: Analyze a software feature or module end-to-end using parallel subagents, source-code introspection, Mermaid/UML diagrams, and an independent critical audit. Use when asked to understand how a feature works, map flows across models/views/controllers/APIs/jobs/integrations, explain architecture, identify functions involved, produce diagrams, or prioritize improvements for any codebase feature.4---56# Feature Flow Auditor78## Purpose910Produce a complete, evidence-based explanation of how a feature works, then challenge it with an independent audit. Prefer read-only analysis unless the user explicitly asks to modify code.1112## Default Output1314Deliver, in this order:15161. Executive summary.172. Scope and assumptions.183. File/component map with absolute paths.194. Domain model/entity explanation.205. End-to-end flow narrative.216. Mermaid diagrams:22 - context/component diagram,23 - sequence diagram,24 - state diagram if stateful,25 - class/entity diagram when models are involved,26 - batch/job/integration diagram when async or external systems exist.277. Key functions/classes and their responsibilities.288. External integrations, payloads, settings/env, and failure paths.299. Operational behavior: commands/jobs/queues/retries/logs/observability.3010. Critical audit findings prioritized from most urgent to least.3111. Quick wins vs larger refactors.3212. Open questions and validation gaps.3334## Workflow3536### 1. Frame the feature3738Identify:3940- feature/module name,41- user-visible entrypoints,42- internal modules/packages,43- external systems,44- background jobs or commands,45- persistence/state fields,46- security-sensitive data.4748If scope is ambiguous, make a reasonable assumption and state it. Ask only when the wrong scope would make the analysis misleading.4950### 2. Launch independent subagents when available5152Use subagents only when the user explicitly asks for agents, delegation, or parallel analysis. Spawn distinct explorers with non-overlapping questions. Do not ask all agents to inspect the same thing.5354Recommended agents:5556- **Model/Data Explorer**: models/entities/state/relationships.57- **Entrypoints Explorer**: routes, controllers/views, forms, UI, templates, admin, public APIs.58- **Integration Explorer**: external services, payloads, env/settings, clients, middleware, error handling.59- **Operations Explorer**: jobs, commands, queues, retries, logs, observability, deployment config.60- **Critical Auditor**: after synthesis, challenge the result and prioritize improvements.6162Use `references/agent-prompts.md` for ready-to-copy prompts.6364While agents run, inspect non-overlapping files locally. Do not block immediately unless the next step depends on their result.6566### 3. Inspect locally with source evidence6768Use fast repository searches:6970- filenames and directories related to the feature,71- URL/route definitions,72- model/entity definitions,73- commands/jobs/tasks,74- settings/env names,75- HTTP clients and external SDKs,76- templates/static assets,77- tests.7879Record absolute paths and concrete class/function names. Prefer citing exact symbols over vague descriptions.8081### 4. Build the flow model8283For every major path, identify:8485- trigger: user action, API call, command, cron, event, webhook,86- validator/form/schema,87- domain objects read/written,88- service/client calls,89- transaction/log/audit behavior,90- success state,91- failure state,92- retry/recovery path.9394For batch systems, explicitly check whether batching is real or merely one-item async processing. Flag “one batch per item” as a design smell unless the external API requires it.9596### 5. Create diagrams9798Use Mermaid. Keep diagrams explanatory, not exhaustive.99100Prefer these diagram types:101102```mermaid103flowchart TD104 A[Entry point] --> B[Validate]105 B --> C[Persist state]106 C --> D[External call]107```108109```mermaid110sequenceDiagram111 actor User112 participant App113 participant DB114 participant External115 User->>App: Action116 App->>DB: Save state117 App->>External: Request118 External-->>App: Response119```120121```mermaid122stateDiagram-v2123 [*] --> Pending124 Pending --> Sent125 Sent --> Approved126 Sent --> Rejected127```128129```mermaid130classDiagram131 class Entity132 class TransactionLog133 Entity --> TransactionLog134```135136### 6. Run the critical audit137138After the primary explanation is drafted, run a separate critical pass. It must not merely repeat the flow. It should look for:139140- secrets in repo, DB, payload logs, admin screens, or runtime logs,141- authentication/authorization gaps,142- side effects on GET or unsafe endpoints,143- idempotency/concurrency issues,144- state ambiguity and missing state machine,145- retry/backoff/timeout gaps,146- duplicate legacy commands or divergent entrypoints,147- hardcoded placeholders/business constants,148- PII retention and log redaction,149- operational observability,150- testability and separation of concerns,151- real batching vs one-item batches.152153Prioritize findings by risk and business impact.154155### 7. Synthesize, do not dump156157Integrate agent findings into a coherent explanation. Resolve contradictions by checking source code. If unresolved, label them as uncertainties.158159Use headings and concise diagrams. Avoid pasting large source blocks.160161## Quality Checklist162163Before finalizing, verify:164165- All important paths use absolute file paths.166- Every diagram maps to actual code paths.167- The flow includes both success and failure paths.168- External integrations include endpoint, payload shape, auth/secrets, and error behavior.169- State fields are explained semantically.170- Batch/queue behavior is described honestly.171- Critical improvements are ordered from urgent to less urgent.172- Quick wins are separated from major refactors.173- Security and idempotency are explicitly covered.