This repository serves as a reference for setting up a context generation system for the Cursor AI IDE. It demonstrates how to create a comprehensive output file containing your project's context, enabling faster iterations and a better experience with Cursor AI.
The main components of this setup are:
.cursorcontext.sh
: A bash script that generates the context file.cursorrules
: A configuration file for custom rules and patternspackage.json
: Contains npm scripts for easy execution
The .cursorcontext.sh
script:
- Creates a single output file (
x.md
) in thedocs
directory - Generates a project structure tree
- Includes debug information and important file paths
- Adds the contents of
.cursorrules
- Incorporates log files (build, test, lint, coverage) if they exist
- Includes the contents of
package.json
- Adds the contents of all relevant source and test files
The generated x.md
file can then be used to provide comprehensive context to Cursor AI IDE.
The .cursorrules
file contains a set of rules that guide the behavior of the AI assistant. These rules help maintain consistency and avoid common pitfalls in AI-assisted development.
The rules cover various aspects such as:
- Verifying information
- Making file-by-file changes
- Avoiding unnecessary apologies or confirmations
- Preserving existing code structures
- Providing concise and relevant responses
These rules ensure that the AI assistant provides helpful and accurate assistance while respecting the project's existing structure and the developer's intentions.
The package.json
file includes scripts that make it easy to run the context generation process:
npm run share-files
: Runs the.cursorcontext.sh
script to generate the context filenpm run test-and-share
: Runs tests (if configured) and then generates the context
These scripts simplify the process of generating and updating the context file, making it easier to keep your AI assistant up-to-date with your project's latest state.
- Modify
.cursorcontext.sh
to include or exclude specific directories or file types - Adjust
.cursorrules
to add custom rules and patterns for your project - Update
package.json
scripts as needed for your workflow
To use this setup in your own project:
-
Copy
.cursorcontext.sh
,.cursorrules
, and the relevantpackage.json
scripts to your project -
Customize the variables at the top of
.cursorcontext.sh
as needed -
Run the context generation script using:
npm run share-files
-
Use the generated
docs/x.md
file with Cursor AI IDE
This is a reference implementation and may need adjustments to work with your specific project structure and needs. It's provided as-is, without any guarantees, and is free to use and modify.
Bruno Palma