Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Edmund Yong - Example Prompts for Cursor Agent
- For debugging:
- **Objective**: Debug and fix a crash in my Node.js app.
- **Context**: The app is in ./app.js and crashes with "Cannot read property 'length' of undefined" when I run `node app.js`.
- **Instructions**:
- - Run `node app.js` to reproduce the error.
- - Trace the error to the specific line in ./app.js.
- - Add a check to ensure the variable is defined before accessing .length.
- **Verification**: Run `node app.js` and confirm it runs without crashing.
- **Preferences**: Use GPT-4o model.
- For feature building:
- **Objective**: Write a Python function to sort a list of dictionaries by a given key.
- **Context**: I’m working in ./utils.py and need this for a data processing script.
- **Instructions**:
- - Create a function called `sort_by_key(data, key)` that takes a list of dictionaries and a key string.
- - Use Python’s sorted() with a lambda function.
- - Add docstring with an example.
- **Verification**: Test it with `data = [{'name': 'Bob', 'age': 25}, {'name': 'Alice', 'age': 30}]` and key='age', ensuring output is sorted ascending.
- **Preferences**: Write the code directly in ./utils.py.
- For Research and Implementation:
- **Objective**: Add JWT authentication to my Express.js app.
- **Context**: The app is in ./server.js, and I haven’t implemented authentication yet.
- **Instructions**:
- - Search the web for a simple JWT tutorial for Express.js.
- - Install required packages (e.g., `jsonwebtoken`) via npm.
- - Add a middleware function to verify tokens in incoming requests.
- **Verification**: Test with a sample route (e.g., GET /protected) and confirm it rejects requests without a valid token.
- **Preferences**: Use Yolo mode for npm installs.
Add Comment
Please, Sign In to add comment