Everything in this section has been about one-shot prompts. The final shift is treating AI as a continuous collaborator — present from project kickoff to deployment, with shared context, a shared style guide, and explicit roles. This topic brings the lessons together into a working pair-programming practice.
Pair programming with a human colleague has rules: a driver and a navigator, regular role swaps, shared keyboard etiquette. Pair programming with AI has its own rules, and they are different. The AI never tires, never gets defensive, and is happy to rewrite the same function ten different ways. But it has no memory between sessions, no awareness of your codebase, and no intuition about which conventions your team follows. To make AI an effective pair, you must give it a persistent context and clear roles — and this topic shows you exactly how to do that across an entire data science project.
A productive AI pair programmer relationship has three pillars: shared context, defined roles, and tight feedback loops. Shared context is everything the AI needs to know about your project: the codebase layout, the dataset schemas, the conventions, the recent decisions. Defined roles tell the AI whether to be the driver (writing code) or the navigator (reviewing, questioning, suggesting alternatives) at any given moment. Tight feedback loops mean every block of generated code gets reviewed, tested, and refined in conversation before the next one.
An analogy: think of AI as a brilliant graduate student joining your team for a six-month project. On day one they know everything about Pandas and nothing about your domain. By month two — if you brief them well, give them context, and give them feedback — they are operating at near-senior level on your specific problems. The difference between a great graduate and a frustrating one is rarely raw ability; it is how well they have been onboarded.
The single highest-leverage habit is maintaining a "context document" for each project. It includes the dataset schemas, the modelling target, the coding conventions, the libraries in use, the directory layout, and a running log of recent decisions. Paste the document into the first prompt of every working session. The AI immediately operates as if it had been on the project for weeks.
Weak prompt
Help me with my data science project.
No project. No codebase. No conventions. The AI defaults to generic best practices that may contradict your team's choices. Every snippet needs heavy editing to fit your repository, and after an hour you are mostly fighting the AI rather than collaborating with it.
Stronger prompt
Act as my senior data science pair programmer.
PROJECT CONTEXT
- Repo layout:
/src/data (loaders, validators)
/src/features (feature builders)
/src/models (training, evaluation)
/notebooks (exploration only — not committed)
/tests (pytest)
- Stack: Python 3.11, Pandas 2.1, scikit-learn 1.4,
XGBoost 2.0, dbt 1.7, Airflow 2.8, BigQuery.
- Style: PEP8, ruff, black-formatted (line length 100),
type hints required on public functions, Google-style
docstrings.
- Target dataset: customers_df (schema attached below).
- Modelling target: churn_within_90d (binary).
- Recent decisions:
* Switched primary metric from ROC-AUC to PR-AUC
last week (class imbalance ~7%).
* Moved feature_engineering.py to use polars-lazy
for the rolling aggregates.
YOUR ROLES (use whichever fits the moment):
- DRIVER: write code that fits the project conventions
exactly; emit one file at a time with explicit path.
- NAVIGATOR: review my code; flag risks, suggest
alternatives, ask clarifying questions.
- REVIEWER: critique a PR diff for bugs, leakage,
test gaps, and style.
For this session, please START as NAVIGATOR.
I will paste a draft feature builder. You critique it
before we write any new code together.
With this in place, every subsequent message in the session benefits from the same context. The AI reviews like a senior, writes code that matches your repo conventions, and remembers (within the session) the decisions you made earlier.
The pattern is: project context document → defined roles → tight loop → fresh context for each new session. The role assignment is the most underused technique. When you tell the AI to be the navigator, it stops generating code and starts asking the questions that catch bugs early. When you tell it to be the reviewer, it produces critiques that read like senior PR feedback. Default to driver only when you genuinely want code.
For longer projects, maintain a short AI_NOTES.md file in the repository — a running log of decisions and conventions. Paste it at the start of each session. Over weeks, it becomes the canonical context that turns AI into a senior team member who never forgets a decision.
AI_NOTES.md. Future sessions inherit the wisdom.Tip: When debugging together, paste both the traceback and the relevant file. Then prompt: "Diagnose this failure. List three plausible root causes in order of likelihood, and for each, the smallest experiment to confirm or rule it out." This turns AI into a calm, systematic debugging partner instead of a guess-and-check engine.
Build a 200-word project context document for your current data science project. Save it as AI_NOTES.md in the repository. For the next week, paste it at the start of every AI session. Note the change in output quality.
Pair-program one full feature: from feature design through to feature implementation and tests. Start with AI as navigator (review your sketch), switch to driver (write the code), then reviewer (critique the result). Use explicit role switches in the conversation.
Use AI to write a code review for one of your existing PRs. Provide the diff and the project context. Ask for: bugs, leakage risks, test gaps, style issues, and three "even better if" suggestions. Compare the AI review to the human review on the same PR.
AI_NOTES.md) and paste it at the start of every session.Sign in to join the discussion and post comments.
Sign inPrompt Engineering for Education & Learning
Use AI as your personal tutor. Learn how to study faster, create lesson plans, generate practice questions, master languages, and prepare for competitive exams with smart prompts.
Prompt Engineering for Specific AI Tools
Tool-by-tool mastery — deep dives into ChatGPT, Claude, Gemini, GitHub Copilot, Midjourney, Stable Diffusion, and more. Learn the exact prompting techniques each platform rewards.
Advanced Prompt Engineering Techniques
Master the powerful techniques AI experts use every day. Chain-of-thought, RAG, agents, function calling, prompt evaluation, and much more — 20 deep-dive tutorials.
Prompt Engineering for Content & Copywriting
Write blogs, ads, emails, and social media content ten times faster with AI. 13 practical tutorials on prompt engineering for content creators and copywriters.
Prompt Engineering for Image Generation
Turn words into stunning visuals. Master AI image generation tools like Midjourney, DALL·E 3, and Stable Diffusion with 18 focused tutorials — from first prompt to full brand identity.
Prompt Engineering Projects & Real-World Applications
Twelve hands-on projects that turn prompt engineering theory into a portfolio. Build chatbots, content generators, RAG systems, and more.