Contributing
Thank you for your interest in contributing! This guide will help you get set up for development.
Table of Contents
Section titled “Table of Contents”- Development Environment
- Getting Started
- Development Workflow
- Testing
- Code Style
- Submitting Changes
- Working with Claude Code
Development Environment
Section titled “Development Environment”Prerequisites
Section titled “Prerequisites”Choose ONE of the following package managers:
- bun (recommended) - Fast JavaScript runtime
- npm (alternative) - Comes with Node.js
Supported Environments
Section titled “Supported Environments”This plugin can be developed in multiple environments:
| Environment | Package Manager | Notes |
|---|---|---|
| WSL | bun or npm | Recommended for Windows users |
| PowerShell | bun or npm | Windows native |
| Linux | bun or npm | Native Linux |
| macOS | bun or npm | Intel or Apple Silicon |
Important: Due to esbuild platform binaries, you should install dependencies in the same environment where you’ll run the build. See TESTING_GUIDE.md for platform-specific issues.
Getting Started
Section titled “Getting Started”1. Clone the Repository
Section titled “1. Clone the Repository”git clone https://github.com/cybersader/obsidian-tag-and-folder-mapper.gitcd obsidian-tag-and-folder-mapper2. Install Dependencies
Section titled “2. Install Dependencies”Using bun (recommended):
bun installUsing npm:
npm install3. Verify Installation
Section titled “3. Verify Installation”# Check that tests passbun test# ornpm test
# Check that TypeScript compilesbun x tsc -noEmit -skipLibCheck# ornpx tsc -noEmit -skipLibCheckYou should see:
- ✅ 156 tests passing
- ✅ No TypeScript errors
Development Workflow
Section titled “Development Workflow”File Structure
Section titled “File Structure”src/├── main.ts # Plugin entry point├── types/│ └── settings.ts # TypeScript interfaces├── transformers/ # Transformation engines│ ├── caseTransformers.ts # Case conversions│ ├── emojiTransformers.ts # Emoji handling│ ├── numberTransformers.ts # Number prefixes│ ├── regexTransformers.ts # Regex & glob patterns│ ├── pipeline.ts # Orchestration│ └── *.test.ts # Unit tests (colocated)├── engine/│ └── ruleMatcher.ts # Rule evaluation├── ui/│ ├── SettingsTab.ts # Settings interface│ └── RuleEditorModal.ts # Rule creation UI└── sync/ # (Phase 3 - coming soon) ├── FolderToTagSync.ts └── TagToFolderSync.tsDevelopment Commands
Section titled “Development Commands”# Run tests (156 passing)bun test
# Run tests in watch mode (auto-rerun on changes)bun test --watch
# TypeScript type checkingbun x tsc -noEmit -skipLibCheck
# Build for development (watch mode)bun run dev
# Build for productionbun run build
# Platform-aware build (auto-detects environment)node scripts/build.mjsMaking Changes
Section titled “Making Changes”-
Create a feature branch
Terminal window git checkout -b feature/your-feature-name -
Make your changes
- Follow the existing code style
- Add tests for new functionality
- Update documentation if needed
-
Run tests
Terminal window bun test -
Type check
Terminal window bun x tsc -noEmit -skipLibCheck -
Test in Obsidian
- See TESTING_GUIDE.md for detailed instructions
- Create a symlink to your vault for live testing
- Use Hot Reload plugin for faster iteration
-
Commit your changes
Terminal window git add .git commit -m "feat: add your feature description"
Testing
Section titled “Testing”Unit Tests
Section titled “Unit Tests”All transformer modules have comprehensive test coverage:
# Run all testsbun test
# Run specific test filebun test src/transformers/caseTransformers.test.ts
# Run tests matching a patternbun test --test-name-pattern="snake_case"Test Coverage:
- Case transformers: 20 tests
- Emoji transformers: 21 tests
- Number transformers: 26 tests
- Regex transformers: 40 tests
- Pipeline: 28 tests
- Rule matcher: 27 tests
Total: 156 tests ✅
Integration Testing
Section titled “Integration Testing”-
Create a test vault - See TESTING_GUIDE.md
-
Test the UI
- Open Obsidian with the test vault
- Enable the plugin
- Test rule creation, editing, drag-and-drop, etc.
-
Test transformations
- Create rules with different transformation configs
- Use the preview feature in the rule editor
- Verify transformations work as expected
Writing Tests
Section titled “Writing Tests”When adding new features, include tests:
import { describe, test, expect } from 'bun:test';import { myNewFunction } from './myNewTransformer';
describe('myNewFunction', () => { test('handles basic case', () => { expect(myNewFunction('input')).toBe('expected output'); });
test('handles edge case', () => { expect(myNewFunction('')).toBe(''); });});Code Style
Section titled “Code Style”TypeScript
Section titled “TypeScript”- Strict mode enabled - All type safety features on
- No implicit any - Always specify types
- Prefer explicit types for public APIs
- Use interfaces over type aliases for objects
Naming Conventions
Section titled “Naming Conventions”- Files: camelCase.ts (e.g.,
caseTransformers.ts) - Classes: PascalCase (e.g.,
RuleEditorModal) - Functions: camelCase (e.g.,
applyTransform) - Constants: UPPER_SNAKE_CASE (e.g.,
DEFAULT_SETTINGS) - Interfaces: PascalCase (e.g.,
MappingRule)
Code Organization
Section titled “Code Organization”- Colocate tests - Keep
*.test.tsnext to*.ts - One export per file for main functionality
- Use barrel exports (
index.ts) for modules - Document complex logic with comments
Commenting
Section titled “Commenting”/** * JSDoc for public APIs * * @param input - Description of parameter * @returns Description of return value */export function publicFunction(input: string): string { // Inline comments for complex logic const result = complexOperation(input); return result;}Submitting Changes
Section titled “Submitting Changes”Pull Request Process
Section titled “Pull Request Process”-
Fork the repository
-
Create a feature branch
Terminal window git checkout -b feature/amazing-feature -
Make your changes
- Write code
- Add tests
- Update docs
-
Ensure quality
Terminal window # All tests passbun test# No TypeScript errorsbun x tsc -noEmit -skipLibCheck# Code builds successfullynode scripts/build.mjs -
Commit with conventional commits
Terminal window git commit -m "feat: add amazing feature"Types:
feat:- New featurefix:- Bug fixdocs:- Documentation changestest:- Test additions/changesrefactor:- Code refactoringchore:- Build process, dependencies
-
Push to your fork
Terminal window git push origin feature/amazing-feature -
Open a pull request
- Describe what changed and why
- Reference any related issues
- Include screenshots for UI changes
- Note which environments you tested in
PR Checklist
Section titled “PR Checklist”- Tests pass (
bun test) - TypeScript compiles (
bun x tsc -noEmit) - Plugin builds (
node scripts/build.mjs) - Tested in Obsidian
- Documentation updated
- Conventional commit message
- No merge conflicts
Working with Claude Code
Section titled “Working with Claude Code”This project is actively developed with Claude Code. Here are some tips:
Environment Considerations
Section titled “Environment Considerations”Claude Code may run commands with different permissions or in a different environment than your normal shell. This affects:
- File permissions - Files created by Claude Code may be owned by root
- Package installation - Dependencies might be installed for a different platform
- Build artifacts - Compiled files might not work in your environment
Best Practices
Section titled “Best Practices”1. Separate Environments
Section titled “1. Separate Environments”- Let Claude Code handle: TypeScript compilation, testing
- You handle: Final builds, Obsidian testing, git commits
2. Platform-Aware Building
Section titled “2. Platform-Aware Building”Use the platform-aware build script:
# This auto-detects your environmentnode scripts/build.mjsInstead of:
# This might use wrong platform binariesbun run build3. Fix Permission Issues (WSL)
Section titled “3. Fix Permission Issues (WSL)”If Claude Code creates files as root:
# Fix ownershipsudo chown -R $USER:$USER .
# Then reinstall dependencies in your environmentrm -rf node_modulesbun install4. Verify Tests Independently
Section titled “4. Verify Tests Independently”After Claude Code makes changes:
# Run tests yourself to verifybun test
# Check TypeScript compilationbun x tsc -noEmitCommunication with Claude Code
Section titled “Communication with Claude Code”When working with Claude Code:
- Specify your environment - “I’m in WSL” or “I’m using PowerShell”
- Mention platform issues - “This might have permission differences”
- Test the changes - Always test in Obsidian yourself
- Report results - Let Claude Code know if tests pass/fail
Development Phases
Section titled “Development Phases”The project is being developed in phases:
✅ Phase 1: Foundation (Complete)
Section titled “✅ Phase 1: Foundation (Complete)”- TypeScript setup with strict mode
- Transformation engines (case, emoji, number, regex)
- Transformation pipeline
- Rule matching engine
- 156 tests passing
✅ Phase 2: User Interface (Complete)
Section titled “✅ Phase 2: User Interface (Complete)”- Settings tab with rule management
- Rule editor modal
- Drag-and-drop priority reordering
- Import/export settings
- Live transformation preview
🚧 Phase 3: Core Sync Engine (Next)
Section titled “🚧 Phase 3: Core Sync Engine (Next)”- File event watchers
- Folder → Tag synchronization
- Tag → Folder synchronization
- Frontmatter manipulation
📋 Phase 4: Advanced Features
Section titled “📋 Phase 4: Advanced Features”- Entry points and flattening
- Exclusion patterns
- Breadth vs depth preferences
- Untagged note handling
🔌 Phase 5: Integrations
Section titled “🔌 Phase 5: Integrations”- Folder notes support
- Plugin API for QuickAdd, Templater
- Commands and hotkeys
See README.md for the complete roadmap.
Getting Help
Section titled “Getting Help”- Documentation: Check TESTING_GUIDE.md and ENVIRONMENT_SETUP.md
- Issues: Search existing issues first
- Discussions: Ask questions in Discussions
- Discord: Join the Obsidian Discord and ask in #plugin-dev
License
Section titled “License”By contributing, you agree that your contributions will be licensed under the MIT License.