---
A simple, offline-first script that auto-documents your coding sessions — per project and per file — so you never lose context or work again.
---
# 🚀 Never Lose Coding Progress Again: How I Built a Hybrid Auto-Logger for VS Code
> **"I was debugging for hours… then my Mac froze. All that work — gone."**
That moment has haunted me more than once.
We’ve all been there:
- You’re deep in the zone, refactoring a complex function.
- Your internet cuts out mid-push.
- Your laptop kernel panics.
- Or worse — you just *forget* what you did yesterday.
And when you come back?
You’re staring at code like, _“Wait… why did I change this?”_
GitHub Copilot doesn’t remember.
Your brain is foggy.
And `git log` only tells part of the story.
So I built a **hybrid auto-logger** that silently documents:
- ✅ **What project** I’m working on
- ✅ **Which file** I’m editing
- ✅ **How long** I’ve been active
- ✅ All **without internet**, and even if my Mac dies
And best of all? It runs in the background — **zero effort required**.
Let me show you how.
---
## 💡 The Problem: We Code, But We Don’t Document
We use AI. We commit code. But we rarely capture the *process*.
We jump between files, tweak logic, debug edge cases — but unless we write notes or commit with good messages, that context vanishes.
And if your machine fails? Good luck reconstructing a full day of work.
So I asked:
> **"What if my editor could quietly journal my progress — automatically?"**
---
## 🛠️ The Solution: A Silent Dev Logger for VS Code (macOS)
I built a lightweight script that:
- Runs every 10 minutes via `cron`
- Logs **project-wide activity**
- Detects your **active file in VS Code** using AppleScript
- Writes clean, readable logs to `.devlogs/`
- Works **100% offline**
No internet? No problem.
Mac dies? I can recover my workflow.
Back from vacation? I can pick up right where I left off.
It’s like a **black box for developers**.
---
## 📁 How It Works
The system uses:
- A **Bash script** (runs quietly)
- **Cron** (scheduling)
- **AppleScript** (to read VS Code’s active file)
- Simple **Markdown-style logs**
### Folder Structure
my-project/
├── .devlogs/
│ ├── project.log # Overall progress
│ ├── auth.js.devlog # File-specific log
│ └── cron.log # Script logs
├── hybrid-devlog.sh # The magic script
└── ...
---
## 📝 Sample Logs
### `project.log` — Your Daily Pulse
markdown
2025-04-05
- ⏱️ 09:15:00: Session started
- ⏱️ 09:25:00: Still working...
- ⏱️ 09:35:00: Still working...
### `auth.js.devlog` — Deep Work on One File
markdown
Dev Log: auth.js
2025-04-05
- 09:15: Active edit session
- 09:25: Added JWT token refresh logic
These logs act like a **time machine** for your development process.
---
## 🚀 Step-by-Step: Set It Up in 5 Minutes
### 1. Create the Script
bash
touch hybrid-devlog.sh
chmod +x hybrid-devlog.sh
code hybrid-devlog.sh
### 2. Paste This Script
bash
!/bin/bash
=== CONFIGURATION ===
PROJECT_DIR="/your/project/path" # ← CHANGE THIS
PROJECT_NAME="My Project"
LOGS_DIR="$PROJECT_DIR/.devlogs"
PROJECT_LOG="$LOGS_DIR/project.log"
DATE=$(date +"%Y-%m-%d")
TIME=$(date +"%H:%M:%S")
TIMESTAMP="[$DATE $TIME]"
mkdir -p "$LOGS_DIR"
=== PER-PROJECT LOG ===
if [ ! -f "$PROJECT_LOG" ]; then
echo "# Development Log for '$PROJECT_NAME'" > "$PROJECT_LOG"
echo "" >> "$PROJECT_LOG"
fi
if ! grep -q "## $DATE" "$PROJECT_LOG"; then
echo "" >> "$PROJECT_LOG"
echo "## $DATE" >> "$PROJECT_LOG"
echo "- ⏱️ $TIME: Session started" >> "$PROJECT_LOG"
else
LAST_LINE=$(tail -n 1 "$PROJECT_LOG" | sed 's/.$//')
if [[ "$LAST_LINE" == "- ⏱️ " ]]; then
sed -i '' '$d' "$PROJECT_LOG"
echo "${LAST_LINE}.." >> "$PROJECT_LOG"
else
echo "- ⏱️ $TIME: Still working..." >> "$PROJECT_LOG"
fi
fi
=== PER-FILE LOG ===
FRONT_APP=$(osascript -e 'tell application "System Events" to get name of first application process whose frontmost is true')
if [[ "$FRONT_APP" == "Code" || "$FRONT_APP" == "Visual Studio Code" ]]; then
FILENAME=$(osascript -e '
tell application "Visual Studio Code"
try
return name of active document of front window
on error
return "untitled"
end try
end tell
' 2>/dev/null)
if [ ! -z "$FILENAME" ] && [ "$FILENAME" != "untitled" ]; then
FILE_LOG="$LOGS_DIR/${FILENAME//\//_}.devlog"
if [ ! -f "$FILE_LOG" ]; then
echo "# Dev Log: $FILENAME" > "$FILE_LOG"
echo "" >> "$FILE_LOG"
echo "## $DATE" >> "$FILE_LOG"
fi
if ! grep -q "## $DATE" "$FILE_LOG"; then
echo "" >> "$FILE_LOG"
echo "## $DATE" >> "$FILE_LOG"
fi
echo "- $TIME: Active edit session" >> "$FILE_LOG"
fi
fi
echo "$TIMESTAMP Hybrid devlog updated"
> 🔁 Don’t forget to update `PROJECT_DIR`!
### 3. Grant Permissions
Go to:
> **System Settings > Privacy & Security > Automation**
Allow your terminal (e.g. `Terminal`, `iTerm`) to control **Visual Studio Code**.
### 4. Schedule with Cron
bash
crontab -e
Add:
bash
*/10 * * * * /bin/bash /your/project/path/hybrid-devlog.sh >> /your/project/path/.devlogs/cron.log 2>&1
That’s it! It now runs every 10 minutes.
---
## 🎯 Why This Matters
This isn’t just about logging — it’s about **preserving context**.
- ✅ **Recover** from crashes with confidence
- ✅ **Document** your process without effort
- ✅ **Reflect** on where you spend time
- ✅ **Show progress** in standups or portfolios
- ✅ **Never** lose a day’s work again
It’s the closest thing to a **developer memory extender**.
---
## 🔄 What’s Next?
I’m extending this to:
- Auto-commit with smart messages
- Generate weekly reports
- Sync logs to Obsidian or Notion
- Detect idle time and pause logging
And yes — I’ll open-source it soon.
---
## 💬 Your Turn
Have you lost hours of work to a crash or bad connection?
Try this system. Tweak it. Make it yours.
And if you do — **let me know in the comments**. I’d love to hear how you’re using it.
Because coding isn’t just about the code.
It’s about the journey.
And now, I finally have a map.
---
## 🔗 Resources
- [GitHub Gist: hybrid-devlog.sh](https://gist.github.com/your-username/...) *(replace with your link)*
- [AppleScript Docs](https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html)
---
**Like this?**
Follow me for more dev tools, automation hacks, and ways to code smarter — not harder.
#vscode #productivity #automation #devjournal #beginners #macos #scripting #git #developerexperience
Top comments (1)
Never losing coding progress was my main goal, so I built a Hybrid Auto-Logger for VS Code that silently snapshots my work and makes it recoverable anytime. The idea is simple: every time I type or save, the extension captures changes and stores them in two layers. First, it writes quick checkpoints into a local storage folder inside the workspace for instant recovery even when offline. Second, it periodically mirrors those snapshots into cloud storage for redundancy, so even if the machine crashes or the project gets corrupted, my work is safe. To avoid bloat, snapshots are deduplicated with hashes, compressed over time, and old ones are automatically cleaned based on a retention policy. The system also provides a restore command inside VS Code, showing timestamps and diffs so I can roll back with a click. By combining fast local saves with secure cloud backups, this hybrid approach makes sure I never lose coding progress again.