Supports Claude Code & Gemini CLI

Specs that ship without revisions.

Implementation-ready feature blueprints, bug fix plans, and security audits for Claude Code and Gemini CLI. Enforced quality gates — edge cases, correctness properties, 12-domain security reviews — traced end-to-end.

Install
$ npx amanah-blueprint

See it in action

From install to blueprint in 60 seconds.

amanah-blueprint — bash

Every team has the same problem.

You describe a feature to an AI (or a developer). They build something. It's 80% right. Missing edge cases. Vague error handling. No tests for the tricky parts.

Without Blueprint
  • AI writes plans from memory
  • "Handle errors gracefully"
  • No edge cases identified
  • "Write tests" (no strategy)
  • Hope it works in production
With Blueprint
  • + AI reads your code first
  • + Error table: scenario, HTTP code, response, recovery
  • + 5-10 edge cases with exact behavior
  • + Property-based + unit + integration strategy
  • + 29 quality gates enforced on every spec

Features

What makes specs implementation-ready.

Formal Acceptance Criteria

WHEN/IF/THEN SHALL language with concrete input/output examples for every criterion.

Edge Case Enumeration

Minimum 5 per feature with exact expected behavior, traced to correctness properties and tests.

Correctness Properties

Formal statements bridging requirements and tests. Every property validates at least one must-have.

Code Reuse First

Existing services, utilities, and models identified before designing new components. Reuse before build.

29 Quality Gates

Security, performance, traceability, and code quality checks enforced on every blueprint before finalizing.

Auto Progress Tracking

- [x] marks in now.md. Resume after interrupt. Audit trail built in.

How It Works

Sequential workflow with built-in review.

One file at a time, with user review between each step. Errors caught early don't compound.

flowchart LR
    A["Research
Codebase"] --> B["what.md
Requirements"] B --> C["how.md
Design"] C --> D["now.md
Action Items"] D --> E["Implement"] style A fill:#18181b,stroke:#71717a,stroke-width:2px,color:#f4f4f5 style B fill:#18181b,stroke:#34d399,stroke-width:2px,color:#f4f4f5 style C fill:#18181b,stroke:#34d399,stroke-width:2px,color:#f4f4f5 style D fill:#18181b,stroke:#34d399,stroke-width:2px,color:#f4f4f5 style E fill:#18181b,stroke:#f59e0b,stroke-width:2px,color:#f4f4f5
01

Install

Run in your project directory.

$ npx amanah-blueprint
02

Setup

In Claude Code, generate atlas.

claude> /setup
03

Generate

Create your first blueprint.

claude> /blueprint my-feature

See a Blueprint

Real spec. Real depth.

This is what gets generated for a payment integration feature. Click a tab to switch between files.

.amanah/blueprints/payment-integration/
# Credit Billing — What

## Overview
Credit-based billing for AI features. Users purchase credits,
each AI action costs a specific amount.

## Glossary
- **Credit**: Virtual currency, 1 credit = $0.01
- **Cost Map**: Lookup table mapping AI actions to credit costs

## Must-Haves

### M-1: Credit Deduction on AI Action
- **Priority**: P0 (must)
- **User Story:** As a user, I want to see exactly how many
  credits each AI action costs before it runs.

#### Acceptance Criteria
1. WHEN an AI action is requested, THE system SHALL check
   the user's credit balance against the action's cost.
   - Example: balance=50, cost=10 → allow, new balance=40

2. IF balance < cost, THEN THE system SHALL reject with HTTP 402.
   - Example: balance=3, cost=10 → HTTP 402
     {required: 10, current: 3}

## Edge Cases
| Scenario | Expected Behavior |
|----------|-------------------|
| balance = 0 | Block, show purchase prompt |
| Concurrent requests | Serialize via SELECT FOR UPDATE |
| Webhook timeout | Don't add credits, log for reconcile |
| Cost map changes mid-flight | Use cost at request start time |
# Credit Billing — How

## Overview
Credit check and deduction via dedicated service layer.
Uses database row-level locking (SELECT FOR UPDATE).

**Key Design Decisions:**
- Row-level locking over mutexes (survives crashes)
- Immutable ledger (balance derived from ledger sum)
- Cost map cached in Redis (admin updates without deploys)

## Architecture

```mermaid
sequenceDiagram
    participant C as Client
    participant A as API
    participant S as CreditService
    participant D as Database

    C->>A: POST /api/v1/generate-report
    A->>S: check_and_deduct(user_id, action)
    S->>D: SELECT FOR UPDATE balance
    D-->>S: balance = 50
    alt balance >= cost
        S->>D: INSERT ledger + UPDATE balance
        S-->>A: {success: true, balance_after: 40}
    else balance < cost
        S-->>A: {success: false, required: 10}
    end
```

## Existing Code to Reuse
| What | File Path | How to Reuse |
|------|-----------|-------------|
| StripeWebhookHandler | services/payment/stripe.py | Add credit top-up |
| UserModel | models/user.py | Add credit_balance |

## Correctness Properties

### Property 1: Balance Never Negative
*For any* sequence of concurrent deductions, balance SHALL
never go below 0.
**Validates: M-1, Q-2**
# Credit Billing — Now

## Action Items

- [ ] 1. Database: Create ledger table
  - [ ] 1.1 Create Alembic migration `add_credit_billing`
    - Add `credit_balance INTEGER DEFAULT 0` to users
    - Create `credit_ledger` table
    - _Ref: M-1.3_

- [ ] 2. Checkpoint — Database ready
  - Run `alembic upgrade head`

- [ ] 3. Service layer
  - [ ] 3.1 Create `services/billing/credit_service.py`
    - `CreditService.check_and_deduct(db, user_id, action)`
    - Use SELECT FOR UPDATE for row locking
    - _Ref: M-1.1_

- [ ] 4. Checkpoint — Service layer ready
  - Unit test: check_and_deduct() with mock DB

- [ ] 5. API
  - [ ] 5.1 Add credit check to AI endpoints
    - _Ref: M-1.1_

- [ ] 6. Tests
  - [ ] 6.1 Unit tests
  - [ ] 6.2 Property tests (Hypothesis)
  - [ ] 6.3 Integration tests

- [ ] 7. Final checkpoint — All tests pass

## Dependency Graph
```json
{
  "waves": [
    { "id": 0, "tasks": ["1.1"] },
    { "id": 1, "tasks": ["3.1"] },
    { "id": 2, "tasks": ["5.1"] },
    { "id": 3, "tasks": ["6.1", "6.2", "6.3"] }
  ]
}
```

Cross-Referencing

Nothing is orphaned.

Every artifact is numbered and linked. Requirements trace to properties, properties trace to tests, edge cases trace through the full chain.

M-1.2 in what.md → validated by Property 3 in how.md → tested by Test 5.2 in now.md
Every edge case has a corresponding property and test
Function names consistent across all three files
graph LR
    M1["M-1.2
Requirement"] -->|"validated by"| P1["Property 3
Speed-Up Bounded"] E1["Edge Case
TTS 10s audio"] -->|"covered by"| P1 P1 -->|"tested by"| T1["Test 5.2
test_speed_factor_bounds"] M1 -->|"traced to"| T1 style M1 fill:#18181b,stroke:#34d399,stroke-width:2px,color:#f4f4f5 style P1 fill:#18181b,stroke:#a78bfa,stroke-width:2px,color:#f4f4f5 style E1 fill:#18181b,stroke:#f59e0b,stroke-width:2px,color:#f4f4f5 style T1 fill:#18181b,stroke:#34d399,stroke-width:2px,color:#f4f4f5

Two Modes

Right tool for the job.

flowchart TD
    A["User Request"] --> B{"Detect Intent"}
    B -->|"/blueprint, plan feature"| C["Full Mode
what + how + now"] B -->|"/fix, hotfix, why"| D["Lite Mode
fix.md only"] style A fill:#18181b,stroke:#71717a,stroke-width:2px,color:#f4f4f5 style B fill:#18181b,stroke:#a78bfa,stroke-width:2px,color:#f4f4f5 style C fill:#18181b,stroke:#34d399,stroke-width:2px,color:#f4f4f5 style D fill:#18181b,stroke:#f59e0b,stroke-width:2px,color:#f4f4f5

Full Mode

Features

For new features and multi-component work.

what.md — requirements, edge cases, risks
how.md — architecture, code, properties
now.md — action items, tests, checkpoints

Sequential review — pause after each file.

Lite Mode

Bug Fixes

For bug fixes, hotfixes, and small changes.

fix.md — everything in one file

Root cause → fix steps → edge cases → tests

Auto-escalates to Full Mode if >5 files affected.

Quality Gates

0 quality gates enforced on every blueprint.

Every blueprint enforces a set of quality gates before it is considered complete. These are what eliminate the revision cycle typical of AI-generated specs.

29 Quality Gates
E Edge Cases
  • Minimum 5 per feature
  • Exact expected behavior
  • Trace to Properties & Tests
C Code Quality
  • No stubbed code anywhere
  • No deprecated APIs
  • Circular import detection
P Correctness
  • Formal Properties
  • Property-to-code consistency
  • Property-to-test coverage
R Reuse First
  • Existing code inventory
  • File path validation
  • Cross-blueprint conflict detection
T Traceability
  • M-N to action items
  • Action items to tests
  • Edge cases to Properties
S Security
  • SQL injection check
  • Auth on all endpoints
  • No hardcoded secrets
Performance — 6 checks
DB indexes on non-PK columns No N+1 queries Long tasks backgrounded External call timeouts Concurrency protection Pagination on all list endpoints

Validation Checklist (Excerpt)

The generator validates every blueprint against 29 checks before finalizing. Key categories:

Traceability 0 checks
  • Every must-have has at least one action item
  • Every Property links to at least one must-have
  • Every Property has a corresponding test in now.md
  • Every edge case has a test in now.md
  • Function name consistency across all files
  • Property-code behavior consistency check
  • Revision Log present in all blueprint files
Security 0 checks
  • SQL injection scan (no string concatenation in queries)
  • Auth dependency on all endpoints
  • Input validation on all user-facing functions
  • No hardcoded secrets or credentials
  • tenant_id isolation on every database query
  • No information leak in error responses
  • Empty input guards at function entry points
Performance 0 checks
  • Database indexes on all non-PK WHERE/ORDER BY/JOIN columns
  • N+1 query detection (no loop-then-query patterns)
  • Long-running tasks (>5s) backgrounded to workers
  • External call timeouts configured explicitly
  • Concurrency protection (SELECT FOR UPDATE / optimistic locking)
  • Pagination on all list endpoints (no unbounded SELECT *)
Code Quality 0 checks
  • No stubbed code (# ... same as current ...)
  • No deprecated APIs (e.g., get_event_loop())
  • No circular imports between components
  • Fallback/error functions fully implemented
  • Python 3.11+ uses asyncio.to_thread()
File Integrity 0 checks
  • All file paths verified via grep/glob (no phantom files)
  • "Existing Code to Reuse" paths exist in project
  • Conflict detection across other blueprints

Atlas

Project-aware blueprints.

Atlas is persistent project context — 5 files that tell the generator about your codebase. Blueprints use your actual imports, file paths, and conventions.

+ With atlas: Uses your imports, your patterns, your file paths.
Without atlas: Falls back to CLAUDE.md and README.md.
.amanah/atlas/
product.md Domain, roles, business model
tech.md Stack, libraries, services
structure.md Directory layout, patterns
conventions.md Gotchas, naming rules
quickstart.md Copy-paste recipes

Slash Commands

12 commands. Full control.

Command Purpose
/setup One-time project initialization
/blueprint <name> Generate full feature blueprint
/fix <name> Generate bug fix plan
/build <name> Autonomously execute blueprint
/spec <name> Read existing blueprint + progress
/review <file> Review code against conventions
/test <feature> Scaffold Vitest tests from spec
/audit <file> Run 29 Quality Gates audit
/bridge <path> Sync external API/Backend context
/history <topic> Search past blueprints for patterns
/security-review [mode] OWASP, UU PDP, ISO 27001 security audit
/atlas Regenerate atlas from codebase

Token Optimization

Built for cost efficiency.

Blueprints are token-intensive by nature. The framework includes optimizations to minimize cost.

Task Tokens
1 Lite fix (fix.md) ~5-8K
1 Full blueprint (what + how + now) ~20-30K
2 Full blueprints (same session) ~40K
Atlas regeneration ~15K

Tip: Batch blueprints in one session to save ~5K tokens per additional blueprint. Atlas stays in context.

12 Security Domains

Security Review Agent

Ship secure code. Every time.

Comprehensive security audits covering OWASP Top 10, Indonesian UU PDP compliance, ISO 27001, multi-tenant isolation, AI/LLM security, and infrastructure hardening.

1

Auth & Authorization

JWT validation, RBAC, session management, token security, privilege escalation

OWASP A01

2

Injection Attacks

SQL injection, command injection, template injection, path traversal

OWASP A03

3

Data Protection & Privacy

PII handling, encryption at rest/transit, UU PDP compliance, GCS security

OWASP A02 + UU PDP

4

Multi-Tenant Isolation

DB queries, API scope, storage paths, AI/LLM context, Redis keys, background jobs

Project-specific — Always Critical

5

API Security

Rate limiting, CORS, security headers, error handling, debug endpoints

OWASP A01/A05/A07

6

Infrastructure

Docker security, secrets management, database hardening, network config

OWASP A05

7

AI/LLM Security

Prompt injection, data leakage, cost abuse, output validation, tool call safety

OWASP LLM Top 10

8

Mobile Security

Secure storage, HTTPS enforcement, biometric auth, code protection

OWASP Mobile Top 10

9

+ 3 More Domains

Input validation, dependency audit, business logic/payment, logging & monitoring

OWASP A03/A04/A06/A09

security-review

# Full codebase audit — all 12 domains

claude> /security-review full


# Targeted AI/LLM security review

claude> /security-review ai


# UU PDP compliance check

claude> /security-review compliance uupdp


# Infrastructure security (Docker, secrets, network)

claude> /security-review infra

OWASP Top 10 UU PDP (Indonesia) ISO 27001 OWASP LLM Top 10 OWASP Mobile Top 10

Start in 30 seconds.

Choose your agent and get your first implementation-ready spec.

Claude Code

Auto-installs to .claude/

$ npx amanah-blueprint
claude> /setup
claude> /blueprint feature

Gemini CLI

Global user-level skills

$ gemini skills install blueprint.skill --scope user
gemini> /setup
gemini> /blueprint feature

FAQ

Common questions.

Does this work with any tech stack?
Yes. The generator detects your stack from CLAUDE.md, package.json, requirements.txt, or similar files. Code examples and conventions are adapted to the detected stack.
Can I use this without Claude Code?
Slash commands are Claude Code-specific, but the blueprint structure (what/how/now and fix.md) works with any AI assistant or as a team convention for human developers. The file format is plain Markdown.
Does it modify my source code?
No. The framework only writes files to .amanah/, .claude/commands/, .claude/skills/, and .claude/agents/. Your source code is never touched.
How is this different from GitHub Issues or Jira?
Issue trackers track work. Blueprints define how to do the work. A blueprint is what you hand to a developer (or AI agent) so they can implement without guessing. Blueprints can be linked from issues — the issue tracks state, the blueprint specifies execution.
When should I use Full vs Lite Mode?
Use Full Mode for new features, multi-component work, or when architecture decisions are needed. Use Lite Mode for bug fixes, hotfixes, and small changes affecting ≤5 files. Lite Mode auto-escalates to Full Mode if the bug turns out to be systemic.
Can I customize the templates?
Yes. Edit SKILL.md and AGENT.md in your project's .amanah/ directory to add project-specific rules or modify generation behavior.