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

Similar Posts