This document details Qoder's file operation system and the critical editing rules that govern how code modifications are performed. It covers the mandatory use of the search_replace tool, the 600-line constraints, exact whitespace matching requirements, and the $100,000,000 penalty system that enforces proper tool selection. This page focuses specifically on the mechanics of file editing; for information about code validation after edits, see Code Change Validation Pipeline; for task planning that precedes file operations, see Planning Approach and Task Breakdown.
Sources: Qoder/prompt.txt121-290
Qoder provides six file operation tools, each with specific use cases and constraints:
| Tool | Purpose | Primary Use Case | Line Limit |
|---|---|---|---|
list_dir | List directory contents | Directory exploration | N/A |
read_file | Read file contents with optional dependency viewing | Mandatory pre-edit context gathering | N/A |
create_file | Create new files | New file generation only | 600 lines max |
search_replace | Make precise string replacements in existing files | DEFAULT editing tool | 600 lines total across all replacements |
edit_file | Propose edits to existing files | Only when explicitly instructed | N/A |
delete_file | Safely delete files | File removal | N/A |
Critical Rule: The system MUST always default to using search_replace for editing existing files unless explicitly instructed to use edit_file, or face a $100,000,000 penalty.
Sources: Qoder/prompt.txt302-309 Qoder/prompt.txt236-243 Qoder/prompt.txt359-365
Sources: Qoder/prompt.txt302-320 Qoder/prompt.txt146-150
Universal Rule: Qoder MUST read a file's contents before attempting any modifications. This is non-negotiable across all file editing operations.
read_file to load the target file into contextsearch_replace with exact original text and new textget_problems to verify no issues introducedoriginal_text parameter uniquely identifies the target locationSources: Qoder/prompt.txt121-124 Qoder/prompt.txt359-365
The search_replace tool is Qoder's default and strongly preferred method for modifying existing files. It performs precise string replacement operations with exact matching semantics.
search_replace(
path: string, // File path to edit
original_text: string, // Exact text to find (must be unique)
new_text: string // Replacement text
)
| Requirement | Description | Penalty for Violation |
|---|---|---|
| Default Tool | Must use search_replace unless explicitly told otherwise | $100,000,000 |
| Unique Match | original_text must uniquely identify target location | $100,000,000 |
| Exact Whitespace | Must match all spaces, tabs, newlines precisely | $100,000,000 |
| No Identity | original_text and new_text cannot be identical | $100,000,000 |
| Line Limit | Total lines across all replacements < 600 | $100,000,000 |
| No Whole File | DO NOT replace entire file content | $100,000,000 |
Sources: Qoder/prompt.txt236-243 Qoder/prompt.txt122-124 Qoder/prompt.txt359-365
To minimize token usage and focus on actual changes, Qoder uses a special comment pattern to represent unchanged code sections between modifications.
// ... existing code ...
FIRST_EDIT
// ... existing code ...
SECOND_EDIT
// ... existing code ...
# ... existing code ... for Python)This pattern clearly shows the new process_user function is being inserted between existing code blocks without cluttering the replacement with unnecessary context.
Sources: Qoder/prompt.txt134-143
The search_replace tool requires byte-for-byte exact matching of the original_text parameter, including all whitespace characters.
| Element | Requirement |
|---|---|
| Spaces | Exact count and position |
| Tabs | Must match tab characters exactly (not converted to spaces) |
| Newlines | Line break positions must match precisely |
| Indentation | Leading whitespace must be identical |
| Trailing Whitespace | Trailing spaces/tabs at line ends must match |
original_text appears exactly once in the fileSources: Qoder/prompt.txt242-243
Qoder enforces strict line count limits on file operations to manage token usage and maintain operational efficiency.
| Tool | Limit Type | Limit Value | Counted Elements |
|---|---|---|---|
create_file | Per file | 600 lines | Total lines in new file |
search_replace | Per call | 600 lines | Sum of all new_text line counts across all replacements in single call |
For modifications exceeding 600 lines:
search_replace callsget_problems between calls for safetyCRITICAL: Never split short modifications (combined length under 600 lines) into several consecutive calls, OR face a $100,000,000 penalty.
This means:
Sources: Qoder/prompt.txt252-257 Qoder/prompt.txt240
Qoder uses an extreme penalty system ($100,000,000) to enforce critical file editing rules. This is not a literal monetary penalty but a conceptual enforcement mechanism that makes certain violations effectively impossible.
edit_file when search_replace should be defaultoriginal_text appears multiple times or doesn't existoriginal_text and new_text are identical stringsThe $100M penalty serves to:
search_replace is used properlySources: Qoder/prompt.txt236-243
File editing operations MUST ALWAYS be executed sequentially. Parallel execution of file edits is strictly prohibited with the same $100M penalty enforcement.
| Operation Type | Parallel Allowed? | Rationale |
|---|---|---|
File Reading (read_file) | ✅ YES | Read-only, no conflicts |
Directory Listing (list_dir) | ✅ YES | Read-only, no conflicts |
Code Search (search_codebase, grep_code) | ✅ YES | Read-only, no conflicts |
File Editing (search_replace, edit_file) | ❌ NO | Prevents race conditions and consistency issues |
File Creation (create_file) | ❌ NO | Prevents conflicts in file system state |
Terminal Commands (run_in_terminal) | ❌ NO | Ensures proper execution order |
While file edits must be sequential, these operations can and should be parallelized for efficiency:
Sources: Qoder/prompt.txt66-80 Qoder/prompt.txt258-262
Sources: Qoder/prompt.txt236-243 Qoder/prompt.txt359-365 Qoder/prompt.txt146-150
After ANY file editing operation, regardless of size or perceived simplicity, Qoder MUST call get_problems to validate the changes.
search_replace, edit_file, or create_file operationget_problems without delayget_problems again after fixesget_problems returns no issuesFrom Qoder/prompt.txt146-150:
3. MANDATORY FINAL STEP:
After completing ALL code changes, no matter how small or seemingly
straightforward, you MUST:
- Use get_problems to validate the modified code
- If any issues are found, fix them and validate again
- Continue until get_problems shows no issues
| Reason | Explanation |
|---|---|
| Syntax Errors | Catch typos and malformed code immediately |
| Type Errors | Detect type mismatches in statically-typed languages |
| Import Issues | Identify missing imports or circular dependencies |
| Lint Violations | Maintain code quality standards |
| Immediate Feedback | Fix issues before they cascade to dependent code |
Sources: Qoder/prompt.txt146-150 Qoder/prompt.txt196-203
search_replace unless explicitly told otherwiseread_file before editingget_problems after every editSources: Qoder/prompt.txt121-290
Refresh this wiki