Welcome to the Wrtr tools! This suite automates markdown blog post creation using OpenAI, research using Perplexity, AI-powered image generation using OpenAI, and hero image replacement for any mistakes. All written in Typescript. Everything is modular, robust, and easy to use. 🚀
- writeforme.ts – Fully automates blog post creation (research, writing, metadata, hero image)
- generateimages.ts – Generate custom AI images for any description
- replaceimage.ts – Instantly replace the hero image of your latest blog post
- setup/wrtr.config.md – Centralized config for all company info, file and directory paths, and blog frontmatter (edit this to update settings!)
- setup/main-prompt.txt – The main prompt template for AI calls (edit this to change prompt style or instructions)
- setup/system-prompts/ – All other prompt templates (advanced, rarely edited) and the config loader
-
Install dependencies:
- From the project root:
pnpm install(installs everything for the monorepo) - Or, from inside
wrtr/:pnpm install(installs just the wrtr tool dependencies)
- From the project root:
-
Environment variables: Create a
.envfile in the project root (orwrtr/):OPENAI_API_KEY=sk-... PERPLEXITY_API_KEY=pxy-...
Both are required for full automation. (You can skip Perplexity with a flag.)
-
Check & update config:
- All project, company, and blog settings are now in
setup/wrtr.config.mdas a friendly markdown file with YAML frontmatter. - To update company info, blog paths, or frontmatter defaults, just edit this file!
- No need to touch any TypeScript files for config anymore.
- All project, company, and blog settings are now in
You can run scripts from the project root (with pnpm exec tsx ...) or from inside the wrtr/ folder using the provided scripts:
pnpm exec tsx writeforme.ts "Your Blog Title" "A short description of your blog post." [keywords] [--skip-perplexity]-
Arguments:
- Blog Title (optional)
- Blog Description (optional)
- Keywords (optional)
--skip-perplexity(optional): Skip research step for faster draft
-
What it does:
- Researches your topic (Perplexity, unless skipped)
- Generates a markdown blog post (OpenAI)
- Extracts metadata (title, description, image prompt)
- Saves
.mdxinblog/or where ever it's set up. - Generates a hero image and saves as
.webpinblog-images/or where ever it's set up.
pnpm exec tsx generateimages.ts "A dreamy wedding venue at sunset" "A vintage camera on a table" "A bouquet of wildflowers"- Each argument is a separate image description.
- Images are saved as
.webpinimages/or where ever it's set up. - Prompts are styled using
setup/wrtr.config.md.
pnpm exec tsx replaceimage.ts "A new description for the hero image" [path/to/image.webp]- Finds the most recently modified
.mdxinblog/(unless you specify an image path) - Generates a new hero image using your description
- Overwrites the old image in
blog-images/(or at the path you specify)
- Research: Calls Perplexity API to get a research summary and citations for your topic (unless skipped).
- Article Generation: Uses OpenAI to generate a long-form markdown article based on the research.
- Metadata Extraction: Extracts title, description, and image prompt from the article.
- MDX File Creation: Saves the article as an
.mdxfile inblog/or where ever it's set up with proper frontmatter. - Image Generation: Generates a webp illustration and saves it in
blog-images/or where ever it's set up.
- All config is in
setup/wrtr.config.mdas YAML frontmatter in a markdown file. - This includes company info, blog/image directory paths, the image promtp and default blog frontmatter fields.
- To update anything, just edit this file!
- The loader at
setup/system-prompts/config-loader.tsreads this config and makes it available to all scripts.
To help you get started safely, this repo includes example config and prompt files:
setup/wrtr.config.example.mdsetup/main-prompt.example.txt
How to use:
- Copy or rename
setup/wrtr.config.example.mdtosetup/wrtr.config.mdand fill in your company/blog details. - Copy or rename
setup/main-prompt.example.txttosetup/main-prompt.txtand customize your main prompt style.
Note: The real config and prompt files are ignored by git, so your sensitive info stays private! 🎉
- Prompt templates: Edit
setup/main-prompt.txtfor the main prompt style or instructions for the AI. - Image style: Edit
setup/wrtr.config.mdto change the look, mood, or art direction of your generated images. - Advanced prompt templates (for metadata, research, images) live in
setup/system-prompts/and rarely need editing.
- Use clear, vivid descriptions for best image results (e.g., "A dreamy clock melting into a soft sunrise, symbolizing time and new beginnings").
- If you see an error about missing frontmatter or image, check your latest blog post for the correct fields.
- The script only updates the image—it does not change the blog content or frontmatter.
- Make sure your API keys are valid and have enough quota.
- If you see errors about missing dependencies, run
pnpm installagain. - For debugging, check the console output for detailed logs and error messages.
- If you ever see a
dquote>orquote>prompt:- This means your shell thinks a quote is unclosed (for example, you started a string with a double or single quote but didn't close it).
- This can happen if you copy-paste commands and miss a quote, or if your arguments contain special characters.
- How to fix:
- Press
Ctrl+Cto cancel the current command prompt. - Double-check your command for any missing or mismatched quotes.
- Prefer using single quotes (
') around arguments, especially if your text contains spaces or special characters. - Example:
pnpm exec tsx writeforme.ts 'How to take great photos' 'A guide for beginners.'
- Press
- This is a shell/terminal thing, not a bug in the script! :)
- Use
--skip-perplexityfor a faster run or if you don't need research/citations.
- This script is designed for use with an MDX blog setup.
- All code follows clean code and modularity best practices.
- If you want to customize prompts or output, check the
wrtr/setup/system-prompts/directory.