selection-processor
Skill2 starsChanged 38 days agoMITView on GitHub
Use when processing only a selected portion of text rather than a full file, to save tokens and enable targeted AI operations
In this repository15 other files it gives its agents.
- notemdproSkill
- batch-processorSkill
- concept-extractorSkill
- content-generatorSkill
- diagram-generatorSkill
- formula-healerSkill
- link-analyzerSkill
- mermaid-healerSkill
- mermaid-summarizerSkill
- qa-extractorSkill
- system-architectureSkill
- test-driven-developmentSkill
- text-translatorSkill
- web-researcherSkill
- workflow-runnerSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Selective linking: Add links to specific paragraphs
- Distinctive: line 157
Always validate selection: Check if selection is non-empty
- Distinctive: line 161
Undo support: Ensure easy rollback if needed
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
NoteMD Pro - Selection-Based Processing
Overview
This skill enables processing of selected text portions within files, rather than forcing full-file rewrites. This saves tokens, reduces processing time, and allows targeted AI operations on specific sections.
When to Use
- Partial content generation: Generate content for just a section
- Selective linking: Add links to specific paragraphs
- Targeted translation: Translate selected portions
- Efficient processing: Save tokens by processing only what's needed
Function Call Chain
Process Selection
├── Get selected text from editor
├── Get surrounding context (optional)
├── Process selected content (LLM)
├── Replace or append selected content
└── Update fileSelection Processing Patterns
1. Get Selected Text
// From Obsidian editor
const editor = view.editor;
const selection = editor.getSelection();
// From VS Code
const selection = editor.selection;
const text = editor.document.getText(selection);2. Process with Context
For better results, include surrounding context:
// Get context before and after selection
const lineNum = editor.getCursor().line;
const beforeLines = editor.getRange({line: 0, ch: 0}, {line: lineNum, ch: 0});
const afterLines = editor.getRange({line: lineNum, ch: 0}, {line: maxLine, ch: 0});
const fullContext = beforeLines + selection + afterLines;3. Replace Selection
// Replace selected text with processed result
editor.replaceSelection(processedContent);
// Or append after selection
editor.replaceRange('\n\n' + processedContent, {line: lineNum + 1, ch: 0});Use Cases
Wiki-Link from Selection
// Selected: "Machine learning is a subset of AI"
// Process: Add links to key concepts
// Result: "Machine learning is a subset of [[AI]]"
async function addLinksToSelection(app: App, editor: Editor) {
const selection = editor.getSelection();
const prompt = getSystemPrompt('addLinks');
const result = await callLLM(prompt, selection);
editor.replaceSelection(result);
}Generate from Selection
// Selected: "Neural Networks"
// Process: Generate expanded content
// Result: Full explanation of neural networks
async function generateFromSelection(app: App, editor: Editor) {
const selection = editor.getSelection();
const prompt = getSystemPrompt('generateTitle', {TITLE: selection});
const result = await callLLM(prompt, '');
editor.replaceSelection(result);
}Translate Selection
// Selected: Some text in English
// Process: Translate to target language
// Result: Translated text
async function translateSelection(app: App, editor: Editor, targetLang: string) {
const selection = editor.getSelection();
const prompt = getSystemPrompt('translate', {LANGUAGE: targetLang, TEXT: selection});
const result = await callLLM(prompt, '');
editor.replaceSelection(result);
}Settings
Selection Processing
| Setting | Description |
includeContextLines | Number of context lines to include |
replaceSelection | Replace or append processed content |
preserveFormatting | Preserve original formatting |
Context Options
| Setting | Description |
contextBefore | Lines before selection |
contextAfter | Lines after selection |
includeHeadings | Include parent headings |
Error Handling
Common Errors
- Empty selection
- Error: No text selected
- Solution: Check selection length before processing
- Selection too large
- Error: Exceeds token limits
- Solution: Split into chunks or use full file mode
- Invalid cursor position
- Error: Cannot determine insertion point
- Solution: Check editor state before operations
Platform-Agnostic Approach
Web/Node.js
// Get selection from DOM
const selection = window.getSelection().toString();
// Process with file system
const content = fs.readFileSync(filepath, 'utf-8');
// Find and replace rangeCLI (Standard Input/Output)
# Pipe selected content to script
echo "$SELECTED_TEXT" | notemd-process --operation=links
# Output replaces stdinBest Practices
- Always validate selection: Check if selection is non-empty
- Provide context: Include surrounding text for better results
- Preserve formatting: Maintain markdown structure
- Preview before replace: Show preview for user confirmation
- Undo support: Ensure easy rollback if needed
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

