Image missing.
Prompt engineering playbook for programmers

created: June 4, 2025, 3:58 p.m. | updated: June 5, 2025, 9:54 p.m.

In prompt engineering terms, this is sometimes called “ few-shot prompting ,” where you show the AI a pattern to follow. ❌ Poor Prompt: “Why isn’t my mapUsersById function working?”AI’s response to the poor prompt (simulated):It’s hard to say without more information. Let’s see two prompting approaches:❌ Prompt 1 (Underspecified): “Refactor the above getCombinedData function.”AI’s response to Prompt 1:*Sure. Here's my code: const UserProfile = ({ userId }) => { const [user, setUser] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { fetchUser(userId).then(setUser).finally(() => setLoading(false)); }, [userId, setUser, setLoading]); // Problem is here return loading ? Prompt engineering for code generation is about guiding the AI to produce code that fits your needs and style.

3 days, 16 hours ago: Hacker News