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:
"Read src/utils/auth.ts and explain the authentication flow"
"Show me the contents of package.json and explain the dependencies"
"What configuration is in the .env.example file?"
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:
"Read Button.tsx, Button.css, and Button.test.tsx to understand the component"
"Show me all files in the components folder and explain how they're organized"
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
"Create a new React component called UserProfile in src/components"
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.
"Create a utility function for formatting dates in src/utils/dateFormatter.ts"
"Create a new API route for user registration in src/api/auth/register.ts"
Creating Configuration Files
"Create a .env.example file with placeholder values for all environment variables used in this project"
The AI can analyze your codebase to find environment variable usage and generate appropriate example configurations.
"Create a tsconfig.json with strict TypeScript settings"
"Create a .gitignore file appropriate for a Node.js project"
Creating Directory Structures
When you specify a path that includes directories that don’t exist, the AI creates them automatically:
"Create src/features/auth/components/LoginForm.tsx"
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:
"Create a new folder structure for a feature module at src/features/payments/"
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:
"Add a loading state to the Button component"
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.
"Fix the typo in the error message on line 45"
"Add TypeScript types to all functions in utils.ts"
"Update the API endpoint URL from /api/v1 to /api/v2"
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:
"Rewrite this configuration file to use ES modules instead of CommonJS"
"Replace the contents of README.md with comprehensive documentation"
"Convert this JavaScript file to TypeScript with full type annotations"
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:
"Delete the deprecated old-component.tsx file"
"Remove the unused legacy/ folder and all its contents"
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:
"Find all files named config"
"Search for files containing 'auth' in the filename"
"Find all .test.ts files in the project"
"List all files in the src/components directory"
Search by Content
Search inside files for specific text or patterns:
"Find all files that import React"
"Search for TODO comments in the codebase"
"Find where getUserById is defined"
"Search for all uses of the deprecated API"
Semantic Search
For complex queries, the AI uses semantic understanding to find relevant code even when it doesn’t contain your exact search terms:
"Find code related to user authentication"
"Where is the payment processing logic?"
"Show me how errors are handled in this project"
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.
"Show me the directory tree"
"What's the folder structure of src/?"
"List all top-level folders and explain what each contains"
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:
"Check for lint errors in this file"
"Fix all TypeScript errors in the project"
"Find and fix ESLint warnings in src/components/"
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:
"Edit src/components/Button.tsx"
Be specific about location - When creating files, specify the exact path to avoid ambiguity:
"Create UserCard.tsx in src/components/users/"
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:
"Create a new feature folder with index.ts, types.ts, and utils.ts files"
Let the AI find files - Instead of specifying exact paths, describe what you’re looking for and let the AI search:
"Find and update the user validation logic"