HOW-TO · DEV

How to delegate specific file tasks to an AI pair programmer while you focus on architecture

intermediate15 minBy Eruo Fredoline
Target environment
Ubuntu 24.04 · Ollama 0.4.x
PREREQUISITES

AI pair programming setup in editor (Claude extension or similar), project with multiple source files

What this does

This guide describes a workflow for assigning targeted, bounded tasks to an AI pair programming tool—such as implementing a specific function, refactoring a single module, or adding error handling to a file—while the developer continues working on higher-level architectural decisions. Delegation reduces idle time and keeps the AI focused on well-scoped deliverables.

Steps

  1. Identify a task with a clear boundary: one file, one function, one refactoring, or one set of tests. Avoid broad tasks like "improve this module."
  2. Open the target file in the editor and position the cursor where the AI should focus its attention.
  3. Use the editor's AI chat input to issue a precise instruction: for example, "Add input validation and error logging to the parseConfig function in this file."
  4. Wait for the AI to propose a diff or inline edit. Review the proposed changes in the editor's diff view.
  5. Accept or modify the proposed changes based on project style and architecture alignment.
  6. Mark the task complete in the project tracking tool (e.g., GitHub issue, kanban board).
  7. Document the decision in a comment above the changed code if the rationale is non-obvious.
  8. Continue with architectural work while the AI handles the next queued file-level task.

Verification

# Check that the file was modified and lint passes
npx eslint src/utils/parser.js && echo "Lint passed"
# Expected output: Lint passed

Common failures

  1. Vague task scope: Asking the AI to "improve this module" produces inconsistent, scattered changes. Solution: decompose the request into one atomic change per instruction: one function, one import, one test file.
  2. AI modifies unintended files: The extension picks up context from other open tabs and changes files outside the target scope. Solution: close all unrelated files before issuing a delegation command, or explicitly name the file in the instruction: "in src/parser.js, add validation."
  3. Accepted changes introduce test failures: AI-proposed edits pass the linter but break existing tests. Solution: always run the test suite immediately after accepting AI edits. If tests fail, revert with git checkout HEAD -- <file> and rephrase the task.
  4. Context lost between tasks: The AI forgets the architectural constraints set in a prior session. Solution: maintain a CONTRIBUTING.md or project-specific instructions file that the AI extension can read as system context for each session.

Related guides