/engineering:ai-app-architecturefrom engineering
Guides architecture decisions for AI-powered applications: choosing architecture style, selecting components, structuring the AI stack, build-vs-buy analysis, and multi-tenant module gating.
Ships in engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
| Input | Required | Purpose |
|---|---|---|
| Domain evidence | yes | AI use case, workload and tenancy profile, data classification, latency/cost targets, model constraints, and failure tolerance |
Default to read-only analysis. Read only scoped records; redact secrets and regulated data. Writes, execution, network calls, production configuration, customer communication, billing changes, and delegation require explicit authority and an identified owner. Never widen tenant, time-window, or system scope implicitly.
When required telemetry, evidence, execution, network access, or write authority is unavailable, return a partial result with each unassessed item labelled, preserve the safest existing state, and state the evidence or approval needed to continue. Never convert missing evidence into a pass.
| Condition | Action |
|---|---|
| Scope, owner, or threshold is missing | Stop the affected decision and request it |
| Evidence is incomplete but read-only analysis is safe | Produce a qualified partial result and gap list |
| A mutation exceeds authority or tenant boundary | Block it and route for approval |
| Evidence meets the stated threshold | Issue the output with provenance and owner |
Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.
| Category | Artifact | Format | Example |
|---|---|---|---|
| Correctness | AI architecture decision record | Markdown doc per skill-composition-standards/references/adr-template.md covering provider, deployment, and integration choices | docs/ai/architecture-adr-assistant.md |
references/practical-ai-engineering.md - evaluation-first AI engineering, RAG quality checks, agentic workflow controls, guardrails, telemetry, and cost discipline.references/ai-transformation-operating-model.md - operating-model, adoption, governance, human-centred design, and sustainability gates distilled from supplied AI transformation source material.AI-powered apps are built on top of foundation models via APIs. You are NOT training models — you are orchestrating them. Your value lies in the application layer: context construction, prompt engineering, retrieval, guardrails, and user experience.
Core principle: Start with the simplest architecture that works. Evolve deliberately.
Design AI systems for measurable economic value, production reliability, and long-term maintainability. Every serious AI application must connect model behavior to a business workflow, revenue lever, cost reduction, risk reduction, or service-quality improvement.
Before selecting a model or framework, define:
Reject AI features that cannot state their economic value or decision impact.
| Style | Description | When to Use |
|---|---|---|
| Wrap | Your UI + prompt engineering wraps a commercial LLM API | First project, internal tools, quick wins |
| RAG | Retriever fetches private/fresh data, injected into prompt | Apps needing company-specific or up-to-date knowledge |
| Workflow | Deterministic steps call models only where judgment or language is needed | Business processes with predictable stages and audit requirements |
| Agentic | LLM plans and executes multi-step tasks using tools | Complex automation, multi-step workflows |
| Fine-tuned | Model weights adapted for domain/style | Only when brand voice or jargon cannot be achieved via prompts |
Default path: Wrap -> RAG -> deterministic workflow -> agents. Only fine-tune when prompts, retrieval, examples, routing, and workflow design cannot meet the target.
┌──────────────────────────────────┐
│ User Interface (web/mobile) │
├──────────────────────────────────┤
│ Input Guardrail │ ← block PII, prompt injection, off-topic
│ Router / Intent Classifier │ ← route to right model/solution
│ Context Builder (RAG / Tools) │ ← feature engineering for AI
│ Model Gateway │ ← unified API wrapper, key mgmt, fallbacks
│ LLM API (OpenAI/Claude/Gemini) │
│ Output Guardrail │ ← catch toxicity, format failures, PII
│ Cache Layer │ ← exact + semantic caching
│ Streaming Handler │ ← MANDATORY — never block on full generation
├──────────────────────────────────┤
│ Token Ledger (MANDATORY) │ ← log every call: tenant_id, user_id, tokens
│ AI Module Gate (OFF by default)│ ← per-tenant enable/disable
└──────────────────────────────────┘
routing → retrieval → generation → scoringStep 1 (Baseline): Query → Model API → Response
Step 2 (Context): Query → Retriever → [Context + Query] → Model → Response
Step 3 (Guardrails): Input Guard → Context → Model → Output Guard → Response
Step 4 (Router): Router → [Intent-specific path] → Model(s) → Response
Step 5 (Cache): Router → Cache → [miss: full pipeline] → Cache Store
Step 6 (Agents): Router → Agent Loop [Plan → Tools → Reflect] → Response
Add each layer only when its absence is causing a real problem.
For production AI features, load references/practical-ai-engineering.md before finalising the architecture. It adds evaluation, RAG, agent, safety, fallback, telemetry, and cost-control gates.
| Capability | Minimum Standard |
|---|---|
| Versioning | Version prompts, models, tools, retrieval indexes, evaluation datasets, and safety policies |
| Observability | Log quality signals, cost, latency, failures, tool calls, cache hits, and user feedback by tenant and feature |
| Evaluation | Maintain golden sets, regression tests, adversarial cases, and release thresholds before launch |
| Governance | Document data flow, retention, PII handling, model/provider choice, human approval points, and audit trail |
| Resilience | Add timeouts, retries with backoff, fallbacks, degraded UX, queueing for long work, and circuit breakers |
| Data quality | Treat data pipelines, embeddings, metadata, and retrieval filters as first-class production assets |
| Explainability | Provide citations, source snippets, confidence bands, or reasoning summaries where users must trust decisions |
| Maintenance | Assign owners for prompt updates, eval refreshes, model migrations, cost reviews, and incident response |
| Option | Effort | Control | Cost | When |
|---|---|---|---|---|
| Commercial API (OpenAI/Claude) | Low | Low | Per-token | Default choice |
| Open source self-hosted (Llama) | High | Full | GPU infra | Data privacy requirement, high volume |
| Fine-tuned commercial | Medium | Partial | Training + inference | Brand voice, jargon control |
| Fine-tuned self-hosted | Very High | Full | High | Maximum control, regulated industries |
Rule: API wrap first. Justify self-hosting with actual cost/compliance numbers.
Every AI feature MUST be gated. AI costs real money per token.
-- Schema: AI module per tenant
CREATE TABLE tenant_ai_config (
tenant_id INT PRIMARY KEY,
ai_enabled BOOLEAN DEFAULT FALSE, -- OFF by default
monthly_budget_usd DECIMAL(10,2), -- null = unlimited
budget_alert_pct INT DEFAULT 80, -- alert at 80% of budget
plan_name VARCHAR(50), -- 'basic', 'pro', 'enterprise'
enabled_at TIMESTAMP,
created_at TIMESTAMP DEFAULT NOW()
);
Enforcement: Every AI endpoint checks tenant_ai_config.ai_enabled before processing. Return 402 Payment Required if disabled.
Log every AI API call for billing, debugging, and cost visibility.
CREATE TABLE ai_token_usage (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
tenant_id INT NOT NULL,
user_id INT NOT NULL,
feature_name VARCHAR(100), -- 'invoice_analysis', 'report_summary'
model VARCHAR(50), -- 'gpt-4o', 'claude-3-sonnet'
tokens_in INT NOT NULL,
tokens_out INT NOT NULL,
cost_usd DECIMAL(10,6), -- calculated at log time
latency_ms INT,
created_at TIMESTAMP DEFAULT NOW(),
INDEX idx_tenant_date (tenant_id, created_at),
INDEX idx_user_date (user_id, created_at)
);
-- Usage by tenant (for invoicing)
SELECT tenant_id,
SUM(tokens_in + tokens_out) AS total_tokens,
SUM(cost_usd) AS total_cost_usd,
DATE_FORMAT(created_at, '%Y-%m') AS month
FROM ai_token_usage
GROUP BY tenant_id, month;
-- Usage by user (for analytics)
SELECT user_id, feature_name,
SUM(tokens_in + tokens_out) AS tokens,
COUNT(*) AS calls
FROM ai_token_usage
WHERE tenant_id = ? AND created_at > DATE_SUB(NOW(), INTERVAL 30 DAY)
GROUP BY user_id, feature_name;
function checkAiQuota(int $tenantId): void {
$config = TenantAiConfig::find($tenantId);
if (!$config || !$config->ai_enabled) {
throw new AiModuleDisabledException('AI module not enabled for this account.');
}
if ($config->monthly_budget_usd !== null) {
$spent = AiTokenUsage::currentMonthCost($tenantId);
if ($spent >= $config->monthly_budget_usd) {
throw new AiBudgetExceededException('Monthly AI budget reached.');
}
if ($spent >= $config->monthly_budget_usd * ($config->budget_alert_pct / 100)) {
notifyTenantBudgetAlert($tenantId, $spent, $config->monthly_budget_usd);
}
}
}
| Layer | Lightweight | Production |
|---|---|---|
| LLM | OpenAI API | API + fallback provider via gateway |
| Context | In-memory / SQLite | Vector DB (Chroma, Qdrant, Pinecone) |
| Cache | Redis | Redis Cluster |
| Queue | Sync | Kafka / RabbitMQ |
| Monitoring | Log file | Prometheus + Grafana |
Chip Huyen — AI Engineering (2025); David Spuler — Generative AI Applications (2024); Andrea De Mauro — AI Applications Made Easy (2024)
For a prompt-versus-retrieval-versus-adaptation decision and release evidence for generated outputs, use model adaptation and generated-output review.
references/routing.md to map retired AI child skill slugs to their reference modules.references/ai-architecture-patterns/entrypoint.md (opens in a new tab)references/ai-on-saas-architecture/entrypoint.md (opens in a new tab)references/ai-on-saas-architecture/references/control-plane-ai-services.md (opens in a new tab)references/ai-on-saas-architecture/references/llm-gateway-design.md (opens in a new tab)references/ai-transformation-operating-model.md (opens in a new tab)references/practical-ai-engineering.md (opens in a new tab)references/routing.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub peterbamuhigire/chwezi-dev-engine --plugin engineering169 skills in this plugin
/accounting-engineUse when designing or implementing double-entry accounting policy and an embedded ledger engine for invoices, payments, stock, balanced postings, mapped accounts, idempotency, reversals, period locks, audit trails, and financial statements./accounting-finance-controllerUse when coordinating accounting and finance implementation reviews, doctrine routing, control evidence, remediation priorities, and release decisions across a software system./advanced-testing-strategyUse when designing or reviewing test strategy for production systems, APIs, mobile apps, SaaS platforms, ERP workflows, and AI-enabled systems. Covers unit, integration, contract, end-to-end, regression, release-gate, and risk-based testing decisions.Other plugins' skills for the same job