File structure passing

Can we have a possibility to send our currently full file structure with full folder and file names from workpace we working on to a model that could be useful to get some suggestions from the LLM

2 Likes

Hi @bulawow ,

Have you seen these:

https://docs.cursor.com/context/@-symbols/@-folders

https://docs.cursor.com/context/@-symbols/@-files

Is that the type of functionality you are looking for?

Can you provide an example of the type of question/prompt you want to supply to Cursor?

1 Like

No i mean passing whole workspace structure like this for a model

project-root/
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   β”œβ”€β”€ index.html
β”‚   β”‚   β”œβ”€β”€ favicon.ico
β”‚   β”‚   └── manifest.json
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.js
β”‚   β”‚   β”‚   └── Navigation.js
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.js
β”‚   β”‚   β”‚   β”œβ”€β”€ About.js
β”‚   β”‚   β”‚   └── Contact.js
β”‚   β”‚   β”œβ”€β”€ styles/
β”‚   β”‚   β”‚   β”œβ”€β”€ main.scss
β”‚   β”‚   β”‚   └── variables.scss
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   β”œβ”€β”€ api.js
β”‚   β”‚   β”‚   └── helpers.js
β”‚   β”‚   β”œβ”€β”€ App.js
β”‚   β”‚   └── index.js
β”‚   β”œβ”€β”€ package.json
β”‚   └── webpack.config.js
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”‚   β”œβ”€β”€ userController.js
β”‚   β”‚   β”‚   └── productController.js
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   β”œβ”€β”€ User.js
β”‚   β”‚   β”‚   └── Product.js
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ userRoutes.js
β”‚   β”‚   β”‚   └── productRoutes.js
β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js
β”‚   β”‚   β”‚   └── errorHandler.js
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── database.js
β”‚   β”‚   └── server.js
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   β”œβ”€β”€ unit/
β”‚   β”‚   β”‚   └── userModel.test.js
β”‚   β”‚   └── integration/
β”‚   β”‚       └── userRoutes.test.js
β”‚   β”œβ”€β”€ package.json
β”‚   └── .env
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ migrations/
β”‚   β”‚   β”œβ”€β”€ 001_create_users_table.sql
β”‚   β”‚   └── 002_create_products_table.sql
β”‚   └── seeds/
β”‚       β”œβ”€β”€ users.sql
β”‚       └── products.sql
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ api-spec.md
β”‚   └── deployment-guide.md
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ deploy.sh
β”‚   └── backup-db.sh
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
└── docker-compose.yml
1 Like

And then would you ask a question like:

Can you give me some advice on the structure of my application?

Is that the type of question you want to ask Cursor?

Is that why you want to pass it the folder structure specifically?

I could ask to rearange the workspace for me in a certain way

I could ask if this file structure is alright for certain standards

I could ask the model to analyze certain files inside a folder and ask if they are a good fit for the place they are currently placed at or to swap it somewhere else

Before creating new feature first i could explain what feature i am working on and ask the model what is the best place for it in the workspace

There is probably countless more possibilities i just cant think of more

1 Like

You can ask this question in the chat or in Composer:
Show me the structure of my project. Then, you can keep asking more questions about the structure. I just checked, and it works.

2 Likes

Ye but it skips folders that don’t have any files and simply just skipps some files/folders if the workspace is big so having normal implementation of that instead of leaving ai to create it will be just better and more reliable

Show me the structure of my project

I tried this on a medium-sized codebase, and it only catches a few files. That’s one of my main topic of interest actually, is how to ask AI to document the structure/architecture of my project.

Haven’t found a compelling solution so far.

Really nice recommendation, perhaps the feature can search for files (excluding the contents of the file) and in addition to the file tree also provide small descriptions for each file (to keep the text to a minimum). Might help withhe AI not assuming files doesn’t exist.

I came to this post from a google search looking for the same thing. I’m disappointed to learn that this feature does not exist yet. When working on a codebase that isn’t mine, I sometimes find it hard to find where a feature might be implemented. Ctrl+Enter works on smaller codebases, but on a bigger one it does not always seem to find the relevant files even after repeatedly trying again and again using different prompts. I would find it very helpful if we could send the entire file structure to the LLM so that it can then suggest files to look into based solely on their name and path.

I’ve been wanting this too (I was thinking a @FileStructure command) and its come up several times where I’ve needed it. One example is expo router, where it’s nice to query about the file structure to understand the stack/tab etc layouts. But I’ve had a number of other times where I’ve found myself wanting it, so I don’t think it’s very niche and would be useful to a number of people

I haven’t tried that yet, but could including the file structure in a file that we then add as context make any sense? Maybe the output of a tree command or something like that? Then one could figure out how to generate this automatically every time we change something in the project. Or just add a task to execute ad-hoc. Then maybe even ignore the structure file to not include it in the git changes.

@petros nice idea, here is a quick shot at it:

  1. Run the following command: git ls-tree -r --name-only HEAD | grep -v -E '(vendor|public|seeds|migrate)' > tree.txt

This will create a tree.txt file at the root of the project with all the files except:

  • The ones ignored as per the .gitignore
  • The folders specified in the grep command

To display this in a human readable way you can add | tree --fromfile but I wsa thinking that repeating full pathnames was probably more useful for AI ingestion.

  1. Go to the composer and type:
Using the file @tree.txt  please establish as many needed steps to analyse 
the files that you need, and write a comprehensive ARCHITECTURE.md file 
that should be the go-to place for a developper who need to understand the 
birds-eye view of the whole project, or details about any of its components.

The result is that the composer (with agents) did 3 steps by itself and produced a pretty comprehensive architecture document. This is not perfect and need to be improved, but it is already a good start!

Anybody welcome to improve based on that flow!

2 Likes

Thought this was a super sensible and obvious idea. Didn’t want to have to keep manually updating the tree, so I created AutoContextTree, a VS Code/Cursor extension which updates the tree automatically whenever you make a git commit.

1 Like

Just spent more time trying and failing to publish with a Microsoft Personal Access Token than it took to create the extension, sigh! Just use the GitHub.