惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
PCI Perspectives
PCI Perspectives
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
H
Heimdal Security Blog
S
Security @ Cisco Blogs
N
News | PayPal Newsroom
J
Java Code Geeks
罗磊的独立博客
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic
V
V2EX
WordPress大学
WordPress大学
Google Online Security Blog
Google Online Security Blog
N
News and Events Feed by Topic
www.infosecurity-magazine.com
www.infosecurity-magazine.com
月光博客
月光博客
AI
AI
小众软件
小众软件
The GitHub Blog
The GitHub Blog
MongoDB | Blog
MongoDB | Blog
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
美团技术团队
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Tailwind CSS Blog
S
Schneier on Security
博客园 - 三生石上(FineUI控件)
F
Full Disclosure
B
Blog RSS Feed
Forbes - Security
Forbes - Security
S
SegmentFault 最新的问题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
Jina AI
Jina AI
Cisco Talos Blog
Cisco Talos Blog
U
Unit 42
Project Zero
Project Zero
H
Hacker News: Front Page
Y
Y Combinator Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Cloudflare Blog
大猫的无限游戏
大猫的无限游戏
S
Secure Thoughts
The Hacker News
The Hacker News
Microsoft Azure Blog
Microsoft Azure Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Stop Hardcoding AI Prompts: A Developer’s Guide to PromptCache
Viraj Lakshi · 2026-05-20 · via DEV Community

Manage, version, and deploy your team’s AI prompts like code — with a TypeScript SDK, REST API, and a shared library that keeps everyone on the same page.


If you’ve been building AI-powered features for any length of time, you’ve hit this wall: prompts scattered across .env files, Notion docs, Slack threads, and inline strings buried in your codebase. Someone tweaks a system prompt in production — no review, no history, no rollback. A teammate asks “which version of that email prompt are we using?” and nobody knows.

PromptCache solves this. It’s a centralized prompt management platform — think GitHub for your AI prompts — with versioning, typed variables, team collaboration, and a TypeScript SDK that lets you fetch and invoke prompts directly in your app. No more hardcoded strings.

This guide walks you through everything from setup to production integration.


Table of Contents

  1. What is PromptCache?
  2. Core Concepts
  3. Getting Started
  4. Installing the SDK
  5. Fetching and Invoking Prompts
  6. Typed Variables in Practice
  7. Versioning and Rollbacks
  8. Scoped API Keys
  9. REST API Usage (curl examples)
  10. Real-World Example: AI Email Feature
  11. Team Workflow
  12. Community Gallery
  13. Join the Beta

What is PromptCache?

PromptCache is a prompt management platform built specifically for engineering teams shipping AI features. It gives you:

  • One Library — all prompts in a single searchable, filterable workspace
  • Versioning — GitHub-style snapshots for every update, with instant rollback
  • Typed Variables — define {{role}}, {{tone}}, {{recipient}} with types and defaults
  • Collaboration — invite teammates, manage roles, share knowledge
  • REST API & TypeScript SDK — invoke prompts directly from your app with scoped keys

The problem it solves is real: without a shared prompt library, teams rebuild the same work over and over — and get inconsistent AI outputs every time.


Core Concepts

Before diving into code, here are the three things you need to understand:

Prompts are versioned templates stored in your PromptCache workspace. Each prompt has a unique ID you reference from your code.

Variables are typed placeholders inside prompt templates, written as {{variable_name}}. They can be required (e.g. role: string) or optional with defaults (e.g. tone: string, default: "professional").

Invoke is the act of resolving a prompt — filling in all variables and returning the final, ready-to-use string. The SDK handles this with client.prompts.invoke().


Getting Started

1. Create your workspace

Head to promptcache.app and request access to the invite-only beta. Access is granted within 24 hours.

2. Create your first prompt

In the dashboard, create a new prompt. Write your template using {{variable}} syntax — variables are auto-detected instantly:

You are a {{role}} at {{company}}.
Write a {{tone}} email to {{recipient}}
about {{topic}}.
Keep it under {{max_words}} words.

Enter fullscreen mode Exit fullscreen mode

PromptCache auto-detects the variables and shows you a panel where you set types and defaults:

Variable Type Status Default
role string required
company string required
tone string optional “professional”
recipient string required
topic string required
max_words number optional 200

3. Publish a version

Click Publish to snapshot the current prompt. You’ll get a stable prompt-id to reference from your app. Every subsequent edit creates a new version — your running app keeps using the last published version until you explicitly update it.


Installing the SDK

npm install @optiqlabs/promptcache-sdk

Enter fullscreen mode Exit fullscreen mode

The SDK is a full TypeScript client with typed responses and IntelliSense support. No hardcoded prompt strings in your codebase — ever.


Fetching and Invoking Prompts

Here’s the complete flow from initialization to resolved prompt string:

import { PromptCacheClient } from '@optiqlabs/sdk';

// Initialize once, reuse across your app
const client = new PromptCacheClient({
  apiKey: process.env.PROMPTCACHE_API_KEY, // 'pk_live_...'
  baseUrl: 'https://api.promptcache.app',
});

// Invoke a prompt by ID, passing variable values
const result = await client.prompts.invoke('your-prompt-id', {
  role: 'Senior Engineer',
  company: 'Acme Corp',
  recipient: 'the product team',
  topic: 'the new deployment pipeline',
  tone: 'professional',
  max_words: 150,
});

// result.rendered → fully resolved prompt string, ready to send to any LLM
console.log(result.rendered);

Enter fullscreen mode Exit fullscreen mode

result.rendered is the fully hydrated prompt — pass it directly to OpenAI, Anthropic, Gemini, or any other LLM API.

Full integration with an LLM

import { PromptCacheClient } from '@optiqlabs/sdk';
import Anthropic from '@anthropic-ai/sdk';

const promptCache = new PromptCacheClient({
  apiKey: process.env.PROMPTCACHE_API_KEY,
  baseUrl: 'https://api.promptcache.app',
});

const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });

async function generateEmail(params: {
  role: string;
  company: string;
  recipient: string;
  topic: string;
}) {
  // 1. Fetch + resolve the prompt from PromptCache
  const { rendered } = await promptCache.prompts.invoke('email-generator-v2', {
    ...params,
    tone: 'professional',
    max_words: 200,
  });

  // 2. Send resolved prompt to your LLM of choice
  const message = await anthropic.messages.create({
    model: 'claude-sonnet-4-20250514',
    max_tokens: 1024,
    messages: [{ role: 'user', content: rendered }],
  });

  return message.content[0].text;
}

Enter fullscreen mode Exit fullscreen mode

Now when your AI engineer improves the email prompt, they publish a new version in PromptCache — no code change, no redeployment needed. The app picks it up on the next invocation.


Typed Variables in Practice

Variables are the core of PromptCache’s power. Let’s look at how types and defaults work.

Required vs Optional

When you invoke a prompt, the SDK will surface TypeScript errors if you omit a required variable:

// ❌ TypeScript error: missing required variable 'role'
const result = await client.prompts.invoke('email-generator-v2', {
  company: 'Acme Corp',
  recipient: 'the board',
  topic: 'Q2 results',
});

// ✅ Correct — all required fields provided
const result = await client.prompts.invoke('email-generator-v2', {
  role: 'CFO',
  company: 'Acme Corp',
  recipient: 'the board',
  topic: 'Q2 results',
  // 'tone' and 'max_words' use their defaults
});

Enter fullscreen mode Exit fullscreen mode

Inject Mode for UI Forms

PromptCache’s Inject Mode identifies which variables are missing and returns them, making it trivial to build dynamic forms. If a user fills in a form and forgets a field, you can surface exactly what’s missing before making the API call.

const { missingVariables } = await client.prompts.getVariables('email-generator-v2');
// → ['role', 'recipient', 'topic']
// Use this to render the right form fields dynamically

Enter fullscreen mode Exit fullscreen mode


Versioning and Rollbacks

Every time you publish a prompt in PromptCache, a snapshot is created — like a Git commit. This means:

  • You always know what prompt your production app is running
  • You can roll back to any previous version instantly from the dashboard
  • Your team can review prompt diffs before publishing

Pinning a specific version

By default, invoke() uses the latest published version. You can also pin to a specific version:

// Pin to a specific published version
const result = await client.prompts.invoke('email-generator-v2', variables, {
  version: '3', // use version 3 specifically
});

Enter fullscreen mode Exit fullscreen mode

This is useful for A/B testing different prompt versions, or for gradually rolling out a new prompt.


Scoped API Keys

PromptCache uses scoped API keys — you don’t hand out a single master key to every service. Instead, you create purpose-specific keys:

Scope What it can do
read Fetch and invoke prompts
write Create and update prompts
org:read Read all prompts across the org

For a production app that only invokes prompts, create a read-scoped key. This limits blast radius if a key leaks.

// Production service — read-only key
const client = new PromptCacheClient({
  apiKey: process.env.PROMPTCACHE_READ_KEY, // 'pk_live_read_...'
  baseUrl: 'https://api.promptcache.app',
});

Enter fullscreen mode Exit fullscreen mode

Manage and rotate keys from the Settings → API Keys panel in your workspace.


REST API Usage

If you’re not using TypeScript, or you’re in a backend language like Python, Go, or Ruby, the REST API has you covered.

Invoke a prompt via curl

curl -X POST https://api.promptcache.app/v1/prompts/email-generator-v2/invoke \
  -H "Authorization: Bearer pk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "variables": {
      "role": "Senior Engineer",
      "company": "Acme Corp",
      "recipient": "the product team",
      "topic": "the new CI pipeline",
      "tone": "professional",
      "max_words": 150
    }
  }'

Enter fullscreen mode Exit fullscreen mode

Response:

{
  "promptId": "email-generator-v2",
  "version": "4",
  "rendered": "You are a Senior Engineer at Acme Corp. Write a professional email to the product team about the new CI pipeline. Keep it under 150 words.",
  "variables": {
    "role": "Senior Engineer",
    "company": "Acme Corp",
    "recipient": "the product team",
    "topic": "the new CI pipeline",
    "tone": "professional",
    "max_words": 150
  }
}

Enter fullscreen mode Exit fullscreen mode

Fetch prompt metadata

curl https://api.promptcache.app/v1/prompts/email-generator-v2 \
  -H "Authorization: Bearer pk_live_..."

Enter fullscreen mode Exit fullscreen mode

For full API reference, visit docs.promptcache.app.


Real-World Example

AI Email Feature (Next.js API Route)

Let’s put it all together. Here’s a Next.js API route that powers an AI email drafting feature:

// app/api/draft-email/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { PromptCacheClient } from '@optiqlabs/sdk';
import Anthropic from '@anthropic-ai/sdk';

const promptCache = new PromptCacheClient({
  apiKey: process.env.PROMPTCACHE_API_KEY!,
  baseUrl: 'https://api.promptcache.app',
});

const anthropic = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY!,
});

export async function POST(req: NextRequest) {
  const { role, company, recipient, topic, tone, maxWords } = await req.json();

  // Validate required fields
  if (!role || !company || !recipient || !topic) {
    return NextResponse.json(
      { error: 'Missing required fields' },
      { status: 400 }
    );
  }

  try {
    // Step 1: Resolve the prompt from PromptCache
    const { rendered, version } = await promptCache.prompts.invoke(
      'email-generator-v2',
      {
        role,
        company,
        recipient,
        topic,
        tone: tone ?? 'professional',
        max_words: maxWords ?? 200,
      }
    );

    // Step 2: Send to LLM
    const message = await anthropic.messages.create({
      model: 'claude-sonnet-4-20250514',
      max_tokens: 1024,
      messages: [{ role: 'user', content: rendered }],
    });

    const draft = message.content[0].type === 'text'
      ? message.content[0].text
      : '';

    return NextResponse.json({
      draft,
      promptVersion: version, // useful for debugging / audit logs
    });
  } catch (err) {
    console.error('PromptCache or LLM error:', err);
    return NextResponse.json(
      { error: 'Failed to generate email' },
      { status: 500 }
    );
  }
}

Enter fullscreen mode Exit fullscreen mode

Notice that promptVersion is returned to the client — you can log this alongside every AI response to know exactly which prompt version produced each output. This is invaluable when debugging regressions.


Team Workflow

Here’s how a typical team uses PromptCache day-to-day:

1. Create — An AI engineer writes a prompt template with {{variables}}, which are auto-detected. They set required fields and sensible defaults.

2. Publish — They snapshot a version, share it in the gallery (public or private), or hand off the prompt ID to the engineering team.

3. Integrate — A developer drops client.prompts.invoke('prompt-id', variables) into the app. No hardcoded strings.

4. Track — The team monitors usage, API key activity, and audit logs from the dashboard. They can see which prompt versions are getting the most invocations.

5. Iterate — Someone improves the prompt. They publish a new version. The app picks it up automatically — zero redeployment.

Additional team features:

  • Bulk CSV Import — migrate your existing prompt library in one shot
  • Admin Safeguards — role-based access controls to prevent accidental overwrites
  • Open-in-AI Deep Links — one-click to pre-fill ChatGPT, Claude, or Gemini for quick testing

Community Gallery

PromptCache includes a public gallery where teams can share prompt templates. Each gallery card shows the prompt’s variables, a category tag, and two actions:

  • Copy — grab the prompt as-is
  • Fork — copy it into your own workspace and customize it

The gallery already includes templates like Cold Email Generator ({{company}}, {{pain_point}}, {{your_solution}}), Code Review Assistant ({{language}}, {{review_type}}), and Blog Post Outline ({{format}}, {{topic}}, {{audience}}).

This means your team doesn’t start from a blank slate — you fork a battle-tested community prompt, customize the variables for your use case, and ship faster.


When Should You Use PromptCache?

PromptCache is the right choice when:

  • You have more than one developer touching AI prompts (coordination problem)
  • You’re iterating on prompts regularly and need history + rollback
  • You want to separate prompt content from application code (no redeploys for prompt tweaks)
  • You need audit logs — compliance, debugging, or customer success teams asking “what prompt generated this output?”
  • You’re building multi-tenant apps where prompt variables change per customer

It’s less critical for solo projects with a single, static system prompt — though even there, versioning pays dividends the moment you want to experiment.


Join the Beta

PromptCache is currently in invite-only beta. Beta access is granted within 24 hours of your request.


Wrapping Up

The prompt is the most important part of your AI feature — it deserves the same engineering discipline as your application code. PromptCache brings versioning, typed variables, collaboration, and a clean SDK to prompt management, so your team ships faster and with more confidence.

Key takeaways:

  • Install with npm install @optiqlabs/promptcache-sdk
  • Initialize PromptCacheClient once with your scoped API key
  • Call client.prompts.invoke('prompt-id', variables) and get back result.rendered
  • Pass that string directly to any LLM — no prompt logic lives in your codebase
  • Iterate on prompts in the dashboard, publish new versions, and your app updates without a redeploy

If you’re building AI features for a team, give PromptCache a try. The “which version did you use?” question should never come up again.


Have questions or built something cool with PromptCache? Drop a comment below.

Tags: #ai #devtools #typescript #llm #promptengineering #openai #anthropic #javascript #webdev #programming