AI prompt libraries: file system, database, or hard-coded?

3-365 Just another day at the library. - Flickr - ginnerobot.jpg

Written by

in

The newsletter for newsletter operators

Daily field notes on deliverability, AI tools, hosting, and monetisation. No "top 10 plugins" filler — real tools, real numbers, real failures.

AI prompt libraries: file system, database, or hard-coded?
Photo: Ginny from USA via Wikimedia Commons (CC BY-SA 2.0)

Once you move past ad-hoc copy-paste prompts and start running AI tasks in production—content outlines, email subject-line variants, metadata generation—you need somewhere to keep the templates. Three common patterns emerge: file system, database, or hard-coded strings in your application code. Each trades off versioning ease, deployment friction, and team access differently.

File system: Git history as your version log

Storing prompts as plain-text files—.txt, .md, or .json—in a /prompts directory gives you Git history for free. Every edit, rollback, and branch lives in version control alongside your code. If a new template tanks your output quality, you diff the commit and revert.

This works well for solo operators and small teams who already live in a code editor. You can structure files by task (subject-line.txt, outline.txt) or by model (claude-rewrite.txt). Your application reads the file at runtime or caches it in memory. Deployment is a git pull and restart.

The downside: non-technical team members can’t edit prompts without opening a pull request or SSH-ing into a server. If you want a marketing person to tweak tone without touching code, file storage adds friction.

Database: runtime editing and A/B tests

Storing prompts in a database table—id, name, version, body, created_at—lets you update templates through an admin UI without redeploying. You can run A/B tests by flagging two versions active and routing requests randomly, then compare output quality or conversion rates.

Versioning requires deliberate schema design. A simple approach: never update rows; instead insert a new row with an incremented version integer and a is_active boolean. Your application queries WHERE name = ? AND is_active = TRUE. To roll back, toggle the boolean on the previous version.

Database storage fits teams where non-engineers need prompt access, or where you iterate fast and deploy infrequently. The trade-off: you lose Git’s diff and blame tools unless you export snapshots to version control periodically. If your database backup schedule lags, you risk losing prompt history.

Hard-coded: when simplicity beats flexibility

Embedding prompts directly in code as string constants—const OUTLINE_PROMPT = "..."—removes external dependencies. No file I/O, no database query. The prompt is compiled into your binary or bundled into your script. If the task is stable and the template hasn’t changed in months, hard-coding reduces moving parts.

This pattern works for narrowly scoped tools: a WordPress plugin that generates alt text, a CLI that summarizes RSS feeds. The moment you need variants or frequent iteration, hard-coded strings become a deployment bottleneck. Every tweak requires a code change, test, and push.

One non-obvious use: hard-code your system prompts (the instructions that set model behavior globally) and store task-specific user prompts externally. System prompts rarely change; user prompts evolve with your content strategy. Splitting them keeps stable config in code and flexible templates in files or database.

Hybrid: configuration meets content

Many production setups combine approaches. Store system prompts and model parameters (temperature, max tokens) in environment variables or a config file; keep user-facing templates in the database with an admin UI. Version-control a nightly export of active prompts as a backup and audit trail.

If you use Claude for multiple tasks—say, newsletter intro rewrites and social-post generation—namespace your prompts by feature (newsletter_intro_v3, social_post_v2) and log which version ran for each job. When output quality shifts, you can trace it to a prompt change rather than guessing.

For solo operators just starting: begin with files in Git. Upgrade to database storage when a second person needs editing access or when you’re testing three variants of the same template in parallel. Reserve hard-coding for the smallest, most stable utilities.

Got a question about tooling, infrastructure, or online-business workflows? Reply to this email—we answer reader questions every Sunday.

Heads up — some links in this article are affiliate links. If you sign up through them, we may earn a small commission at no extra cost to you. We only recommend tools we use ourselves.

The newsletter for newsletter operators

Daily field notes on deliverability, AI tools, hosting, and monetisation. No "top 10 plugins" filler — real tools, real numbers, real failures.

Other newsletters you might like

Irish Rugby Fans

The best Irish rugby updates, straight to your inbox — Six Nations, the Nations Championship and the provinces. Only when there's something worth reading.

Subscribe

Love California

Love California — in your inbox The Pacific Coast Highway, national parks, beaches, wine country and the best places to visit in California. One short email, every day.

Subscribe

Springbokfans

The best Springbok updates, straight to your inbox. Only when something worth reading actually happens.

Subscribe

Love Spain

Love Spain — in your inbox. Iconic cities, hidden pueblos and the best places to visit in Spain. One short email, every day.

Subscribe

Newsletters via the One Two Three Send network.  ·  Want your newsletter featured here? Click here