Skip to content

Commit baa6632

Browse files
committed
note
1 parent 4f489a0 commit baa6632

File tree

1 file changed

+212
-0
lines changed

1 file changed

+212
-0
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# Guide to AI Assisted Engineering
2+
3+
Source: <https://getdx.com/uploads/guide-to-ai-assisted-engineering.pdf>
4+
5+
## 1. Part 1 - AI Prompting Techniques
6+
7+
### 1.1. Meta-prompting
8+
9+
- The technique of embedding instructions within a prompt to help a model understand how to approach and respond to the task.
10+
- An example:
11+
12+
```prompt
13+
Don't
14+
15+
Fix this Spring Boot error: [error details]
16+
```
17+
18+
```prompt
19+
Do
20+
21+
Debug the following Spring Boot error: [paste error details]
22+
23+
- Identify and explain the root cause.
24+
- Provide a fixed version of the problematic code.
25+
- Suggest best practices to prevent similar issues in the future.
26+
27+
Output should follow this format:
28+
29+
1) Error Message & Stack Trace (Summarized).
30+
2) Root Cause Analysis (Explain why the error happened).
31+
3) Fixed Code (With comments).
32+
4) Preventive Measures (Best practices to avoid this issue).
33+
```
34+
35+
### 1.2. Prompt-chaining or recursive prompting
36+
37+
- One of the most powerful best practices that can be utilized is to create a full workflow rather
38+
than a single prompt, where the output of one prompt becomes the input to another. You can
39+
chain multiple tasks together that build on the previous output, and even switch model types
40+
in between.
41+
- An example:
42+
43+
```prompt
44+
Do
45+
46+
I am a mobile developer, and you are a senior React Native architect. Let's have a
47+
brainstorming session where you ask me one question at a time about the
48+
following requirements, and come up with a specification. I have a mobile
49+
application that currently uses two separate code bases and build processes for
50+
iOS and Android. I want to migrate this app to React Native so that I can unify the
51+
codebase and build process
52+
```
53+
54+
- As an example, the first question the LLM asks might be:
55+
56+
```text
57+
1. What are the main features and functionalities of your existing mobile app across both
58+
iOS and Android?
59+
60+
(Think screens, workflows, integrations, and anything that might differ between
61+
platforms.)
62+
```
63+
64+
- After a series of questions, one at a time as specified, the LLM will let you know that it has reached its final question.
65+
- Once you answer the final question, the LLM will build a blueprint specification. You can then use this specification with a reasoning model to create a step-by-step process, including prompt examples, which can be followed to create the app. Meta-prompting can ensure that the output follows a repeatable process.
66+
67+
### 1.3. One-shot or few-shot vs. zero-shot prompting
68+
69+
Similar to meta-prompting, providing examples of the kind of output you are looking for can
70+
result in much more accurate and comprehensive results from the assistant. This can help the
71+
model learn from existing examples and provide better structure in its output. A zero-shot
72+
prompt simply asks the assistant to produce some output without scoped precedent, whereas
73+
a one-shot (providing a single output example) or a few-shot (providing multiple examples)
74+
can save multiple cycles of refining and improving answers.
75+
76+
```prompt
77+
Don't
78+
79+
Write a Spring Boot REST API with a /hello endpoint
80+
```
81+
82+
```prompt
83+
Do
84+
85+
Here is an example of a structured REST API design:
86+
87+
88+
@RestController
89+
90+
@RequestMapping("/users")
91+
92+
public class UserController {
93+
94+
private final UserService userService;
95+
96+
public UserController(UserService userService) {
97+
98+
this.userService = userService;
99+
100+
}
101+
102+
@GetMapping("/{id}")
103+
104+
public ResponseEntity<UserDTO> getUser(@PathVariable
105+
Long id) {
106+
107+
return
108+
ResponseEntity.ok(userService.getUser(id));
109+
110+
}
111+
112+
}
113+
114+
Now generate a HelloController that:
115+
- Uses a HelloService layer@
116+
- Returns a DTO instead of plain strings@
117+
- Follows RESTful response conventions (ResponseEntity,
118+
proper status codes).
119+
```
120+
121+
### 1.4. System prompt updates for better accuracy
122+
123+
One of the most effective ways to use this system prompt is by creating a feedback loop between users of the assistant and the model owners who configure the assistant platform organizationally. When the model creates inaccurate or suboptimal output, in many cases that output can be corrected going forward by changing the system prompt.
124+
125+
### 1.5. Multi-model or adversarial engineering
126+
127+
Basic workflow:
128+
129+
- Define the task.
130+
- Prompt both AI models.
131+
- Adversarial cross-testing.
132+
- Evaluate feedback.
133+
- Declare a winner.
134+
135+
### 1.6. Multi-context: use images and voice prompting
136+
137+
There are more ways to engage with copilots than just typing in prompts. Participants
138+
reported that voice-to-text prompting can speed up code assistant usage by 30% or more.
139+
Using images such as flow charts and roadmap visualizations can reduce the amount of
140+
prompting and typing considerably.
141+
142+
### 1.7. Understand determinism and non-determinism
143+
144+
Determinism can be controlled using temperature, a system parameter that adjusts the randomness of token selection.
145+
146+
A lower temperature (i.e., “0.1” as opposed to “0.9”) makes the model more deterministic by favoring high-probability tokens, leading to consistent and repeatable outputs. Conversely, a higher temperature (i.e., “0.9” or above) increases randomness, fostering creativity but reducing predictability.
147+
148+
## 2. Part 2 - Recommend use cases
149+
150+
### 2.1. Stack trace analysis
151+
152+
```prompt
153+
Analyze this Java stack trace and suggest the root cause and potential fixes: [Insert stack trace and additional error detail if appropriate]
154+
```
155+
156+
### 2.2. Refactoring existing code
157+
158+
```prompt
159+
Refactor this Java function to improve readability and efficiency: [Insert longer explanation, context, and code]
160+
```
161+
162+
### 2.3. Mid-loop code generation
163+
164+
```prompt
165+
Complete this Java function: [Example Function and additional context, metaprompts, etc]
166+
```
167+
168+
### 2.4. Test case generation
169+
170+
```prompt
171+
Generate JUnit test cases for the following Java class: [Insert class]
172+
```
173+
174+
### 2.5. Learning new techniques
175+
176+
```prompt
177+
I have five years of experience writing Java and Spring. Show me how to create a Java 24 virtual thread in Spring
178+
```
179+
180+
### 2.6. Complex query writing (SQL, Regex, CLI commands)
181+
182+
Sometimes developers will need to generate complex patterns or queries such as regular
183+
expression patterns or SQL queries. Rather than context switch to a different coding or pattern
184+
framework, AI coding assistants can generate code-native expressions for you.
185+
186+
### 2.7. Code documentation
187+
188+
Once you’ve finished writing some code, a code assistant can help you comment that code for
189+
better understandability and readability. It can also generate actual documentation in markup
190+
formats like AsciiDoc and LaTeX.
191+
192+
### 2.8. Brainstorming and planning
193+
194+
Using a generative AI tool to plan out your work can be very effective, especially when using a
195+
recursive workflow as described in the workflows and prompting techniques section above.
196+
197+
### 2.9. Initial feature scaffolding
198+
199+
Using a generative AI tool to plan out your work can be very effective, especially when using a
200+
recursive workflow as described in the workflows and prompting techniques section above
201+
202+
```prompt
203+
Create the code outline for a Java application that will listen on a Kafka topic and
204+
create a multicast pattern to a Postgres endpoint, a RESTFul POST endpoint, and
205+
an SMTP endpoint.
206+
```
207+
208+
### 2.10. Code explanation
209+
210+
Rather than pore over unfamiliar code or try to chase down the initial authors of the code, a
211+
code assistant can provide valuable insights into the functionality of existing code. This can be
212+
especially helpful when trying to interpret code in frameworks you may be less familiar with.

0 commit comments

Comments
 (0)