Never Lose Coding Progress Again: How I Built a Hybrid Auto-Logger for VS Code
---
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