This content originally appeared on DEV Community and was authored by alingse
We've all been there. You're deep in a terminal session, wrestling with a complex problem. You turn to an AI assistant like Google's Gemini or Anthropic's Claude directly in your CLI. After a few prompts, you strike gold—a perfect code snippet, a brilliant debugging strategy, or a complex command you'll need again.
Then... you close the terminal. Or you scroll up, but the buffer is gone. That stroke of genius is lost to the digital ether. Frustrating, right?
What if you could have a perfect, replayable, and—most importantly—intelligently-named log of every single one of these sessions?
That's exactly why I created ai-cli-log
.
What is ai-cli-log?
ai-cli-log
is a command-line tool that wraps your terminal commands, seamlessly recording everything from your input to the AI's rendered output. It's designed to be a "fire-and-forget" solution to a problem many developers face daily.
It’s built with Node.js and TypeScript, and it leverages some clever tech to ensure the logs are not just text dumps, but faithful representations of what you actually saw on screen.
The Magic: Not Just Logging, but Smart Logging
Here’s what makes ai-cli-log
more than just another script redirecting stdout to a file.
1. Lossless, Interactive Session Capture
Modern CLIs are complex. They have spinners, progress bars, and dynamic prompts that rewrite the screen. A simple >
redirect misses all of that.
ai-cli-log
uses node-pty
to create a pseudo-terminal (pty) and @xterm/headless
to run a headless terminal emulator. This means it interprets all the ANSI escape codes for colors, cursor movements, and screen clearing. The final log file is a pristine record of the rendered output, looking exactly like it did in your live session.
2. AI-Powered Filenames
This is the killer feature. A folder full of session-20250715-103000.txt
isn't very helpful. ai-cli-log
can use an AI to summarize your session and create a descriptive, human-readable filename.
Imagine turning this:
gemini-20250715-103215.txt
Into this:
gemini-20250715-103215-refactor-database-schema-with-migrations.txt
Now you can find the exact session you're looking for with a simple file search.
Getting Started in 60 Seconds
Ready to try it? It's simple.
1. Installation
npm install -g ai-cli-log
2. Basic Logging
Just prefix the command you want to run with ai-cli-log run
.
ai-cli-log run gemini
After you exit the Gemini session, you'll find a new log file in a .ai-cli-log
directory in your project folder.
╭───────────╮
│ > /quit │
╰───────────╯
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Agent powering down. Goodbye! │
│ │
│ Performance │
│ Wall Time: 4.7s │
│ Agent Active: 0s │
│ » API Time: 0s (0.0%) │
│ » Tool Time: 0s (0.0%) │
│ │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Session logged to .ai-cli-log/gemini-20250715-083847.txt
3. Enable AI Summaries
To get those smart filenames, use the -s
(--with-summary
) flag.
# Use the default summarizer
ai-cli-log -s run gemini
# Specify a summarizer (more on this below)
ai-cli-log --by gemini-pro run gemini
Now, when your session ends, ai-cli-log
will send the transcript to your configured AI, get a summary, and use it in the filename.
(Session content long, sampling first and last 50 lines for summary)
Summary by ollama (took 13.9s): "interaction-summary"
Session logged to .ai-cli-log/gemini-20250715-083306-interaction-summary.txt
Configuration: Make It Your Own
ai-cli-log
is designed to be flexible. You can configure different AI backends, prompts, and models.
Run the interactive setup to get started:
ai-cli-log init
This command will scan for installed AI tools (gemini
, ollama
, sgpt
, etc.) and create a config.json
file for you, either globally (~/.config/ai-cli-log/
) or locally (./.ai-cli-log/
).
Here’s a peek at what the configuration looks like:
{
"summarizer": {
"default": "gemini-pro",
"summarizers": [
{
"name": "gemini-pro",
"tool": "gemini",
"prompt": "You are a log summarizer. Your response MUST be a valid JSON object with one key: "summary" (a 3-5 word, lowercase, filename-friendly phrase). Example: {"summary": "refactor-database-schema"}. The session content is:",
"maxLines": 100
},
{
"name": "ollama-llama3",
"tool": "ollama",
"model": "llama3",
"prompt": "..."
}
]
}
}
You can define multiple "summarizers" and easily switch between them using the --by <name>
flag.
Final Thoughts
ai-cli-log
was born from a personal need, but it solves a universal problem for anyone working with AI in the terminal. It’s a small utility that has a massive impact on workflow, turning transient conversations into a permanent, searchable knowledge base.
Give it a try and never lose a great idea again.
Check out the project on GitHub: https://github.com/alingse/ai-cli-log
Happy coding!
This content originally appeared on DEV Community and was authored by alingse

alingse | Sciencx (2025-07-15T00:39:26+00:00) Supercharge Your CLI Workflow: Never Lose a Genius AI-Powered Idea Again with ai-cli-log. Retrieved from https://www.scien.cx/2025/07/15/supercharge-your-cli-workflow-never-lose-a-genius-ai-powered-idea-again-with-ai-cli-log/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.