Skip to main content
Scratch stores notes as plain Markdown files, making them accessible to any text editor or AI agent. The built-in file watcher automatically detects external changes and reloads notes in real-time.

Why Use External Editors?

  • AI coding agents - Claude Code, Cursor, Windsurf can read and edit your notes
  • Advanced text editing - Vim, Emacs, VS Code with custom extensions
  • Automation scripts - Process notes with Python, Node.js, shell scripts
  • Bulk operations - Rename, search/replace, or format multiple files at once
Scratch’s file watcher runs continuously when a notes folder is set. External changes appear in Scratch within 500ms (debounced per file).

File Watcher Implementation

Scratch uses the Rust notify crate to watch your notes folder for changes:

How It Works

  1. Recursive watching - Monitors the entire notes folder (up to 10 levels deep)
  2. Event debouncing - Groups rapid changes (500ms window per file)
  3. Change detection - Detects create, modify, and delete events
  4. Frontend notification - Emits file-change events to the UI
  5. Auto-reload - Reloads the current note if changed externally

What’s Watched

All .md files except those in excluded folders:
  • .git (Git metadata)
  • .scratch (App settings)
  • .obsidian (Obsidian vault)
  • .trash (Deleted notes)
  • assets (Images and attachments)
Create a .scratch/ folder in your notes directory to store app-specific data that won’t appear in Scratch’s note list.

Using External Text Editors

Quick Edit Workflow

1

Open in Editor

Right-click a note in Scratch’s sidebar and select Reveal in File Manager. Then open the .md file in your preferred editor.
2

Make Changes

Edit the note in your external editor and save (Cmd+S).
3

Auto-Reload in Scratch

Scratch detects the file change and shows a notification: “External changes detected.” Click Reload or press Cmd+R.
EditorBest ForSetup
VS CodeMarkdown extensions, AI pluginsInstall Markdown Preview Enhanced
Vim/NeovimKeyboard-driven editingUse markdown plugins like vim-markdown
Sublime TextFast, lightweight editingInstall Markdown Extended package
ObsidianGraph view, community pluginsOpen same folder as Scratch
iA WriterDistraction-free writingSet notes folder as library
Avoid concurrent edits: Don’t edit the same note in Scratch and an external editor simultaneously. The last save wins, potentially losing changes.

AI Agent Integration

Scratch works seamlessly with AI coding agents that can read and write files:

Claude Code (Anthropic)

Claude can read your notes, answer questions, and make edits:
# Ask Claude about your notes
claude "What are the main themes in my notes?"

# Edit a specific note
claude "Add a 'Next Steps' section to my Project Ideas note"

# Create a new note from a template
claude "Create a meeting notes file for today's standup"
Setup:
  1. Install Claude Code CLI from claude.ai
  2. Run claude in your notes folder
  3. Scratch auto-reloads when Claude saves changes

Cursor / Windsurf

AI-first code editors can edit notes like source code:
1

Open Notes Folder

In Cursor, select File → Open Folder and choose your notes directory.
2

Use AI Chat

Ask Cursor to edit notes:
"Add tags to all notes in the Archive folder"
"Reformat all meeting notes to use a consistent template"
3

Watch Changes in Scratch

Scratch detects file changes and reloads affected notes automatically.

GitHub Copilot Workspace

Use Copilot to generate note content:
  1. Open your notes folder in VS Code
  2. Create a new .md file
  3. Write a prompt as a comment: <!-- Generate a book summary for "Atomic Habits" -->
  4. Copilot generates the summary
  5. Save the file - Scratch adds it to the note list
Use AI agents for bulk operations (tagging, formatting, link extraction) and Scratch for daily writing (fast, focused, WYSIWYG).

Automation Scripts

Example: Daily Note Generator

Create daily notes automatically with a shell script:
#!/bin/bash
# daily-note.sh - Create a daily note with template

NOTES_DIR="$HOME/Documents/Notes"
DATE=$(date +"%Y-%m-%d")
FILE="$NOTES_DIR/Daily/$DATE.md"

mkdir -p "$NOTES_DIR/Daily"

cat > "$FILE" <<EOF
# Daily Note - $DATE

## Tasks
- [ ] Review yesterday's notes
- [ ] Plan today's priorities

## Notes

## Reflections

EOF

echo "Created daily note: $FILE"
Run daily:
chmod +x daily-note.sh
./daily-note.sh
Scratch detects the new file and adds it to the note list instantly.

Example: Markdown Linter

Fix markdown formatting across all notes:
# Install markdownlint-cli
npm install -g markdownlint-cli

# Lint and fix all notes
cd ~/Documents/Notes
markdownlint --fix '**/*.md'
Scratch reloads all modified notes automatically.

Example: Note Tagger (Python)

Add tags to notes based on content:
import os
import re
from pathlib import Path

NOTES_DIR = Path.home() / "Documents" / "Notes"

for note_file in NOTES_DIR.rglob("*.md"):
    content = note_file.read_text()
    
    # Skip if already has tags
    if "tags:" in content:
        continue
    
    # Extract keywords
    tags = []
    if "meeting" in content.lower():
        tags.append("meeting")
    if "project" in content.lower():
        tags.append("project")
    
    # Add tags as YAML frontmatter
    if tags:
        frontmatter = f"---\ntags: {', '.join(tags)}\n---\n\n"
        note_file.write_text(frontmatter + content)
        print(f"Tagged: {note_file.name}")
Run with:
python tag-notes.py
Scratch’s file watcher handles frontmatter changes gracefully. The editor shows the rendered note (frontmatter hidden), while source mode shows the raw YAML.

File Watcher Behavior

Reload Logic

When an external change is detected:
  1. Debounce check - Waits 500ms for additional changes to the same file
  2. Self-save detection - Ignores changes from Scratch’s own saves
  3. Notification - Shows “External changes detected” toast
  4. Auto-reload - If the changed note is currently open, shows reload prompt

Manual Reload

If auto-reload doesn’t trigger:
  • Single note: Press Cmd+R or click the Reload button (↻)
  • All notes: Close and reopen Scratch
  • Search index: Search automatically rebuilds on file changes
If you’re making many external changes at once (e.g., mass rename), close Scratch first to avoid excessive reloads. Reopen when done.

External Change Detection

Current Note Detection

Scratch shows a banner when the open note changes externally:
⚠️ This note was modified externally. [Reload] [Dismiss]
  • Reload - Fetches the latest content from disk (discards unsaved changes)
  • Dismiss - Keeps the current editor content (your version)
The note list refreshes automatically when:
  • A new .md file is created
  • A note is deleted externally
  • A note’s title (first # Heading) changes
Unsaved changes are lost if you reload while editing. Scratch auto-saves every 500ms, but rapid external changes can still cause conflicts.

Conflict Resolution

If you edit the same note in Scratch and externally:

Scenario 1: External Edit While Not Editing

Safe - Scratch reloads the note seamlessly

Scenario 2: External Edit While Editing

⚠️ Conflict - Scratch shows the reload banner. Choose:
  1. Reload - Accept external changes (lose your unsaved edits)
  2. Dismiss - Keep your version (save to overwrite external changes)

Scenario 3: Simultaneous Edits

Last save wins - No merge conflict UI. Use Git for version control if this is common.
Best practice: Use Scratch for interactive editing and external tools for batch operations. Avoid editing the same note simultaneously.

Combining Scratch with Obsidian

Many users run Scratch and Obsidian on the same notes folder:

Setup

1

Create Shared Folder

Create a folder for your notes (e.g., ~/Documents/Notes).
2

Open in Scratch

In Scratch, set this folder as your notes folder.
3

Open in Obsidian

In Obsidian, select Open folder as vault and choose the same folder.

What Works

  • Basic Markdown - Both editors support standard Markdown
  • Wikilinks - [[Note Title]] works in both
  • Images - Both use ![](assets/image.png) syntax
  • Frontmatter - YAML metadata is preserved

What Doesn’t Work

  • Obsidian plugins - Dataview, Templater, etc. are Obsidian-specific
  • Canvas files - Scratch doesn’t support .canvas format
  • Embedded queries - Obsidian’s query blocks won’t render in Scratch
Scratch focuses on fast, distraction-free writing. Use Obsidian for graph view, advanced queries, and community plugins.

Performance Considerations

Large Note Collections

The file watcher is optimized for thousands of notes:
  • Efficient recursion - Only watches note folders (excludes .git, etc.)
  • Debouncing - Prevents event spam from rapid saves
  • Incremental index updates - Search index updates per-file, not full rebuild

High-Frequency Edits

If an external tool edits files rapidly (e.g., live sync):
  • Debounce prevents thrashing - Multiple edits within 500ms are batched
  • Reload only if viewing - Sidebar updates don’t disrupt the editor

Disabling File Watching

File watching cannot be disabled (by design). If you need to pause it:
  1. Close Scratch
  2. Make bulk changes
  3. Reopen Scratch - notes and search index refresh on startup

Troubleshooting

”File watcher failed to start”

Cause: OS file descriptor limit exceeded (macOS/Linux). Fix: Increase the limit:
# macOS
ulimit -n 10240

# Linux (persistent)
echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Notes not auto-reloading

  1. Check file watcher status - Restart Scratch
  2. Verify file changes - Save the file in your external editor
  3. Manual reload - Press Cmd+R

High CPU usage

Cause: Too many file change events (e.g., live sync). Fix: Exclude the sync folder from Scratch’s notes folder or disable live sync temporarily.

Best Practices

  1. Close before bulk operations - Avoid overwhelming the file watcher
  2. Use Git for versioning - External edits don’t create undo history in Scratch
  3. Test on a subset first - When running automation scripts, test on a few notes
  4. Keep backups - External tools can corrupt files; Git or Time Machine saves the day
  5. Communicate intent - If using AI agents, review changes before closing Scratch
Create a “Scratch + AI” workflow: Use Scratch for daily writing, Claude for summarization/tagging, and Git for version control.

Build docs developers (and LLMs) love