About File Operations
Cheetah AI can perform comprehensive file operations through natural language commands, enabling you to manage your codebase without leaving the conversation. Whether you need to create new components, read and understand existing code, make targeted edits, or reorganize your project structure, the AI handles file operations intelligently and efficiently.
File operations are available in Gather, Plan, and Agent modes. In Gather mode, the AI can only read files. In Plan and Agent modes, the AI can also create, edit, and delete files. Understanding how these operations work helps you make the most of the AI’s capabilities.
Reading Files
Reading files is the foundation of how the AI understands your codebase. When you ask about code or request changes, the AI reads relevant files to gather context and provide accurate responses.
Explicit File Reading
You can explicitly ask the AI to read and explain files:
When you ask the AI to read a file, it retrieves the contents and uses them to answer your question. This is useful when you want to understand specific code or need the AI to have context about a particular file before making changes.
Reading Multiple Files
For efficiency, you can ask the AI to read several related files at once:
Reading multiple files in a single request is more efficient than reading them one at a time. It also helps the AI understand how files relate to each other, leading to better responses about architecture and dependencies.
Automatic File Reading
In Agent mode, the AI automatically reads files as needed to complete your requests. When you ask it to modify a component, it reads the component file first to understand its current structure. When you ask about how something works, it searches for and reads relevant files.
You don’t need to explicitly tell the AI which files to read for most tasks. It uses semantic search and file path analysis to find relevant code automatically.
Creating Files
The AI can create new files with generated content, following your project’s patterns and conventions.
Creating Code Files
When you ask the AI to create a component, it generates appropriate code based on your project’s patterns. It examines existing components to understand your conventions for file structure, naming, imports, and styling.
Creating Configuration Files
The AI can analyze your codebase to find environment variable usage and generate appropriate example configurations.
Creating Directory Structures
When you specify a path that includes directories that don’t exist, the AI creates them automatically:
This creates the features, auth, and components directories if they don’t exist, then creates the LoginForm.tsx file.
You can also explicitly create directories:
Editing Files
The AI uses intelligent editing strategies to modify files efficiently and accurately. For most edits, it uses a search-and-replace approach that targets specific sections of code rather than rewriting entire files.
Smart Edits with Search/Replace
When you request a change, the AI identifies the specific code that needs to be modified and generates a targeted edit:
The AI reads the Button component, identifies where state should be added, and generates edits that add the loading state, update the render logic, and modify props as needed. Only the relevant sections are changed; the rest of the file remains untouched.
Benefits of Search/Replace Editing
This approach has several advantages over rewriting entire files:
Precision - Only the code that needs to change is modified. Unrelated code, comments, and formatting are preserved exactly as they were.
Speed - Editing specific sections is faster than regenerating entire files, especially for large files.
Safety - Smaller, targeted changes are easier to review and less likely to introduce unintended modifications.
Conflict Avoidance - When working with version control, smaller changes reduce the likelihood of merge conflicts.
Full File Rewrites
For new files or when significant restructuring is needed, the AI may rewrite the entire file:
The AI chooses between targeted edits and full rewrites based on the scope of changes needed. You can also explicitly request a full rewrite if you prefer.
Deleting Files
The AI can remove files and directories when requested:
For safety, the AI exercises caution with deletions:
- It confirms before deleting files that appear important or are referenced elsewhere
- It warns if deleting a file might break imports or dependencies
- It suggests alternatives like renaming or archiving when appropriate
File deletions are permanent and cannot be undone through the AI interface. Make sure you have version control or backups before deleting important files.
File Search
The AI provides multiple ways to find files and code in your project.
Search by Name
Find files by their path or filename:
Search by Content
Search inside files for specific text or patterns:
Semantic Search
For complex queries, the AI uses semantic understanding to find relevant code even when it doesn’t contain your exact search terms:
Semantic search understands the meaning of code, not just keywords. This makes it powerful for exploring unfamiliar codebases or finding code when you don’t know the exact terminology used.
Directory Structure
Understanding your project’s structure helps you navigate and organize code effectively.
The AI can provide both raw directory listings and explanations of how your project is organized.
Lint and Type Error Detection
The AI can identify and help fix code quality issues:
When fixing errors, the AI reads the error messages, understands the underlying issues, and generates appropriate fixes. It can handle common issues like missing types, unused variables, import errors, and style violations.
Best Practices
Use relative paths - Prefer relative paths from your workspace root for clarity and portability:
Be specific about location - When creating files, specify the exact path to avoid ambiguity:
Review changes before committing - Always check your git diff before committing AI-generated changes. Use git diff or your IDE’s source control view to verify all modifications.
Batch related operations - Group related file operations in a single request for efficiency:
Let the AI find files - Instead of specifying exact paths, describe what you’re looking for and let the AI search: