Essential Supporting Tools
read_file: Get Context Before Editing
read_file: Get Context Before Editing
Always read files before editing to understand the structure:Best practice: Read the relevant sections first, then edit with proper context.
codebase_search: Find What to Edit
codebase_search: Find What to Edit
Semantic search to locate relevant code:Best practice: Search first to understand the codebase, then read specific files.
grep_search: Find Exact Matches
grep_search: Find Exact Matches
When you need exact text or pattern matches:Best practice: Use for finding function names, imports, or specific strings.
list_dir: Explore Directory Structure
list_dir: Explore Directory Structure
Navigate and understand the codebase structure:Best practice: Use to explore unknown codebases or find related files before editing.
Agent Workflow
Effective agents follow this pattern:- ๐ Search: Find relevant code with
codebase_searchorgrep_search - ๐ Read: Get context with
read_filebefore editing - โ๏ธ Edit: Make precise changes with
edit_file - โ Verify: Read again to confirm changes worked
Common Patterns
Delete a section in between:Error Handling
Morph is trained to be robust to poor quality update snippets, but you should still follow these steps to ensure the best quality. When tools fail, follow these steps:- Check file permissions: Ensure the target file is writable
- Verify file path: Confirm the file exists and path is correct
- Review syntax: Check that your edit snippet follows the
// ... existing code ...pattern - Retry with context: Read the file again and provide more context around your changes
- Simplify changes: Break complex edits into smaller, focused changes
Next Steps
Ready to start building with Morph? Hereโs what to do next:Explore the Apply API
Learn about the Apply API endpoints, models, and message formats for
production use
Quickstart Guide
Step-by-step guide to configure your agent with the edit_file tool and
integrate with Morphโs Fast Apply API