Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding AI Agent Rules (Cursor + Copilot) #371

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .cursorrules.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# [PROJECT NAME]

## PROJECT DESCRIPTION
- [PROJECT DESCRIPTION - What is the goal of the project? What is the purpose of the project?]

## AI AGENT ROLE
- [AI AGENT ROLE - What is the role of the AI agent? What is the goal of the AI agent? Example ↴]
- You are a senior software engineer with great experience in [PROJECT LANGUAGE] and [PROJECT TECHNOLOGY].
- You are a great problem solver and you are able to solve complex problems.

## CODING STYLE AND STRUCTURE
- [How do you want the agent to write the code? What is the coding style and structure?]
- Prefer iteration and modularization over code duplication
- Use descriptive variable names with auxiliary verbs
- Write concise, technical TypeScript code with accurate examples

## Error Handling
- [How do you want the agent to handle errors?]
- Implement proper error boundaries
- Log errors appropriately for debugging
- Provide user-friendly error messages
- Handle network failures gracefully

## Testing
- [How do you want the agent to handle testing?]
- Write unit tests for utilities and components
- Implement E2E tests for critical flows
- Test across different Chrome versions
- Test memory usage and performance

## Security
- [How do you want the agent to handle security?]
- Implement Content Security Policy
- Sanitize user inputs
- Handle sensitive data properly
- Follow Chrome extension security best practices
- Implement proper CORS handling
26 changes: 26 additions & 0 deletions .github/copilot-instructions.md.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copilot Guidelines

This project <PROJECT_NAME> uses <TECH_STACK>.

## Project Structure
Structure of how project files are setup. Making changes to files should be in their respected file.
```
| App | Description |
|-----------|-----------------------------------------------------------------------------|
| api | Contains serverless functions designed to run separately from the main app e.g. webhooks and cron jobs. |
| app | The main application, featuring a shadcn/ui template. |
| docs | The documentation, which contains the documentation for the app e.g. guides and tutorials. |
| email | The email preview server from react.email. |
| storybook | The storybook, which contains the storybook for the app. |
| studio | Prisma Studio, which is a graphical editor for the database. |
| web | The website, featuring a twblocks template. |
```

## Nesting
- Avoid deeply nested code. Break down logic into smaller functions.
- Opening curly braces should be on the same line as the statement.

## Error Handling
- Always catch a specific error instead of a generic one.
- Log the error message and stack trace.

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ yarn-error.log*
.env.sentry-build-plugin

# BaseHub
.basehub
.basehub

# AI Rules
.cursorrules
.github/copilot-instructions.md
26 changes: 26 additions & 0 deletions docs/features/ai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,29 @@ export const provider = createAnthropic({
apiKey: env.ANTHROPIC_API_KEY,
});
```

## Customizing the AI agent rules

To those that use Cursor or GitHub Copilot - You can customize the AI agent rules by updating the respected file listed below. For context, each chat response will read through the file and repspond with a more currated response based on your rules. It is important to

> **Important:**
> Keep your instructions short and precise. Poor instructions can degrade Cursor and Copilots quality and performance.


#### Cursor

Update the `.cursorrules` file to customize the AI agent to your project needs. These rules can be updated at any time and will better help you over time.

Great examples of how to customize your Cursor Rules can be found in this repository: [awesome-cursorrules](https://github.com/PatrickJS/awesome-cursorrules).

Learn more about [Cursor Rules](https://docs.cursor.com/context/rules-for-ai).

#### GitHub Copilot

In order to begin using Copilot Instructions, you must first enable the `Use Instruction Files` setting in VSCode.

Update the `.github/copilot-instructions.md` file to customize the AI agent to your project needs. These instructions can be updated at any time and will better help you over time.

Learn more about [GitHub Copilot Instructions](https://docs.github.com/en/copilot/customizing-copilot/adding-custom-instructions-for-github-copilot).

*It is important to note that AI outputs may still include hallucinations or inaccuracies, so always review and validate the generated suggestions.*
Loading