Loading lesson…
Loading lesson…
By mastering some practical techniques, you can make your collaboration with AI more efficient.
Bad description:
This feature has a problem
Help me optimize it
Good description:
After the user clicks the "Submit" button, the form is not submitted
The browser console reports: Uncaught TypeError: Cannot read property 'value' of null
The error occurs on line 23 of form.js
This list loads very slowly and has 1000 items
Please help me add pagination with 20 items per page
Key points:
Bad approach:
Help me implement login, registration, password recovery, profile center,
password change, and email verification
Good approach:
Implement the login feature first, with these requirements:
- Email and password login
- Remember login state
- Error messages
(After it is done) Now implement the registration feature
(After it is done) Now implement the password recovery feature
Key points:
Bad approach:
Good approach:
Key points:
Technique 1: refer to previous conversation
Implement according to the plan we just discussed
Refer to the previous getUserList function
Technique 2: provide related code
This is the existing user model code:
[paste code]
Please implement the article model in the same style
Technique 3: explain project background
This is an e-commerce project using React + Node.js
It already has a user system and a product system
Now we need to add a shopping cart feature
Scenario: you solved a complex problem
How to do it:
Example:
Create a document under docs/solutions/:
# Solving the N+1 Query Problem
## Problem Description
When fetching the article list, the system queries the author information once per article,
which causes a performance problem.
## Solution
Use a JOIN query to fetch all the data in one go:
```sql
SELECT articles.*, users.name as author_name
FROM articles
LEFT JOIN users ON articles.author_id = users.id
Result: query time dropped from 2000ms to 50ms
Technique 1: ask "why" first
Why does this code cause a memory leak?
Why should we use useCallback instead of a normal function?
Technique 2: ask for multiple options
What are the different ways to implement user authentication?
What are the pros and cons of each?
Technique 3: ask for explanations
How does this code work?
Can you explain this algorithm in detail?