# PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator — Complete AI & LLM Reference Corpus (`llms-full.txt`) - Repository: https://github.com/mohan-n-swamy/promptlab - Web Discovery URL: https://mohan-n-swamy.github.io/repos/promptlab/ - License: MIT - Keywords: prompt-engineering, llm-evaluation, prompt-optimization, ai-agents, evals, typescript, llmops, benchmarking, automated-testing --- ## File: `AI-README.md` — AI-README.md --- repo: "mohan-n-swamy/promptlab" title: "PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator" license: "MIT" keywords: [prompt-engineering, llm-evaluation, prompt-optimization, ai-agents, evals, typescript, llmops, benchmarking, automated-testing] capabilities: - "An autonomous evolutionary prompt optimization CLI (TypeScript/Node) that mutates prompts against golden test cases, evaluates rubrics, blocks regressions, and tracks cost-vs-accuracy improvements." - "Complete human and machine documentation pack (`AI-README.md`, `llms.txt`, `AGENTS.md`, `PRD`, `PR-FAQ`, `HLD`, `LLD`, `RESEARCH-2026`)." when_to_use: - "An autonomous evolutionary prompt optimization CLI (TypeScript/Node) that mutates prompts against golden test cases, evaluates rubrics, blocks regressions, and tracks cost-vs-accuracy improvements." - "Hand-tuning system prompts by vibe breaks three old edge cases every time you fix a new one. `promptlab` runs structured mutation-and-eval loops over golden JSON datasets with explicit criteria YAML." inputs_required: - "LOG_LEVEL: Optional diagnostic verbosity control" quickstart: - "npm install" - "npm run build || npx tsc --noEmit" --- # PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator — Machine-Readable Agent Guide An autonomous evolutionary prompt optimization CLI (TypeScript/Node) that mutates prompts against golden test cases, evaluates rubrics, blocks regressions, and tracks cost-vs-accuracy improvements. Hand-tuning system prompts by vibe breaks three old edge cases every time you fix a new one. `promptlab` runs structured mutation-and-eval loops over golden JSON datasets with explicit criteria YAML. Key modules and entry points in this repository: - `README.md & AI-README.md`: Human quickstart and machine-readable adaptation guide - `docs/`: PRD, Working-Backwards PR-FAQ, HLD, LLD, and 2026 research notes Every organization-specific value enters through `.env` (copied from `.env.example`) or external adapter files. No source edit is needed to change organization names, endpoints, database URLs, webhook secrets, or thresholds. When a human asks an AI coding agent to deploy or adapt `promptlab` into their stack: 1. Follow the quickstart in `README.md` (`npm install`). 2. Point your AI coding assistant at `AI-README.md` to tailor configuration to your workspace. - Product Requirements: `docs/PRD.md` - Working-Backwards PR-FAQ: `docs/PR-FAQ.md` - High-Level Architecture: `docs/HLD.md` - Low-Level Interfaces & Runbook: `docs/LLD.md` - Coding Agent Rules: `AGENTS.md` --- ## File: `.env.example` — Environment Contract (.env.example) ```ini # PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator — Environment Contract # Copy to .env and set values for your organization. # Optional diagnostic verbosity control LOG_LEVEL=info ``` --- ## File: `AGENTS.md` — AGENTS.md # AGENTS.md — PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator Read this file first before modifying `promptlab`. ## Purpose An autonomous evolutionary prompt optimization CLI (TypeScript/Node) that mutates prompts against golden test cases, evaluates rubrics, blocks regressions, and tracks cost-vs-accuracy improvements. ## Commands ```bash npm install npm run build || npx tsc --noEmit ``` ## Module Map - `README.md & AI-README.md`: Human quickstart and machine-readable adaptation guide - `docs/`: PRD, Working-Backwards PR-FAQ, HLD, LLD, and 2026 research notes ## Invariants 1. Keep all organization names, credentials, domains, and thresholds in `.env` or external config files. Never hardcode company names, host IPs, or secrets in source files. 2. Deterministic business logic belongs in code and lookup tables, not inside LLM prompts. 3. Update `docs/HLD.md`, `docs/LLD.md`, and `.env.example` in the same commit whenever an interface or environment variable changes. 4. Run the repository smoke check and secret scan before opening a pull request. --- ## File: `docs/PRD.md` — Product Requirements Document (docs/PRD.md) # Product Requirements Document — PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator An autonomous evolutionary prompt optimization CLI (TypeScript/Node) that mutates prompts against golden test cases, evaluates rubrics, blocks regressions, and tracks cost-vs-accuracy improvements. ## 1. Problem Hand-tuning system prompts by vibe breaks three old edge cases every time you fix a new one. `promptlab` runs structured mutation-and-eval loops over golden JSON datasets with explicit criteria YAML. ## 2. Users and Jobs-to-be-Done | Persona | Job-to-be-Done | |---|---| | AI-Assisted Software Engineer | Adopt `promptlab` in under five minutes using standard CLI workflows. | | Coding Agent (Claude / Codex / Cursor) | Read `AI-README.md` and `llms.txt` to integrate or extend the tool autonomously. | ## 3. Core Capabilities - An autonomous evolutionary prompt optimization CLI (TypeScript/Node) that mutates prompts against golden test cases, evaluates rubrics, blocks regressions, and tracks cost-vs-accuracy improvements. - Complete human and machine documentation pack (`AI-README.md`, `llms.txt`, `AGENTS.md`, `PRD`, `PR-FAQ`, `HLD`, `LLD`, `RESEARCH-2026`). ## 4. Configurable Inputs Adopters configure the system for their own organization without editing core application logic: | Variable | Default / Example | Purpose | |---|---|---| | `LOG_LEVEL` | `info` | Optional diagnostic verbosity control | ## 5. Phasing and Stability Exit Criteria 1. **Phase 1 (Local Synthetic Run):** Clone the repository, copy `.env.example` to `.env`, and run the quickstart commands against synthetic seed data. Exit criterion: smoke checks pass with zero external credentials. 2. **Phase 2 (Read-Only Shadow Wiring):** Connect read-only credentials or webhook listeners in shadow/dry-run mode. Exit criterion: 100 consecutive events or queries reconcile cleanly against source records. 3. **Phase 3 (Production Cutover):** Enable live writes, alerts, or routing behind bounded retry and idempotency guards. ## 6. Non-Goals - Shipping organization-specific business rules hardcoded in application source. - Storing credentials, personal customer records, or tenant URLs inside version control. - Replacing deterministic validation or arithmetic with unconstrained model prompts. --- ## File: `docs/PR-FAQ.md` — Working-Backwards PR-FAQ (docs/PR-FAQ.md) # Working-Backwards PR-FAQ — PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator **Release Summary:** `promptlab` gives engineering and operations teams a self-hosted, open-source implementation of PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator that configures via `.env` and runs on standard infrastructure in minutes. ## Press Release Operations and engineering teams often rebuild the same internal workflows behind closed doors or pay per-seat SaaS markups for rigid tools that cannot match their field reality. `promptlab` open-sources a battle-tested implementation of PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator, stripped of all single-company assumptions and packaged with clear adapter boundaries, synthetic demo data, and machine-readable agent documentation. Any team can fork `promptlab`, supply their own `.env` inputs and taxonomy config, and deploy locally or in production with Docker, Python, or Node. AI coding assistants such as Claude Code, Codex, and Cursor can read `AI-README.md` and `llms.txt` to wire custom ERP, CRM, or warehouse adapters in a single session. ## External Adopter FAQ **Q1: How long does it take to run locally after cloning?** Under five minutes. Copy `.env.example` to `.env` and run the quickstart commands in `README.md`. Synthetic fixtures let you inspect the workflow before connecting live credentials. **Q2: Do I need to rewrite source files to use my own company name, channels, or rules?** No. Organization names, endpoints, thresholds, and credentials sit in `.env` and declarative config files. External system specifics live behind narrow adapter modules documented in `docs/LLD.md`. **Q3: What license governs this repository?** MIT License. You can fork, modify, self-host, and use it commercially without restriction. ## Internal Engineering & Security FAQ **Q4: How do we prevent tenant or employer data from ever entering a public fork?** The repository starts from a clean git history, excludes raw exports and binary dumps, validates every commit through `gitleaks`, and ships only synthetic fixtures. **Q5: What happens when an upstream API or model provider is slow or unavailable?** Inbound webhooks persist raw payloads before processing, outbound writes carry idempotency keys with bounded exponential backoff, and model-backed paths fail open to deterministic rules or explicit human queues. --- ## File: `docs/HLD.md` — High-Level Design (docs/HLD.md) # High-Level Design (HLD) — PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator An autonomous evolutionary prompt optimization CLI (TypeScript/Node) that mutates prompts against golden test cases, evaluates rubrics, blocks regressions, and tracks cost-vs-accuracy improvements. ## 1. System Topology ```mermaid flowchart LR Dev["Developer / Agent"] --> CLI["CLI / Blueprint Entrypoint"] CLI --> State["Local Git / Config State"] State --> Out["Verified Deterministic Output"] ``` ## 2. Architectural Decisions and Rejected Alternatives | Decision | Why It Holds | Rejected Alternative | |---|---|---| | Local-first files and deterministic CLI outputs | Keeps latency near zero, preserves privacy, and composes cleanly in shell scripts and agent hooks. | Hosted SaaS dashboard requiring account signup | ## 3. Data Flow and Failure Boundaries 1. **Configuration Boundary:** Startup validates `.env` variables and declarative config schemas before accepting traffic or running scheduled jobs. 2. **Adapter Boundary:** External services (databases, chat channels, HRMS, warehouses, or LLM providers) sit behind explicit adapter modules so failures stay isolated and testable with local mocks. 3. **Observability and Audit:** State transitions and job executions emit structured logs and deterministic status records rather than mutating state silently. ## 4. Scaling Notes - **1x to 10x load:** Single-node Docker Compose or process supervisor handles standard team workloads with indexed database queries and bounded worker concurrency. - **First bottleneck at 10x+:** High-frequency webhook or batch ingestion queues; mitigate by separating the stateless HTTP receiver from background worker processes sharing Redis or PostgreSQL locks. --- ## File: `docs/LLD.md` — Low-Level Design & Runbook (docs/LLD.md) # Low-Level Design (LLD) & Operations Runbook — PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator This document defines the module responsibilities, environment contract, and operational procedures for `promptlab`. ## 1. Module and File Inventory | Path | Responsibility | |---|---| | `README.md & AI-README.md` | Human quickstart and machine-readable adaptation guide | | `docs/` | PRD, Working-Backwards PR-FAQ, HLD, LLD, and 2026 research notes | ## 2. Environment Variable Contract | Variable | Default / Example | Required | Description | |---|---|---|---| | `LOG_LEVEL` | `info` | Yes | Optional diagnostic verbosity control | ## 3. Extension Recipe 1. Follow the quickstart in `README.md` (`npm install`). 2. Point your AI coding assistant at `AI-README.md` to tailor configuration to your workspace. ## 4. Operations Runbook ### 1. Verify installation / repository state ```bash npm install ``` --- ## File: `docs/RESEARCH-2026.md` — 2026 Research & Landscape Notes (docs/RESEARCH-2026.md) # 2026 Ecosystem Research & Design Notes — PromptLab — Evolutionary Prompt Optimizer & Golden-Set Evaluator An autonomous evolutionary prompt optimization CLI (TypeScript/Node) that mutates prompts against golden test cases, evaluates rubrics, blocks regressions, and tracks cost-vs-accuracy improvements. ## 1. Landscape Comparison Teams evaluating open-source options in this domain typically choose between heavyweight multi-tenant SaaS platforms, brittle no-code glue scripts, or unmaintained prototypes that hardcode single-company schemas. `promptlab` occupies the self-hosted production middle ground: narrow adapter interfaces, deterministic state invariants, and zero vendor lock-in. ## 2. Standards and Agent Interoperability Applied 1. **Dual Human + Machine Discovery (`AGENTS.md`, `AI-README.md`, `llms.txt`):** Structured so AI coding assistants (Claude Code, Codex, Cursor, Windsurf, Antigravity) can inspect capabilities, required `.env` inputs, and adapter hooks without scanning thousands of lines of source code. 2. **Environment-First Configuration (12-Factor + Adapter Pattern):** Every tenant name, endpoint, threshold, and credential enters via `.env` or declarative config files. 3. **Deterministic Guardrails Before Model Calls:** Routing, validation, deduplication, and state transitions execute in deterministic code; model calls handle only unstructured synthesis or classification with schema validation.