How to use LLMs effectively in your daily work: a practical tutorial
What to use and why
- Prompt patterns: reusable templates that standardize how you ask for design, code, tests, reviews, and refactoring. They help you stay consistent, reduce drift, and accelerate onboarding of team members.
- Task decomposition: breaking large goals into clear, verifiable subtasks with owners, inputs, and acceptance criteria. This makes AI-assisted work scalable and auditable.
- Output review: a structured checklist to verify fidelity, safety, performance, and maintainability before merging AI-generated work into production.
Prompt patterns for effective software prompts
- System-focused scoping prompts
- Define scope: “From now on, you are an expert software architect focused on X. Maintain this role for the duration of the session.”
- Boundaries: list constraints, such as language, framework, version, security requirements.
- Ambiguity flagging: require the model to surface ambiguities and propose clarifications.
- Roles and persona prompts
- Assign specific roles for different tasks: design, implementation, testing, security review, documentation.
- Switch roles as needed to cover all aspects of a feature or system.
- Task-oriented templates
- Design prompts: specify inputs, desired architecture, trade-offs, and non-functional requirements.
- Implementation prompts: provide interface contracts, data models, edge-case handling, and coding standards.
- Testing prompts: request unit, integration, and property-based tests; specify coverage targets.
- Refactoring prompts: request a slow, safe refactor plan with risk assessment and a migration path.
- Ambiguity and risk prompts
- After generating a solution, ask the model to identify potential ambiguities, missing requirements, and security or performance risks, plus concrete mitigation steps.
- Verification prompts
- Require the model to produce verifiable outputs: code that passes a supplied test suite, or a design that aligns to given constraints with traceable mappings to requirements.
Task decomposition patterns
- Define objectives clearly
- Start with objective: “Build a feature X with constraints A, B, C. End state: Y.”
- Break into 3-10 concrete subtasks
- Each subtask should have a owner, inputs, dependencies, expected outputs, and acceptance criteria.
- Plan-execute-validate loop
- Plan: determine steps and checkpoints.
- Execute: run tasks with AI assistance or automation.
- Validate: confirm outputs meet criteria; if not, replan.
- Use decomposed prompting
- For complex tasks, create explicit subtask prompts with tailored instructions to handle each domain (UI, backend, tests, deployment).
- Checkpoints and validators
- Insert checkpoints where you verify requirements alignment, API compatibility, and performance baselines.
Choosing when to use LLMs in development
- Use for design exploration and rapid prototyping when constraints are clear and quick feedback is valuable.
- Use for boilerplate generation, repetitive refactoring, or scaffolding, complemented by strong human review.
- Use for complex decision justification and risk assessment, but always require traceable reasoning and verifiable outputs.
- Avoid relying solely on AI for critical correctness (security, correctness of algorithms, concurrency) without exhaustive testing and code review.
Real-world exercise structure
- Exercise 1: Prompt pattern design
- Task: Create a 1-page design doc for a new microservice.
- Prompt: “Act as a software architect. Given a microservice that handles X, design a scalable, secure architecture in 2 options, list pros/cons, and include a concrete data model. Surface ambiguities and propose clarifications.”
- Output: two design options, data model, ambiguity list, clarifications.
- Human review: verify alignment with requirements, security, and scalability.
- Exercise 2: Task decomposition for feature rollout
- Task: Implement feature Y with integration to service Z.
- Subtasks: requirements gathering, API surface, data model, service wiring, tests, deployment plan, rollback plan.
- Acceptance criteria: all tests pass, performance within baseline, documented changes.
- Exercise 3: AI-assisted code review
- Task: Review a pull request generated by AI.
- Checklist: fidelity to requirements, edge cases, input validation, API integrity, readability, test coverage, security implications.
- Output: annotated review with suggested fixes and rationale.
A concrete 1-week workflow sample
- Day 1: Define objective and constraints; draft 2-3 design prompts; identify acceptance criteria.
- Day 2-3: Generate designs; select a preferred approach; create subtask plan with owners and validators.
- Day 4-5: Implement or scaffold with AI assistance; write tests; run through a plan-act-validate loop.
- Day 6: Conduct a thorough AI-assisted code review against criteria; iterate on fixes.
- Day 7: Prepare deployment and rollback strategy; document decisions and rationale.
Best practices for maintaining judgment and quality
- Maintain a strong code review discipline: require human signs-off on architecture, critical logic, and security.
- Use explicit acceptance criteria for every subtask and output.
- Require traceability: map each output to its original requirement or design decision.
- Apply deterministic checks: run tests, linting, and security scans; require passing before progress.
- Alternate thinking aids: use Chain of Thought-like prompts for reasoning steps, but always validate with tests and independent analysis.
- Keep prompts modular: reuse sub-prompts for consistent outputs and easier auditing.
Example prompt templates you can adapt
- Design prompt
- “Act as a software architect. You are designing a microservice X. Constraints: framework A, language B, latency < C ms, throughput D req/s, security standard E. Provide 2 architectural options, data model, API contracts, and migration plan. Surface ambiguities and propose clarifications.”
- Implementation prompt
- “You are a senior developer. Implement the following API: [spec]. Provide code in [language], with tests, error handling, input validation, and logging. Include a brief rationale and notes for future extension.”
- Testing prompt
- “Create unit tests for the API above covering typical, boundary, and error cases. Include property-based tests where appropriate. Ensure test coverage >= X% and document edge-case assumptions.”
- Review prompt
- “Review the following AI-generated code against the feature spec. Confirm fidelity, identify gaps, list edge cases, security concerns, and provide concrete fixes with rationale.”
Exercises and quick checks
- Practice 1: Write a decomposed plan for a feature that involves three services with a shared data model. Include owners and validators for each subtask.
- Practice 2: Generate two design options for a data pipeline; annotate the trade-offs between batch and streaming approaches.
- Practice 3: Create a 6-layer AI review checklist focusing on requirements fidelity, API integrity, security, performance, and maintainability.
Illustrative example
- Feature: Add user analytics to an app
- Subtasks: data collection schema, event naming, backend services, data warehouse schema, privacy controls, dashboards, tests, deployment
- Validators: event counts within expected ranges, end-to-end tests pass, privacy settings enforced
- Review: ensure data correctness, no PII leakage, and scalable ingestion.
If you want, I can tailor these templates to your tech stack (languages, frameworks, CI/CD) and provide a ready-to-run set of prompts and a small exercise pack aligned to your current project.
Would you like me to adapt this for your stack (for example, Node.js with PostgreSQL and React frontend) and generate a starter prompt kit plus a 3-task decomposition exercise to practice?
-
Rizwan Saleem | https://rizwansaleem.co
Top comments (0)