agentleFS
JacobinwweyJacobinwwey/notemdpro/skills/selection-processor/SKILL.md

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

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
  1. Distinctive:

    Selective linking: Add links to specific paragraphs

    line 15
  2. Distinctive:

    Always validate selection: Check if selection is non-empty

    line 157
  3. Distinctive:

    Undo support: Ensure easy rollback if needed

    line 161

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 file

Selection 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

SettingDescription
includeContextLinesNumber of context lines to include
replaceSelectionReplace or append processed content
preserveFormattingPreserve original formatting

Context Options

SettingDescription
contextBeforeLines before selection
contextAfterLines after selection
includeHeadingsInclude parent headings

Error Handling

Common Errors

  1. Empty selection
    • Error: No text selected
    • Solution: Check selection length before processing
  2. Selection too large
    • Error: Exceeds token limits
    • Solution: Split into chunks or use full file mode
  3. 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 range

CLI (Standard Input/Output)

# Pipe selected content to script
echo "$SELECTED_TEXT" | notemd-process --operation=links

# Output replaces stdin

Best Practices

  1. Always validate selection: Check if selection is non-empty
  2. Provide context: Include surrounding text for better results
  3. Preserve formatting: Maintain markdown structure
  4. Preview before replace: Show preview for user confirmation
  5. Undo support: Ensure easy rollback if needed

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.