redline-ai
v0.2.0
Published
Inline AI editing for local Markdown files
Readme
redline-ai
Edit your docs while reading them.
The Problem
Fixing a document always means switching between two modes: reading and editing. You read the rendered output, spot something wrong, switch to your editor, find the line, fix it, switch back to the preview, and repeat. The context switch is small but constant, and it adds up.
What redline-ai Does
redline-ai lets you preview local Markdown files in the browser and edit them right there. Select any text, tell the AI what to change, review the diff, and apply it. The source file is updated on disk. No copy-pasting, no switching windows.
$ npx redline-ai serve ./docsOpen http://localhost:4321, and you're reading your docs with editing powers.
How It Works
- Select any text in the rendered preview
- Click the "AI Edit" button that appears
- Describe what you want changed (e.g. "make this more concise", "translate to English")
- Review the diff showing exactly what will change
- Apply or Reject
The source Markdown file is rewritten on disk. The preview refreshes automatically.
Who It's For
- Writers editing blog posts, READMEs, or documentation
- Anyone with an Obsidian vault, Hugo site, or plain Markdown folder
- Developers who want to proofread rendered output, not raw markup
Use Cases
Phone-first editing with Happy Coder
Reading on your phone helps things stick. With --host 0.0.0.0, redline-ai is accessible from any device on your local network.
$ npx redline-ai serve ./docs --host 0.0.0.0Open the URL on your phone, read through the rendered docs, and edit inline. Pair this with Happy Coder -- a mobile client for Claude Code -- to generate drafts from your phone, then polish them directly in redline-ai.
Two Modes
Standalone (serve)
redline-ai renders your Markdown files itself. Point it at any directory.
$ npx redline-ai serve ./docs
$ npx redline-ai serve ~/obsidian-vault
$ npx redline-ai serve .Proxy (proxy)
Already running a dev server (Astro, Next.js, etc.)? redline-ai sits in front of it, injecting the editing overlay into your existing site.
$ npx redline-ai proxy --target http://localhost:3000 --root ./src/content --config redline.tomlConfigure URL-to-file mapping in redline.toml:
[proxy]
target = "http://localhost:3000"
root = "./src/content"
[[proxy.routes]]
pattern = "/blog/:slug"
file = "blog/:slug.mdx"
[[proxy.routes]]
pattern = "/docs/:path*"
file = ":path.md"Features
- Live preview with syntax-highlighted code blocks
- AI-powered inline editing via Claude Code
- Diff review before any change hits disk
- Session memory -- the AI remembers earlier edits in the same file
- Hot reload -- file changes refresh the browser automatically
- Multiple edits -- open several edit panels at once without losing any
- Framework-agnostic -- works with any Markdown directory or existing dev server
Requirements
- Node.js 22+
- Claude Code CLI installed and authenticated
Note: redline-ai currently uses Claude Code as the AI backend. Other AI agent CLIs are not supported yet.
Install
npm install -g redline-aiOr run directly:
npx redline-ai serve ./docsCLI
redline-ai serve <dir> # Preview and edit Markdown files
--port <port> # Port number (default: 4321)
--host <host> # Host to bind (default: 127.0.0.1, use 0.0.0.0 for LAN)
--config <path> # Config file (default: redline.toml)
--open # Open browser automatically
redline-ai proxy # Proxy an existing dev server
--target <url> # Target server URL
--root <dir> # Source file directory
--config <path> # Config file (default: redline.toml)
--port <port> # Port number (default: 4321)
--host <host> # Host to bind (default: 127.0.0.1, use 0.0.0.0 for LAN)Customizing AI Prompts
You can customize the prompts sent to Claude by adding an [agent] section to redline.toml:
[agent]
prompt_first_call = """
You are a technical editor. Here is the full document:
<article>
{{fullSource}}
</article>
Edit L{{startLine}}-{{endLine}}:
<target>
{{target}}
</target>
{{selectionContext}}
Instruction: {{instruction}}
Return only the modified target text.
"""
prompt_subsequent_call = """
Edit L{{startLine}}-{{endLine}} of the same document:
<target>
{{target}}
</target>
{{selectionContext}}
Instruction: {{instruction}}
Return only the modified target text.
"""Available template variables:
| Variable | Description |
|---|---|
| {{fullSource}} | Full document content |
| {{target}} | The matched source text to edit |
| {{startLine}} | Start line number |
| {{endLine}} | End line number |
| {{instruction}} | User's edit instruction |
| {{selectionContext}} | Additional context when a sub-selection is made |
If omitted, built-in default prompts are used.
License
MIT
