Give your Ai assistant a map of your project
One of the things I am really bad at is deciding where to put a file in a project. I realized that I can let AI solve that for me by giving it more context on the project with a map of the project or a specific folder. I like to use tree to get this.
Using tree
In Aider I /run tree -I node_modules
and add it to the chat. Then I /ask
Aider where to put the file I want to create.
This is what the tree output looks like from the command above. -I
is ignore.
├── jsconfig.json
├── package.json
├── pnpm-lock.yaml
├── README.md
├── src
│ ├── app.css
│ ├── app.html
│ ├── lib
│ │ └── images
│ │ ├── github.svg
│ │ ├── svelte-logo.svg
│ │ ├── svelte-welcome.png
│ │ └── svelte-welcome.webp
│ └── routes
│ ├── +layout.svelte
│ ├── +page.js
│ ├── +page.svelte
│ ├── about
│ │ ├── +page.js
│ │ └── +page.svelte
│ ├── Counter.svelte
│ ├── Header.svelte
│ └── sverdle
│ ├── +page.server.js
│ ├── +page.svelte
│ ├── game.js
│ ├── how-to-play
│ │ ├── +page.js
│ │ └── +page.svelte
│ └── words.server.js
├── static
│ ├── favicon.png
│ └── robots.txt
├── svelte.config.js
└── vite.config.js
Using ls
If you don't have tree installed you can do this with ls -R1
which will list all the files in a single column.
node_modules/
package.json
pnpm-lock.yaml
README.md
src/
static/
svelte.config.js
vite.config.js
./node_modules:
@fontsource/
@neoconfetti/
@sveltejs/
svelte@
vite@
./node_modules/@fontsource:
fira-mono@
./node_modules/@neoconfetti:
svelte@
./node_modules/@sveltejs:
adapter-auto@
kit@
vite-plugin-svelte@
./src:
app.css
app.html
lib/
routes/
./src/lib:
images/
./src/lib/images:
github.svg
svelte-logo.svg
svelte-welcome.png
svelte-welcome.webp
./src/routes:
+layout.svelte
+page.js
+page.svelte
about/
Counter.svelte
Header.svelte
sverdle/
./src/routes/about:
+page.js
+page.svelte
./src/routes/sverdle:
+page.server.js
+page.svelte
game.js
how-to-play/
words.server.js
./src/routes/sverdle/how-to-play:
+page.js
+page.svelte
./static:
favicon.png
robots.txt
Misc Terminal ways
Unfortunately macOs terminal ls
command can't exclude files or directories. However these commands can.
**ls + grep **
# pipe to grep
ls -R | grep -v node_modules
# pipe to grep with multiple exclusions
ls -R | grep -vE "(node_modules|\.git|dist)"
**find **
# Single exclude
find . -name node_modules -prune -o -print
# Multiple excludes
find . -name node_modules -prune -o -name .git -prune -o -print
Another alternative for macOs is to install the GNU coreutils
brew install coreutils
gls
# ignore flag
gls -R1 --ignore=node_modules
gls -R1Inode_modules