Add contextual notes to your code with full version history and intelligent tracking. Notes stay with your code even when line numbers change.
Working on complex codebases, developers face a common dilemma:
Traditional Code Comments:
- ❌ Clutter your source files with non-code content
- ❌ Get committed to version control, polluting git history
- ❌ Mix documentation with implementation
- ❌ No version history for the comments themselves
- ❌ Can't be easily filtered or searched separately
External Documentation:
- ❌ Quickly becomes outdated as code changes
- ❌ Disconnected from the actual code location
- ❌ Requires context switching between editor and docs
- ❌ Hard to maintain alignment with code
The result? Important context gets lost, technical debt goes undocumented, and new team members struggle to understand why code exists the way it does.
Code Context Notes provides a third way: contextual annotations that live alongside your code without being part of it.
✅ Non-invasive - Notes stored separately in .code-notes/ directory, never touching your source files
✅ Intelligent tracking - Notes follow your code even when you move, rename, or refactor it
✅ Multiple notes per line - Add multiple annotations to the same code with easy navigation
✅ Workspace sidebar - Dedicated Activity Bar panel showing all notes organized by file
✅ Complete history - Every edit preserved with timestamps and authors
✅ Team collaboration - Share notes by committing .code-notes/ or keep them local with .gitignore
✅ Native integration - Uses VSCode's comment UI for a familiar, seamless experience
✅ Markdown support - Rich formatting with keyboard shortcuts
✅ Zero performance impact - Efficient caching and content hash tracking
Perfect for:
- 📝 Documenting technical debt and TODOs
- 🎓 Onboarding new developers with contextual explanations
- 💡 Recording implementation decisions and trade-offs
- 🔍 Leaving breadcrumbs for future refactoring
- 🤝 Team knowledge sharing without code pollution
- Open VSCode
- Go to Extensions (Ctrl+Shift+X)
- Search for "Code Context Notes"
- Click Install
code --install-extension jnahian.code-context-notesAvailable on Open VSX Registry for VS Codium users.
- Add notes using VSCode's native comment UI
- CodeLens indicators show where notes exist
- Multiple notes per line - Add unlimited annotations to the same code location
- Icon-only navigation buttons for switching between multiple notes
- Markdown formatting with keyboard shortcuts (Ctrl/Cmd+B, I, K)
- Inline editing with Save/Cancel buttons
- Notes follow code content even when line numbers change
- Content hash tracking detects moved code
- Automatic position updates on document changes
- Full audit trail of all note modifications
- View history directly in the comment thread
- Never lose context - all edits preserved with timestamps
- Notes stored as markdown files in
.code-notes/directory - One file per note, named by note ID
- Easy to read, search, and version control
- Automatic author detection using git username
- Fallback to system username
- Override via configuration
Method 1: From Code
- Select code you want to annotate (or just place cursor on a line)
- Press
Ctrl+Alt+N(orCmd+Alt+Non Mac) - Type your note with markdown formatting
- Click Save or press
Ctrl+Enter
Method 2: From Sidebar
- Click the Code Notes icon in the Activity Bar
- Click the + button in the sidebar toolbar
- Type your note and save
That's it! A CodeLens indicator appears above your code, and the note shows in the sidebar.
Method 1: Keyboard Shortcut
- Select the line(s) of code (or just place cursor on a line)
- Press
Ctrl+Alt+N(Windows/Linux) orCmd+Alt+N(Mac) - Enter your note in the comment editor
- Click Save
Method 2: From Sidebar
- Open the Code Notes sidebar (Activity Bar icon)
- Click the + button in the toolbar
- Enter your note and click Save
Method 3: Command Palette
- Place cursor on the line of code (or select multiple lines)
- Open Command Palette (
Ctrl+Shift+PorCmd+Shift+P) - Type "Code Notes: Add Note"
- Enter your note and click Save
Method 4: CodeLens
- Select the line(s) of code
- Click "➕ Add Note" in the CodeLens that appears above your code
- Enter your note and click Save
💡 Tips:
- You can add notes without selecting text - just place the cursor on a line
- You can add multiple notes to the same line - just click "➕ Add Note" again
- Notes added from the sidebar use your current cursor position
Notes support full markdown with keyboard shortcuts:
- Bold:
Ctrl/Cmd+Bor**text** - Italic:
Ctrl/Cmd+Ior*text* - Inline Code:
Ctrl/Cmd+Shift+Cor`code` - Code Block:
Ctrl/Cmd+Shift+Korlanguage ` - Link:
Ctrl/Cmd+Kor[text](url) - List: Type
-or1. - Heading: Type
#or##
- CodeLens: Click the indicator above annotated code to expand the note
- Inline: Notes appear as comment threads in your editor
- Preview: CodeLens shows a preview of the note content
- Multiple Notes: When there are multiple notes on the same line:
- CodeLens shows "📝 Note 1 of N" to indicate multiple annotations
- Use Previous (
<) and Next (>) buttons to navigate between notes - Each note displays its position (e.g., "Note 2 of 3")
- Click the Edit button (pencil icon) in the comment thread
- Modify the note content
- Click Save to create a new history entry
- Or click Cancel to discard changes
Each edit creates a new history entry with timestamp and author.
Button Layout:
- Single note:
[+] [Edit] [History] [Delete] - Multiple notes:
[<] [>] [+] [Edit] [History] [Delete][<]and[>]- Navigate between notes[+]- Add another note to the same line[Edit],[History],[Delete]- Standard actions
- Click the History button (clock icon) in the comment thread
- History appears as replies showing:
- Action (created, edited, deleted)
- Author
- Timestamp
- Previous content
- Click the Delete button (trash icon) in the comment thread
- Confirm the deletion
- Note is marked as deleted in history (not permanently removed)
- CodeLens indicator disappears
The Code Notes sidebar provides a workspace-wide overview of all your notes, organized by file.
Opening the Sidebar:
- Click the Code Notes icon in the Activity Bar (left sidebar)
- A dedicated panel opens showing all notes across your workspace
Sidebar Structure:
- Root Node: Shows total note count ("Code Notes (N)")
- File Nodes: Show files with notes and note count per file ("src/app.ts (3)")
- Note Nodes: Show line number, preview text (50 chars), and author
Quick Actions:
- + Button (toolbar): Add a note at current cursor position (no selection needed)
- Collapse All (toolbar): Reset all file nodes to collapsed state
- Refresh (toolbar): Manually refresh the sidebar
Navigating from Sidebar:
- Click a note: Opens the file and focuses the comment thread inline
- Right-click a note for context menu:
- Go to Note: Opens file and shows the note in comment editor
- Edit Note: Opens file and enables edit mode
- View History: Opens file and shows note history inline
- Delete Note: Confirms and deletes the note
- Right-click a file for context menu:
- Open File: Opens the file in editor
Sorting Options: Configure how files are sorted in the sidebar (see Configuration section):
- By File Path (default): Alphabetical order
- By Date: Most recently updated notes first
- By Author: Alphabetical by author name
Collapsing/Expanding:
- File nodes are collapsed by default to keep the view clean
- Click to expand and see notes within each file
- Use "Collapse All" button to reset to default state
Open VSCode Settings (Ctrl+, or Cmd+,) and search for "Code Context Notes":
"codeContextNotes.storageDirectory": ".code-notes"Directory where notes are stored (relative to workspace root). Default: .code-notes
"codeContextNotes.authorName": "Your Name"Override automatic username detection. Default: git username or system username
"codeContextNotes.showCodeLens": trueEnable/disable CodeLens indicators above code with notes. Default: true
"codeContextNotes.sidebar.sortBy": "file"Sort notes in sidebar by: "file" (path, alphabetically), "date" (most recent first), or "author" (alphabetically by author). Default: "file"
"codeContextNotes.sidebar.previewLength": 50Maximum length of note preview text in sidebar (20-200 characters). Default: 50
"codeContextNotes.sidebar.autoExpand": falseAutomatically expand file nodes in sidebar. Default: false (collapsed)
| Command | Windows/Linux | Mac | Description |
|---|---|---|---|
| Add Note | Ctrl+Alt+N |
Cmd+Alt+N |
Add note to current line or selection |
| Delete Note | Ctrl+Alt+D |
Cmd+Alt+D |
Delete note at cursor |
| View History | Ctrl+Alt+H |
Cmd+Alt+H |
View note history |
| Refresh Notes | Ctrl+Alt+R |
Cmd+Alt+R |
Refresh all notes |
| Bold | Ctrl+B |
Cmd+B |
Insert bold text (in comment editor) |
| Italic | Ctrl+I |
Cmd+I |
Insert italic text (in comment editor) |
| Inline Code | Ctrl+Shift+C |
Cmd+Shift+C |
Insert inline code (in comment editor) |
| Code Block | Ctrl+Shift+K |
Cmd+Shift+K |
Insert code block (in comment editor) |
| Link | Ctrl+K |
Cmd+K |
Insert link (in comment editor) |
Notes are stored in .code-notes/ directory with one file per note:
project/
├── src/
│ └── app.ts
└── .code-notes/
├── abc123-def456-ghi789.md
└── xyz789-uvw456-rst123.md
Each note file is named by its unique ID and contains:
# Note
**File:** src/app.ts
**Lines:** 10-15
**Author:** username
**Created:** 2025-10-17T10:30:00.000Z
**Updated:** 2025-10-17T14:45:00.000Z
**Content Hash:** abc123def456
## Content
Your note content here with **markdown** formatting.
## History
### Created - 2025-10-17T10:30:00.000Z - usernameOriginal content
### Edited - 2025-10-17T14:45:00.000Z - username
Previous content before this edit
You can add .code-notes/ to .gitignore if you want notes to be local only, or commit them to share with your team.
All commands are available in the Command Palette (Ctrl+Shift+P or Cmd+Shift+P):
Note Operations:
- Code Notes: Add Note - Add a note to selected code or current line
- Code Notes: Delete Note at Cursor - Delete note at current cursor position
- Code Notes: View Note History - View complete history of a note
- Code Notes: Refresh All Notes - Refresh all note displays
Sidebar:
- Code Notes: Refresh Sidebar - Manually refresh the sidebar view
- Code Notes: Collapse All - Collapse all file nodes in sidebar
Formatting:
- Code Notes: Show Markdown Formatting Guide - Display markdown help
Yes! Notes use content hash tracking to follow code even when line numbers change. If you move code to a different location, the note moves with it.
If the code content changes significantly, the note may become "stale" but is never deleted. You can update or delete the note manually.
Yes! Notes work with all file types and languages supported by VSCode.
Notes are stored in .code-notes/ directory. You can choose to commit them (to share with team) or add to .gitignore (to keep them local).
Notes are stored as markdown files, so you can read, search, and process them with any text tool. Future versions may include export features.
Commit the .code-notes/ directory to your repository. Team members with the extension installed will see all notes.
Minimal. The extension uses caching and efficient algorithms. Even with 100+ notes, you won't notice any lag.
git clone https://github.com/jnahian/code-context-notes
cd code-context-notes
npm install
npm run compile- Open the project in VSCode
- Press
F5to launch Extension Development Host - Test the extension in the new window
# Run unit tests (fast, ~50ms)
npm run test:unit
# Run with coverage report
npm run test:coverage
# Run all tests (requires VSCode)
npm test
# Package extension with git tagging
npm run package
# Publish to both marketplaces
npm run publishTest Coverage: 88% overall with 100 total tests
- 41 unit tests (pure Node.js)
- 59+ integration tests (VSCode API)
See docs/TESTING.md for detailed testing documentation.
- VSCode 1.80.0 or higher
- Git (optional, for author detection)
- Notes are tracked by content hash; significant code changes may cause notes to become stale
- Large files (10,000+ lines) may experience slight performance impact
- Content tracking works best with unique code blocks
Future enhancements being considered:
- Sidebar view for browsing all notes
- Search and filter notes across workspace
- Export notes to various formats
- Note templates
- Tags and categories
- Rich text editing
- Team collaboration features
MIT - see LICENSE file for details
Contributions are welcome! Please read CONTRIBUTING.md for details on:
- Code of conduct
- Development setup
- Testing requirements
- Pull request process
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: docs/
See CHANGELOG.md for version history and release notes.