Context Groups: Defining collections of files as a single context for prompting

It would be nice to be able to define “context groups”, so that if i am working on a specific feature with, say, 8 different relevant files / state / api routes, i can define them all as one “group”, and then invoke that context within a prompt instead of needing to remember all the relevant files and tag them every time i want to start a new thread with that subject

5 Likes

Interesting idea…

So you would create groups of files, and perhaps also functions within files, and give the group a name, and then be able to @ the group?

FYI - there is already a few feature requests for the ability to ‘add all open files’ as context, which is kind of similar, but I can see why your idea is unique.

For reference, in case the impetus was similar:

4 Likes

Possible workaround:

Create folder with the grouped files and use the @ folder option to include it

Have not tested this but don’t see why it wouldn’t work ?

Though the cursor prompting is a black box so not sure what comes out at the other end - eg what is actually sent to cursor

3 Likes

exactly -

I find myself working on a handful of features at once, and needing to redo context many times over again for specific things, often times this spans up to 10 different files, but may only include a couple functions in each file. I find that i get much higher quality answers to prompts if i give the prompt all the files that touch a certain process / feature, with the least amount of extraneous context possible. Being able to quickly invoke “profile-notifications”, “filter-state”, “auth”, etc would save a lot of time.

3 Likes

unfortunately most of the time im working on projects where the location of certain files impact how they function and its not possible to rearrange things temporarily without breaking the app

2 Likes

I wonder if some sort of ‘canned responses’ feature could achieve the desired results, but also be adaptable to other scenarios as well.

You know how helpdesk software has canned responses, eg from a quick Google search:

https://www.helpdesk.com/help/what-are-canned-responses/

https://www.livechat.com/help/set-canned-responses

https://www.customerly.io/canned-response-templates

It seems Cursor already has the underlying mechanism for ‘tagging’ specific content through the @ symbols feature, but as you say some sort of flexible ‘grouping’ could be helpful.

Perhaps as a proof of concept, we could create a single file called canned_prompts.md or instruction_sets.md and establish some conventions in there like:


# Canned Prompts  

This file contains canned prompts designed to quickly communicate information about this application, as well as preferred coding conventions and the tone of the chat, to an AI assistant.  

Each prompt is demarcated by two hash symbols, ie ##.  

Only refer to the prompt you have been instructed to refer to.  

## Database
Look at these files to see how I create a database client class, export it and import it - file_1.js, file_2.js and file_3.js.  

## Token Cache
Look at this file to see how I implemented a persistent database store for my token cache - file_4.js.  

## Request Flow 
To be added...

## Authentication Flow
To be added...

## User Types
This application supports two user types:
01.  Internal Users with an Azure AD Account
02.  External Users with an Azure AD B2C Account 

## User Stories
To be added...

## Azure AD Tenants and Resources
This application interacts with two Azure AD Tenants:
01.  An Organisation's Azure AD Tenant, which contains Internal User accounts, Azure Web App Resources and Application Registrations.  
02.  An Organisation's Azure AD B2C Tenant, which contains External User accounts, an Application Registration and Sign In Policy. 

## Coding Conventions
To be added...

## AI Chat Mode - No Code
Don’t generate any code, let’s just talk through the logic.  

## AI Chat Mode - Succinct 
Be brief and succinct and don’t repeat yourself.  

## AI Chat Mode - Encouraging 
Remind me of my goals and achievements and encourage me to keep going and stay focussed.  

## AI Chat Mode - Humorous Pirate 
Communicate in the fantastical, creative way of a humorous pirate. 

## Low Hanging Fruit Check - Security Best Practices 
Please provide a list of 'low-hanging fruit' security best practices for a Node/Express application, a short explanation of each, and review my codebase to see if I have implemented them or not.  Be concise and succinct.  

## Readme  
Look at the README.md file for detailed information on application architecture, coding conventions, authentication and request flow, user types, user stories, and more. 

## Review Main Goal Status   
My main goal is to create an application that:
 - Is operational
 - Follows security best practices 
 - Is scalable 
 - Looks great 
 - And that I am proud of and confident in    

Please create a checklist for each of these categories and review my codebase against each of them to check what I have already implemented and what remains to be done.  Be concise and succinct.

And then we could just @ that one file and say something like:

@ canned_prompts.md , Refer to the Database and Token Cache canned prompts and follow the same conventions to implement a database store for persistent session storage. Activate ‘AI Chat Mode - Encouraging’.

(and maybe the Cursor team could enable files to be automatically opened when referenced in a canned prompt :slightly_smiling_face:, come to think of it, that functionality might already be available - Edit: i tried in Ctrl + L (normal and interpreter modes) and Ctrl + I but it wouldn’t open the files when instructed to from the canned prompts :sweat_smile:)

Update:

When i add Activate ‘AI Chat Mode - Encouraging’ to my chats it is awesome, truly energizing!

4 Likes

that seems like a pretty solid approach if custom tagging turned out to be too difficult to implement.

1 Like

This is great!! I used similar approach to get multiple “roles” / “personalities” to solve prompts together - eg a web dev, copywriter and project manager. Just create text files for each of their names describing their role - then @ mentioning them in prompt.

2 Likes

Put these in a separate mode file - so i can just @mode it

Can even make it shorter - by having folder with funny pirate and nocode files.

3 Likes

@imrat - are the files where the different ‘modes’ specified named like this?

without any file extensions?

mode_funny
mode_nocode
mode_encouraging

So you are just using the @ Files symbol to mention one mode?

(or the @ Folders symbol to mention multiple modes at once?)

If not, I am just wondering if I have overlooked an @ Mode symbol?

2 Likes

i have prompts/ or roles/ folder
in it i have text files without extension

eg

funny
brief
nocode
tailwind

that way - @tailwind allows easy selection

or in cmd+shift+i mode - create a convo and add the relevant role files

then in .cursorrules have something like:
never change files in /prompts/
use /prompts/ for customising your response

1 Like

@connor,

So as an immediate solution you could either:

  • Create 1 file for each canned prompt:

    • canned_prompt_1
    • canned_prompt_2
    • canned_prompt_3
  • Create 1 file that had all the canned prompts within it

    • canned_prompts

And then you could just @ either:

  • the specific canned_prompt file

  • the single canned_prompts file
    (and reference the relevant entry)

Example canned prompt files below.

Multiple Canned Prompts File

# Canned Prompts  

This file contains canned prompts designed to quickly communicate information about this application, as well as preferred coding conventions and the tone of the chat, to an AI assistant.  

Each prompt is demarcated by two hash symbols, ie ##.  

Only refer to the prompt you have been instructed to refer to.  

## Canned Prompt 01
Look at these files to see how I do scenario 01 - file_1.js, file_2.js and file_3.js.  
  
## Canned Prompt 02  
Look at this file to see how I do scenario 02 - file_4.js.     

## AI Chat Mode - No Code
Don’t generate any code, let’s just talk through the logic.  

## AI Chat Mode - Succinct 
Be brief and succinct and don’t repeat yourself.  

## AI Chat Mode - Encouraging 
Remind me of my goals and achievements and encourage me to keep going and stay focused.  

## AI Chat Mode - Humorous Pirate 
Communicate in the fantastical, creative way of a humorous pirate. 

Single Canned Prompt File

# Canned Prompt 01    

This file contains a canned prompt designed to quickly communicate information about this application.  

Look at these files to see how I do scenario 01 - file_1.js, file_2.js and file_3.js.  

I’ve personally gone with the single command_prompts file.

And I gave it an .md extension because I love the syntax highlighting my editor has for markdown files.

4 Likes

@connor
The workaround I do for the moment is to select all the relevant files in the file browser, and drag them into the chat.

Even if the files are spread in different folders, using ctrl + click is still quite fast.

It’s not ideal, but it’s better than manually finding each file with @, which I find tedious.

Good luck.

1 Like