Tell the AI what the code is trying to do.
GOALS = {
"order-processing": "A system that charges customers and updates inventory.",
"log-parser": "A tool that reads log lines and counts errors.",
}
PRIORITIES = ["security", "speed", "clarity"]
def review(goal, priority):
intent = GOALS[goal]
print()
print("Reviewing for %s" % priority)
print("Goal: %s" % intent)
focus_map = {
"security": "Look for injection, secrets, untrusted input.",
"speed": "Look for repeated work and unnecessary copies.",
"clarity": "Look for unclear names and long functions.",
}
print("Focusing: %s" % focus_map[priority])
Before you run it, say out loud what it will print. Then open the answer.
What it prints
GOALS = {
"order-processing": "A system that charges customers and updates inventory.",
"log-parser": "A tool that reads log lines and counts errors.",
}
PRIORITIES = ["security", "speed", "clarity"]
def review(goal, priority):
intent = GOALS[goal]
print()
print("Reviewing for %s" % priority)
print("Goal: %s" % intent)
focus_map = {
"security": "Look for injection, secrets, untrusted input.",
"speed": "Look for repeated work and unnecessary copies.",
"clarity": "Look for unclear names and long functions.",
}
print("Focusing: %s" % focus_map[priority])
Without the goal, the review only sees the surface it can show.