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
β
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
- Select code you want to annotate
- Press
Ctrl+Alt+N(orCmd+Alt+Non Mac) - Type your note with markdown formatting
- Click Save or press
Ctrl+Enter
That's it! A CodeLens indicator appears above your code.
Method 1: Keyboard Shortcut
- Select the line(s) of code
- Press
Ctrl+Alt+N(Windows/Linux) orCmd+Alt+N(Mac) - Enter your note in the comment editor
- Click Save
Method 2: Command Palette
- Select the line(s) of code
- Open Command Palette (
Ctrl+Shift+PorCmd+Shift+P) - Type "Code Notes: Add Note to Selection"
- Enter your note and click Save
Method 3: CodeLens
- Select the line(s) of code
- Click "β Add Note" in the CodeLens that appears above your code
- Enter your note and click Save
π‘ Tip: You can add multiple notes to the same line! Just click the "β Add Note" CodeLens or button again to create additional annotations.
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
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
| Command | Windows/Linux | Mac | Description |
|---|---|---|---|
| Add Note | Ctrl+Alt+N |
Cmd+Alt+N |
Add note to selected code |
| 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):
- Code Notes: Add Note to Selection - Add a note to selected code
- 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
- 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.