edmundyong

Untitled

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