A structured methodology for building LLM systems through human-AI collaboration. Guides agents through requirements, flow design, utilities, data schema, node implementation, and optimization for reliable AI applications.
A structured methodology for building LLM systems through human-AI collaboration. This guide helps AI agents work with humans to design and implement complex AI applications using the PocketFlow framework.
**Humans Design, Agents Code!** This approach emphasizes:
1. Start with small, simple solutions
2. Design at a high level before implementation
3. Frequently ask humans for feedback and clarification
**What**: Clarify project requirements and evaluate AI system fit.
**Actions**:
- **Good for**: Routine tasks requiring common sense (filling forms, replying to emails)
- **Good for**: Creative tasks with well-defined inputs (building slides, writing SQL)
- **Not good for**: Ambiguous problems requiring complex decision-making (business strategy, startup planning)
**What**: Outline how your AI system orchestrates nodes at a high level.
**Actions**:
**Critical Rule**: If humans can't specify the flow, AI agents can't automate it! Manually solve example inputs first to develop intuition.
**Example Diagram**:
```mermaid
flowchart LR
start[Start] --> batch[Batch]
batch --> check[Check]
check -->|OK| process
check -->|Error| fix[Fix]
fix --> check
subgraph process[Process]
step1[Step 1] --> step2[Step 2]
end
process --> endNode[End]
```
**What**: Identify and implement utility functions needed by the flow.
**Actions**:
- Reading inputs (retrieving Slack messages, reading emails)
- Writing outputs (generating reports, sending emails)
- Using external tools (calling LLMs, searching the web)
- **Note**: LLM-based tasks (summarizing, analyzing) are NOT utilities—they're core functions
- Implement it
- Write a simple test
- Document input/output and necessity
**Example Utility**:
```python
from openai import OpenAI
def call_llm(prompt):
client = OpenAI(api_key="YOUR_API_KEY_HERE")
r = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": prompt}]
)
return r.choices[0].message.content
if __name__ == "__main__":
prompt = "What is the meaning of life?"
print(call_llm(prompt))
```
**What**: Design the shared store that nodes use to communicate.
**Actions**:
**Example**:
```python
shared = {
"user": {
"id": "user123",
"context": {
"weather": {"temp": 72, "condition": "sunny"},
"location": "San Francisco"
}
},
"results": {}
}
```
**What**: Plan how each node reads/writes data and uses utility functions.
**Actions**:
For each Node, describe:
**What**: Implement nodes and flows based on the design.
**Actions**:
**Example Node**:
```python
from pocketflow import Node
from utils.call_llm import call_llm
class GetQuestionNode(Node):
def exec(self, _):
user_question = input("Enter your question: ")
return user_question
def post(self, shared, prep_res, exec_res):
shared["question"] = exec_res
return "default"
class AnswerNode(Node):
def prep(self, shared):
return shared["question"]
def exec(self, question):
return call_llm(question)
def post(self, shared, prep_res, exec_res):
shared["answer"] = exec_res
```
**Example Flow**:
```python
from pocketflow import Flow
from nodes import GetQuestionNode, AnswerNode
def create_qa_flow():
get_question_node = GetQuestionNode()
answer_node = AnswerNode()
get_question_node >> answer_node
return Flow(start=get_question_node)
```
**What**: Evaluate results and optimize performance.
**Actions**:
- **Prompt Engineering**: Use clear, specific instructions with examples
- **In-Context Learning**: Provide robust examples for difficult-to-specify tasks
**Note**: Expect to iterate Steps 3–6 hundreds of times!
**What**: Ensure system robustness and handle edge cases.
**Actions**:
```
my_project/
├── main.py # Entry point
├── nodes.py # Node definitions
├── flow.py # Flow creation functions
├── utils/ # Utility functions
│ ├── __init__.py
│ ├── call_llm.py
│ └── search_web.py
├── requirements.txt
└── docs/
└── design.md # High-level, no-code documentation
```
1. **Documentation First**: Maintain `docs/design.md` with high-level, no-code design documentation
2. **One Utility, One File**: Dedicate one Python file per API call with a `main()` test function
3. **Design Before Code**: Complete Steps 1-5 before heavy implementation
4. **Iterative Development**: Expect many iterations—this is normal
5. **Fail Fast**: Use built-in retry mechanisms to quickly identify weak points
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/agentic-coding-guide/raw