
ask before you search.
When you ask an AI coding tool like Copilot or ClaudeCode a question about your project, it is not reading every file to get you an answer. It is most likely just running a search tool called **grep** to jump straight to the lines that it thinks are related to your prompt. This is a cost effective decision to getting a good enough answer, similar to like when you skim read in school, you can flip through the page and still get just enough information to answer a question. Like all shortcuts though, this practice also carries a cost.
What is Grep?
Grep acts as a Ctrl+F for your entire project. You give it a word, it searches every file, and it prints back the line where your search word appears.
(g/re/p, "globally search for a regular expression and print")
# Find every place your project mentions "checkout"
grep -r "checkout" .- grep — the search tool itself
- -r — "recursive": search inside every folder, and every folder inside that
- "checkout" — the word you're looking for, kept in quotes
- . — where to start looking (a single dot means "the folder I'm in right now")
🧭 Before You Start: Open a Terminal in Your Project
On a Mac, open the Terminal app (press ⌘ + Space and type "terminal"). On Windows, open PowerShell — grep's commands work there through tools like Git Bash, which installs with Git. Then point the terminal at your project folder:
# Move into your project folder (drag the folder onto the
# terminal window after typing "cd " to fill in the path)
cd ~/Projects/my-app
# Confirm where you are
pwd💬 How Do I Search Through My Codebase?
Start with the word a customer would see on the screen — a button label, a headline, an error message. Screen text is the fastest way into an unfamiliar codebase, because it appears exactly once or twice and takes you straight to the file that controls it.
# Where does my site say "Start free trial"?
grep -rn "Start free trial" .
# Not sure about capitalization? Add -i (ignore case)
grep -rni "start free trial" .🖼️ How Do I Find Every .png File in My Project?
Grep searches inside files, so to find files by name you pair it with find, which lists every file in your project. Pipe that list through grep with the | symbol and you've filtered thousands of files down to just the images:
# List every .png image in your project
find . | grep -i "\.png$"
# Which files USE a specific image? Search contents for its name
grep -rn "hero-banner.png" .🎯 How Do I Search Only Certain Files — or Skip the Junk?
# Only look inside one kind of file
grep -rn "price" . --include="*.tsx"
# Skip node_modules (installed packages you didn't write)
grep -rn "price" . --exclude-dir=node_modules
# Just tell me WHICH files match, not every line
grep -rl "stripe" . --exclude-dir=node_modules📋 The Cheat Sheet
| You want to say | Add this | Example |
|---|---|---|
| Search every folder inside this one | -r | grep -r "refund" . |
| Ignore capitalization | -i | grep -ri "Contact Us" . |
| Show me line numbers | -n | grep -rn "FAQ" . |
| Just list matching files | -l | grep -rl "apiKey" . |
| Count the matches per file | -c | grep -rc "TODO" src |
| Show lines that DON'T match | -v | find . | grep -v test |
| Only search this file type | --include | grep -r "logo" . --include="*.css" |
| Skip a folder entirely | --exclude-dir | grep -r "key" . --exclude-dir=node_modules |
🤖 How Do I Direct an LLM to Search My Codebase?
Here's the part that pays off twice. AI coding tools run grep behind the scenes every time they explore your project — so once you speak grep, you can steer them. Instead of a vague "fix my pricing page," hand the model a searchable string and a scope. Specific, grep-shaped prompts get faster answers and fewer wrong guesses:
Grep for "Start free trial" in this project and list every
file and line number where it appears. Don't change anything yet.
Search the codebase for where the monthly price is set.
Start by grepping for "$29" and "price". Report what you find.
Grep for every .png referenced in src/ and tell me which
ones no longer exist in the public folder.- Give it the exact string — quote the button text or error message you see on screen, capitalization and all
- Set the scope — "search src/ but skip node_modules" saves the model from drowning in installed packages
- Ask for locations first, changes second — "list file and line numbers, don't edit yet" keeps you in control
- Check its work yourself — run the same grep it claims to have run; if your terminal finds 12 matches and the model mentions 3, keep asking
🧯 If You Get No Results
- Zero results isn't an error — it usually means the search is case-sensitive, so retry with -i
- Check you're standing in the right folder: run pwd, and cd into your project if you're not
- Search a shorter piece of the phrase — screen text sometimes gets split across lines in code
- If the terminal seems stuck printing forever, press Ctrl + C to stop it — nothing is harmed
That's the whole skill. You can now answer "where does my site say that?", "which files use this image?", and "where is this price set?" in seconds — the same first move every engineer and every AI tool makes. The step-by-step guides at unparty.app build on exactly this kind of investigation, one small command at a time.
“Every investigation starts with a search. Now you know how to run one.”
— unparty-app