Cursor rule
.cursor/rules/new_features.mdcGuidelines for integrating new features into the Task Master CLI
Cursor rules
Quality
65/100
Scores the file, not the repository.Length
1,255 words
9 headings · 15 code blocksRepository
192
— · pushed 309 days agoLast changed
3 days ago
First indexed 3 days ago.1234567# Task Master Feature Integration Guidelines89## Feature Placement Decision Process1011- **Identify Feature Type**:12 - **Data Manipulation**: Features that create, read, update, or delete tasks belong in [`task-manager.js`](mdc:scripts/modules/task-manager.js)13 - **Dependency Management**: Features that handle task relationships belong in [`dependency-manager.js`](mdc:scripts/modules/dependency-manager.js)14 - **User Interface**: Features that display information to users belong in [`ui.js`](mdc:scripts/modules/ui.js)15 - **AI Integration**: Features that use AI models belong in [`ai-services.js`](mdc:scripts/modules/ai-services.js)16 - **Cross-Cutting**: Features that don't fit one category may need components in multiple modules1718- **Command-Line Interface**:19 - All new user-facing commands should be added to [`commands.js`](mdc:scripts/modules/commands.js)20 - Use consistent patterns for option naming and help text21 - Follow the Commander.js model for subcommand structure2223## Implementation Pattern2425The standard pattern for adding a feature follows this workflow:26271. **Core Logic**: Implement the business logic in the appropriate module282. **UI Components**: Add any display functions to [`ui.js`](mdc:scripts/modules/ui.js)293. **Command Integration**: Add the CLI command to [`commands.js`](mdc:scripts/modules/commands.js)304. **Testing**: Write tests for all components of the feature (following [`tests.mdc`](mdc:.cursor/rules/tests.mdc))315. **Configuration**: Update any configuration in [`utils.js`](mdc:scripts/modules/utils.js) if needed326. **Documentation**: Update help text and documentation in [dev_workflow.mdc](mdc:scripts/modules/dev_workflow.mdc)3334```javascript35// 1. CORE LOGIC: Add function to appropriate module (example in task-manager.js)36/**37 * Archives completed tasks to archive.json38 * @param {string} tasksPath - Path to the tasks.json file39 * @param {string} archivePath - Path to the archive.json file40 * @returns {number} Number of tasks archived41 */42async function archiveTasks(tasksPath, archivePath = 'tasks/archive.json') {43 // Implementation...44 return archivedCount;45}4647// Export from the module48export {49 // ... existing exports ...50 archiveTasks,51};52```5354```javascript55// 2. UI COMPONENTS: Add display function to ui.js56/**57 * Display archive operation results58 * @param {string} archivePath - Path to the archive file59 * @param {number} count - Number of tasks archived60 */61function displayArchiveResults(archivePath, count) {62 console.log(boxen(63 chalk.green(`Successfully archived ${count} tasks to ${archivePath}`),64 { padding: 1, borderColor: 'green', borderStyle: 'round' }65 ));66}6768// Export from the module69export {70 // ... existing exports ...71 displayArchiveResults,72};73```7475```javascript76// 3. COMMAND INTEGRATION: Add to commands.js77import { archiveTasks } from './task-manager.js';78import { displayArchiveResults } from './ui.js';7980// In registerCommands function81programInstance82 .command('archive')83 .description('Archive completed tasks to separate file')84 .option('-f, --file <file>', 'Path to the tasks file', 'tasks/tasks.json')85 .option('-o, --output <file>', 'Archive output file', 'tasks/archive.json')86 .action(async (options) => {87 const tasksPath = options.file;88 const archivePath = options.output;8990 console.log(chalk.blue(`Archiving completed tasks from ${tasksPath} to ${archivePath}...`));9192 const archivedCount = await archiveTasks(tasksPath, archivePath);93 displayArchiveResults(archivePath, archivedCount);94 });95```9697## Cross-Module Features9899For features requiring components in multiple modules:100101- ✅ **DO**: Create a clear unidirectional flow of dependencies102```javascript103 // In task-manager.js104 function analyzeTasksDifficulty(tasks) {105 // Implementation...106 return difficultyScores;107 }108109 // In ui.js - depends on task-manager.js110 import { analyzeTasksDifficulty } from './task-manager.js';111112 function displayDifficultyReport(tasks) {113 const scores = analyzeTasksDifficulty(tasks);114 // Render the scores...115 }116```117118- ❌ **DON'T**: Create circular dependencies between modules119```javascript120 // In task-manager.js - depends on ui.js121 import { displayDifficultyReport } from './ui.js';122123 function analyzeTasks() {124 // Implementation...125 displayDifficultyReport(tasks); // WRONG! Don't call UI functions from task-manager126 }127128 // In ui.js - depends on task-manager.js129 import { analyzeTasks } from './task-manager.js';130```131132## Command-Line Interface Standards133134- **Naming Conventions**:135 - Use kebab-case for command names (`analyze-complexity`, not `analyzeComplexity`)136 - Use kebab-case for option names (`--output-format`, not `--outputFormat`)137 - Use the same option names across commands when they represent the same concept138139- **Command Structure**:140```javascript141 programInstance142 .command('command-name')143 .description('Clear, concise description of what the command does')144 .option('-s, --short-option <value>', 'Option description', 'default value')145 .option('--long-option <value>', 'Option description')146 .action(async (options) => {147 // Command implementation148 });149```150151## Utility Function Guidelines152153When adding utilities to [`utils.js`](mdc:scripts/modules/utils.js):154155- Only add functions that could be used by multiple modules156- Keep utilities single-purpose and purely functional157- Document parameters and return values158159```javascript160/**161 * Formats a duration in milliseconds to a human-readable string162 * @param {number} ms - Duration in milliseconds163 * @returns {string} Formatted duration string (e.g., "2h 30m 15s")164 */165function formatDuration(ms) {166 // Implementation...167 return formatted;168}169```170171## Writing Testable Code172173When implementing new features, follow these guidelines to ensure your code is testable:174175- **Dependency Injection**176 - Design functions to accept dependencies as parameters177 - Avoid hard-coded dependencies that are difficult to mock178```javascript179 // ✅ DO: Accept dependencies as parameters180 function processTask(task, fileSystem, logger) {181 fileSystem.writeFile('task.json', JSON.stringify(task));182 logger.info('Task processed');183 }184185 // ❌ DON'T: Use hard-coded dependencies186 function processTask(task) {187 fs.writeFile('task.json', JSON.stringify(task));188 console.log('Task processed');189 }190```191192- **Separate Logic from Side Effects**193 - Keep pure logic separate from I/O operations or UI rendering194 - This allows testing the logic without mocking complex dependencies195```javascript196 // ✅ DO: Separate logic from side effects197 function calculateTaskPriority(task, dependencies) {198 // Pure logic that returns a value199 return computedPriority;200 }201202 function displayTaskPriority(task, dependencies) {203 const priority = calculateTaskPriority(task, dependencies);204 console.log(`Task priority: ${priority}`);205 }206```207208- **Callback Functions and Testing**209 - When using callbacks (like in Commander.js commands), define them separately210 - This allows testing the callback logic independently211```javascript212 // ✅ DO: Define callbacks separately for testing213 function getVersionString() {214 // Logic to determine version215 return version;216 }217218 // In setupCLI219 programInstance.version(getVersionString);220221 // In tests222 test('getVersionString returns correct version', () => {223 expect(getVersionString()).toBe('1.5.0');224 });225```226227- **UI Output Testing**228 - For UI components, focus on testing conditional logic rather than exact output229 - Use string pattern matching (like `expect(result).toContain('text')`)230 - Pay attention to emojis and formatting which can make exact string matching difficult231```javascript232 // ✅ DO: Test the essence of the output, not exact formatting233 test('statusFormatter shows done status correctly', () => {234 const result = formatStatus('done');235 expect(result).toContain('done');236 expect(result).toContain('✅');237 });238```239240## Testing Requirements241242Every new feature **must** include comprehensive tests following the guidelines in [`tests.mdc`](mdc:.cursor/rules/tests.mdc). Testing should include:2432441. **Unit Tests**: Test individual functions and components in isolation245```javascript246 // Example unit test for a new utility function247 describe('newFeatureUtil', () => {248 test('should perform expected operation with valid input', () => {249 expect(newFeatureUtil('valid input')).toBe('expected result');250 });251252 test('should handle edge cases appropriately', () => {253 expect(newFeatureUtil('')).toBeNull();254 });255 });256```2572582. **Integration Tests**: Verify the feature works correctly with other components259```javascript260 // Example integration test for a new command261 describe('newCommand integration', () => {262 test('should call the correct service functions with parsed arguments', () => {263 const mockService = jest.fn().mockResolvedValue('success');264 // Set up test with mocked dependencies265 // Call the command handler266 // Verify service was called with expected arguments267 });268 });269```2702713. **Edge Cases**: Test boundary conditions and error handling272 - Invalid inputs273 - Missing dependencies274 - File system errors275 - API failures2762774. **Test Coverage**: Aim for at least 80% coverage for all new code2782795. **Jest Mocking Best Practices**280 - Follow the mock-first-then-import pattern as described in [`tests.mdc`](mdc:.cursor/rules/tests.mdc)281 - Use jest.spyOn() to create spy functions for testing282 - Clear mocks between tests to prevent interference283 - See the Jest Module Mocking Best Practices section in [`tests.mdc`](mdc:.cursor/rules/tests.mdc) for details284285When submitting a new feature, always run the full test suite to ensure nothing was broken:286287```bash288npm test289```290291## Documentation Requirements292293For each new feature:2942951. Add help text to the command definition2962. Update [`dev_workflow.mdc`](mdc:scripts/modules/dev_workflow.mdc) with command reference2973. Add examples to the appropriate sections in [`MODULE_PLAN.md`](mdc:scripts/modules/MODULE_PLAN.md)298299Follow the existing command reference format:300```markdown301- **Command Reference: your-command**302 - CLI Syntax: `task-manager your-command [options]`303 - Description: Brief explanation of what the command does304 - Parameters:305 - `--option1=<value>`: Description of option1 (default: 'default')306 - `--option2=<value>`: Description of option2 (required)307 - Example: `task-manager your-command --option1=value --option2=value2`308 - Notes: Additional details, limitations, or special considerations309```310311For more information on module structure, see [`MODULE_PLAN.md`](mdc:scripts/modules/MODULE_PLAN.md) and follow [`self_improve.mdc`](mdc:scripts/modules/self_improve.mdc) for best practices on updating documentation.312
Also in skindhu/AI-TASK-MANAGER
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| skindhu/AI-TASK-MANAGER.cursor/rules/ui.mdc · 192 | Cursor rules | ui | 62/100 | 3 days ago | |
| skindhu/AI-TASK-MANAGER.cursor/rules/architecture.mdc · 192 | Cursor rules | testarchtesting-strategy | 42/100 | 3 days ago | |
| skindhu/AI-TASK-MANAGER.cursor/rules/commands.mdc · 192 | Cursor rules | stylearch | 62/100 | 3 days ago | |
| skindhu/AI-TASK-MANAGER.cursor/rules/cursor_rules.mdc · 192 | Cursor rules | no sections | 36/100 | 3 days ago | |
| skindhu/AI-TASK-MANAGER.cursor/rules/dependencies.mdc · 192 | Cursor rules | arch | 66/100 | 3 days ago | |
| skindhu/AI-TASK-MANAGER.cursor/rules/dev_workflow.mdc · 192 | Cursor rules | setup | 52/100 | 3 days ago | |
| skindhu/AI-TASK-MANAGER.cursor/rules/self_improve.mdc · 192 | Cursor rules | no sections | 36/100 | 3 days ago | |
| skindhu/AI-TASK-MANAGER.cursor/rules/tasks.mdc · 192 | Cursor rules | arch | 70/100 | 3 days ago | |
| skindhu/AI-TASK-MANAGER.cursor/rules/tests.mdc · 192 | Cursor rules | teststylearchtesting-strategy+1 | 74/100 | 3 days ago | |
| skindhu/AI-TASK-MANAGER.cursor/rules/utilities.mdc · 192 | Cursor rules | securitydocs | 54/100 | 3 days ago | |
| skindhu/AI-TASK-MANAGERassets/.windsurfrules · 192 | Windsurf rules | setup | 40/100 | 3 days ago |
Diff against .cursor/rules/ui.mdc Diff against .cursor/rules/architecture.mdc Diff against .cursor/rules/commands.mdc Diff against .cursor/rules/cursor_rules.mdc Diff against .cursor/rules/dependencies.mdc Diff against .cursor/rules/dev_workflow.mdc Diff against .cursor/rules/self_improve.mdc Diff against .cursor/rules/tasks.mdc Diff against .cursor/rules/tests.mdc Diff against .cursor/rules/utilities.mdc Diff against assets/.windsurfrules
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
