Skip to content
Back to skills

File Operations

ASecurity

Read, write, search, and edit files across the workspace. Enforces the

  • 3 stars
  • 0 votes
  • 1 copy
  • 5 views
  • Added September 20, 2026
toolspythonrustgoshell

Works with

  • terminal

Security analysis

A100/100

Scanned November 9, 2026

npx -y skills add ruskicoder/system-prompts --skill file-operations --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of File Operations?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for File Operations
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ruskicoder-file-operations/badge)](https://www.skillsdirectory.com/skills/ruskicoder-file-operations)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: file-operations
description: Read, write, search, and edit files across the workspace. Enforces the
  READ-BEFORE-WRITE rule, batch file reads, atomic SEARCH/REPLACE blocks, and file
  discovery via grep and glob rather than terminal commands.
argument-hint: <file path or search pattern>
---

<!-- Generated from skills/file-operations.md by tools/generate_integrations.py. Edit the source file, not this one. -->

# Skill: File Operations

## Purpose
Read, write, search, and edit files in the filesystem with maximum efficiency and minimal token waste.

## Tools Required
- readFile / readMultipleFiles
- write / fsWrite
- append / fsAppend
- edit / strReplace / search_replace
- grep / grepSearch
- glob / fileSearch / glob_file_search
- delete / deleteFile
- list_dir / listDirectory

## General Principles
- Prefer batch reads (readMultipleFiles) over sequential single-file reads
- Read entire files when practical: partial reads force extra roundtrips
- Search first (grep/glob) before reading when you don't know exact file location
- Never print file contents to user: use edit/write tools instead
- Never generate binary, hashes, or non-textual content

## Reading Files

### Single File
- Use `readFile` with known absolute path
- For large files (>500 lines), read in chunks with offset/limit
- Prefer reading a large meaningful section over many small sequential reads

### Multiple Files
```python
# Preferred: batch related files in one call
readMultipleFiles(paths=[...])
```

### File Discovery
1. Use `glob` / `fileSearch` when you know part of the filename
2. Use `grep` / `grepSearch` when searching for content patterns
3. Use `listDirectory` for understanding structure
4. NEVER use shell `find`, `grep`, `cat` for file operations: use dedicated tools

## Writing Files

### Creating New Files
- Use `write` / `fsWrite` for new files or complete rewrites
- For files >50 lines, prefer write + follow-up appends
- Always create with complete, immediately runnable content
- Include all imports, dependencies, and types

### Appending to Existing Files
- Use `append` / `fsAppend` when adding to the end of a file
- File must already exist

### Editing Existing Files (SEARCH/REPLACE)
- Use `edit` / `strReplace` / `search_replace` for targeted edits
- CRITICAL: `oldString` / `SEARCH` block must match EXACTLY, character for character, including whitespace
- Include 2-5 lines of surrounding context to ensure uniqueness
- Break large edits into a series of smaller, targeted SEARCH/REPLACE blocks
- Each block should change a focused section: don't edit half a file at once

```python
# GOOD: precise with context
edit(
    filePath="src/app.py",
    oldString="def old_function():\n    return x + 1\n\ndef another():\n    pass",
    newString="def new_function():\n    return x * 2\n\ndef another():\n    pass"
)

# BAD: too little context (may match multiple places)
edit(
    filePath="src/app.py",
    oldString="return x + 1",
    newString="return x * 2"
)
```

### Partial Write for Large Files
- For large files where only small sections change, use `// keep existing code` markers
- The unchanged code stays as a comment placeholder
- Only applies when the tooling supports this pattern

## Deleting Files
- Use `deleteFile` / `delete` with explanation
- Handles non-existent files gracefully

## Searching

### Content Search (grep)
- Use `grep` / `grepSearch` for regex pattern matching across files
- Rust regex syntax. Escape special characters: `(`, `)`, `[`, `]`, `{`, `}`, `+`, `*`, `?`, `^`, `$`, `|`, `.`, `\`
- Include patterns to filter file types when possible
- Results capped at 50: refine query if results fill up

### File Search (glob)
- Use `glob` / `fileSearch` when you know part of the filename
- Glob patterns like `**/*.ts`, `src/**/*.py`

## Directory Listing
- Use `listDirectory` / `list_dir` with optional depth parameter
- Use for understanding project structure before diving in

## Batch Editing Rule
- When making multiple edits to the same file, combine ALL changes into a SINGLE edit call
- This minimizes roundtrips and token overhead
- Only split into multiple calls when edits are in completely unrelated sections

## Post-Edit Verification
- After editing, check for linter errors by running lint tools
- If errors introduced, fix them (max 3 fix cycles per file)
- Verify imports are complete and correct

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.