Mastering Context Engineering (4): Practice - Development Workflow
Mastering Context Engineering (4): Practice - Development Workflow
"AI is not a tool but a collaborator. Collaborators need context."
Introduction
In the previous article, we completed project setup. You have CONTEXT.md and .cursorrules.
Now the question is: How do you use it daily?
This article covers specific workflows for applying Context Engineering in daily development.
Part 1: Context-First Conversation Patterns
1.1 Basic Principle
Before (No Context):
"Build a login feature"
After (Context First):
"I'm working on authentication in our system.
[Current Situation]
- Express + PostgreSQL based
- Currently using session-based auth
- Mobile app launch planned
[Goal]
Transition to JWT-based authentication
[Constraints]
- Need to migrate existing user sessions
- Minimize downtime
What approach would be good?"
1.2 Situation-Specific Patterns
1. New Feature Implementation
[Context]
- Current system state
- Related existing code location
- Business requirement background
[Request]
"In this context, how should I implement [feature]?
Suggest an approach first."
2. Bug Fixing
[Symptoms]
- Error message or unexpected behavior
- Reproduction steps
[Context]
- Related code files
- Recent changes
[Request]
"What's causing this bug?
Suggest a fix direction."
3. Refactoring
[Current State]
- Problematic code and location
- Why refactoring is needed
[Goal]
- What to improve
[Constraints]
- What shouldn't change (API, behavior)
[Request]
"How can I improve this code?"
1.3 Making AI Ask Questions
Key: Acknowledge incomplete context, ask AI to question
"I want to implement user profile editing.
Check if the context I provided is sufficient.
Ask me anything you need to know before implementing."
Part 2: 4-Phase Workflow
2.1 Overview
Phase 1: Context Building
↓
Phase 2: Exploratory Conversation
↓
Phase 3: Incremental Implementation
↓
Phase 4: Guardrails
2.2 Phase 1: Context Building
Goal: Establish foundation for AI to reason effectively
Checklist:
- Project background explanation
- Current architecture sharing
- Problem definition
- Constraint specification
- Past attempts and results
2.3 Phase 2: Exploratory Conversation
Goal: Find optimal approach
Steps:
- Request approach suggestions
- Discuss pros and cons
- Encourage additional questions
- Reach agreement
2.4 Phase 3: Incremental Implementation
Goal: Implement in small units while maintaining feedback loop
Principles:
- One small unit at a time
- Review after each step
- Feedback becomes next context
2.5 Phase 4: Guardrails
Goal: Ensure quality and maintainability
Checklist:
- Write tests (unit, integration, edge cases)
- Documentation (code comments, README)
- Code review (style, performance, security)
- Error handling (exceptions, user-friendly messages, logging)
Part 3: Context Continuity in Iteration
3.1 Why Continuity Matters
Problem:
Session 1: "Implement JWT auth" → Implementation
Session 2: "Add refresh token" → Different style
Session 3: "Implement logout" → Yet another style
Result: Inconsistent code, duplication, conflicts
3.2 Converting Feedback to Context
Pattern:
[Previous Feedback]
- "Unify error response format to { error: { code, message } }"
- "Use try-catch pattern with async/await"
[This Request]
Implement logout API.
Reflecting the above feedback.
3.3 Maintaining Decision Log
Format:
## Decision Log
### 2024-12-13: Token Storage Method
**Decision:** Use httpOnly cookies
**Reason:** XSS defense, automatic transmission
**Alternative:** localStorage (security vulnerable)
3.4 Bridging Sessions
At Session End:
"Before wrapping up today's work,
create a summary for the next session.
Include:
- Completed work
- Next tasks
- Unresolved issues
- Key decisions"
At Next Session Start:
"Here's the previous session summary:
[Completed]
- JWT auth basic structure
- Login/logout API
[Next]
- Refresh token logic
- Token renewal middleware
[Unresolved]
- Redis connection setup needed
[Decisions]
- httpOnly cookies
- Access 1hr, Refresh 7 days
Let's implement refresh token logic in this context."
Part 4: Real Scenario Walkthrough
4.1 Scenario: New Feature Development
Situation: Adding comments feature to blog
Phase 1: Context Building
"I want to add a comments feature.
[Current State]
- Next.js 14 static blog
- Serverless environment (Vercel)
- No authentication system
[Requirements]
- Allow anonymous comments
- Need spam prevention
- Real-time updates not required
[Constraints]
- Serverless limits DB connections
- Minimize cost
- Minimize management burden"
Phase 2: Exploratory Conversation
AI: "Here are some options:
1. Giscus (GitHub Discussions based)
- Pros: Free, no management, markdown support
- Cons: Requires GitHub account
2. Self-implementation + Supabase
- Pros: Full control
- Cons: Implementation/management cost
Which direction is better?"
Me: "Giscus sounds good. GitHub account requirement helps with spam prevention too."
Phase 3-4: Incremental implementation and guardrails...
Conclusion
Key Summary
-
Context-First Conversation
- Provide context before requests
- Encourage AI to ask questions
- Use situation-specific patterns
-
4-Phase Workflow
- Context Building → Exploration → Incremental Implementation → Guardrails
- Feedback loop at each phase
-
Context Continuity
- Convert feedback to context
- Maintain decision log
- Pass summaries between sessions
Next Article Preview
Article 5: Advanced Context Engineering - Teams and Systems will cover:
- Team-level Context Engineering
- Context management in complex systems
- Reference Application pattern
- Team of Agents pattern
Have you applied this workflow? Which patterns were most effective? Share your experience.
