v5.1.0 — now on npm

Specs that ship without revisions.

Implementation-ready feature blueprints and bug fix plans for Claude Code. Enforced quality gates — edge cases, correctness properties, security checks — traced end-to-end.

Install
$ npx amanah-blueprint
npm version npm downloads GitHub stars license

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

29 checks enforced on every blueprint.

Click a category to see the individual checks. These run before a blueprint is finalized.

Traceability 8 checks
  • Every action item references at least one must-have (M-N)
  • 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 7 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 6 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 5 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 3 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

Five commands. Full control.

Command Purpose
/setup One-time project initialization
/blueprint <name> Generate full feature blueprint
/fix <name> Generate bug fix plan
/spec <name> Read existing blueprint + progress
/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.

Start in 30 seconds.

Three commands to your first implementation-ready spec.

$ npx amanah-blueprint

Install the framework in your project directory.

claude> /setup

In Claude Code — generates atlas, installs skills, updates CLAUDE.md.

claude> /blueprint my-first-feature

Generates what.md, pauses for review, then how.md, then now.md.

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.