How I “AI” for Consulting Projects

I now use AI constantly for client projects. I’m sharing this detailed “how-to” as an inspiration for fellow modelers. It’s easy to feel a sense of “AI hopelessness” relative to those out there who have hit the seventh level. I follow Boris Cherny on Twitter as a classic example. Yes. The Claude guy. I learn from people like him, but I do not have dozens of agents in motion orchestrated from my iPhone like he does. However, I use AI agents to crank out high quality work for clients in the form of data pipelines, models and dashboards that can organize, predict and visualize their situations. That means moving in the direction of, but staying back from, the bleeding edge.

This is evolving quickly, but here is my current system for Python or VBA projects to create solutions for clients. My big AI-related theme over the past year is much greater emphasis on pre-planning. For all recent changes done in concert with an AI agent, I now possess a specification document co-written with the agent documenting details of what was done either starting from scratch or from modifying a client’s existing tools. My efficiency gain from using AI is a huge leap versus the old way.

  • The AI coding agent writes my code using VS Code and its chat+context files harness
  • AI also writes validation tests that certify correctness of project code.
  • I use markdown format notes in the Obsidian app to make AI-readable project background for the agent. I expose these to AI situationally with “read this” instructions in VS Code Copilot chat and in high-level Obsidian instruction notes.
  • For bigger projects, I create an Obsidian graph subfolder (graph = linked, single-topic notes) with project background for me and the agent. I version control this as a separate Github repository from the project and test code.
  • I keep close supervision of AI-generated work including personal, detailed review of code and other outputs the AI generates. I also run/debug the validation tests myself.
  • I use a modular, well-described architecture for projects. It represents data and reports as structured data “objects” aka tables and scenario models that include descriptive metadata about the objects and their variables in addition to the actual data.
  • I use instructions and skills files to ground the the coding gent with “this is how we do things around here” for general and specific coding practices. The skills *.md files are also where I correct negative behaviors by the agent by asking it to write down “how will we avoid doing things this way in the future”.
  • To get ready for coding, the agent and I interact using Matt Pocock’s outstanding and elegant Grill-me skill. We jointly create a “Change_” specification Obsidian note that was my agreement with the agent on the work to be done. We create this jointly before turning the agent loose on coding. This specification then serves as permanent documentation of the change and how it was executed.

Obsidian for Background Context
For work projects, I store all relevant notes in one subfolder in my Obsidian Vault that I host on the cloud to make it available across my laptop and other devices. Since an AI agent is doing the actual coding, this enables working on the requirements development while sipping coffee in Starbucks with just an iPhone in tow.

Context files are key to moving beyond simple chat into agent-based AI development. I love the free Obsidian app for both personal and work note keeping. Obsidian recently replaced Evernote as my personal note-keeping solution. It stores each note as an open-format, text file in markdown format. It is amazing how this can supersede using Microsoft Word for many purposes.

VS Code and Its Copilot Chat as a Harness
I use VS Code as the overall work environment aka IDE. It is free, but Copilot Chat within it is a nominal monthly charge for access to Claude and OpenAI coding agents. I currently pay $40 per month for that access to premium models after experience showed this to be worthwhile. I use a consistent src and tests subfolder arrangement for all projects with src containing the project files and a tests/test_data subfolder for validation data. My standard code toolbox lets me instantly reorient execution to use of either validation or production data as inputs.

The screen picture shows my VS Code environment for the Excel Steps open-source add-in project. The chat window shows an example interaction with the agent. I use Github for version control. VS Code allows me to instance a repository and commit changes to the project files. I include the project’s Obsidian graph/notes folder in the VS Code workspace, and I version control it with a separate Github repo from the project files. This graph folder is the ExcelSteps_Graph twistie at the bottom of the Explorer tree at left. All other files are in the Excel_Steps project folder

Feeding Foundational Context to the Coding Agent
VS Code and the AI models are built to access standard background files visible in the Explorer file tree at the left of the screen picture above. Within the project’s .github folder, copilot-instructions.md contains the basic instructions for how I want the agent to do things. Here I describe the data structures and basic coding and testing practices to use. My Python and VBA instructions include function and test function templates to standardize those aspects. This is where I set the tone that we develop highly modular code based on single-action functions in a predictable architecture. It also describes my preferred error handling approach.

Because it is a bad idea to “overfeed” context to the agent, skills.md files work in concert with copilot-instructions.md to guide the agent on additional topics. The skill format includes lines of YAML “frontmatter” (within the “—” fences in the example below) that the agent keeps resident in memory. It then accesses the document’s details when relevant. This example corrected an overly-verbose coding practice by the agent and quite simply got it doing things in a way that I wanted it to.

Test-Based Validation
I use Pytest tests for projects in Python and a test suite workbook I wrote for VBA (example in Excel_Steps repo). I do not pre-write tests nor do I expect the agent to do so, but I always ask the agent to write tests that validate the project code. I involve myself personally in running them to check the quality. Testing is a relatively uncommon practice among working engineers, scientists and consultants. In my opinion, that’s a mistake. With what AI agents can do, there is no excuse for not generating test code to validate.

It is invaluable to break things up into single-action functions and have at least one test per function to prove execution as expected. In Python, Brian Okken’s book, Python Testing with Pytest is an excellent tutorial. In VBA, my VBA test suite workbook gets co-developed with the project and can execute all project macros to check their outputs and actions on a workbook. My respect for this approach dates to excellent mentoring by a former P&G colleague and Computer Scientist, Mike Hilton. In the early 2000’s, he dazzled me with Excel test suite macros that could inspect and compare worksheets relative to a standard. Such testing can be rerun whenever changes are made to avoid introducing errors in complex projects.

While my copilot-instructions.md sets the expectation and code templates for testing, this can sometimes be an afterthought for the AI agent. Here is an example interaction to prod it to consider how testing will be set up in a specification for a change.

Spec Document from Grill Me Session
Matt Pocock’s grill-me skill has just a few sentences, and its effectiveness made it one of the most popular items in the global Github/developer community. It asks the agent to “Interview me relentlessly about every aspect of this plan until we reach a shared understanding”. My link here is to one of his skills repo’s subfolders, but this entire repo and his Youtube channel are worth browsing. He is a clear-spoken voice on use of AI for coding.

I feed the agent an initial, high-level background paragraph describing the project. It includes relevant “Read this background Obsidian note/code file” instructions to ground the agent in previous work. I then ask it to grill me with questions per the skill. Once that runs its course, the agent writes a Changexyz note according to a template I feed it in another, project-changes skill I wrote (vba-project-changes is an example in the Excel_Steps project). I typically do not even read the Change note in great detail. The agent generates it as a summary of our back and forth. My experience is that it does a great job doing so.

Executing the Change
Once the Change_ document is complete, I authorize the agent to make the change/write the code. In the example below, it generated approximately 1000 lines of project and test code while modifying 9 files/modules. Next step: I run the tests and ensure things are working. If there are outages, they often stem from giving the agent incomplete background such as an incomplete description of complex input data.

A Note About Developing in VBA
Developing in VBA requires a special solution, but it is a good one. Excel is a standard for many of my clients and a bedrock in my project team experiences at P&G. Developing in its VBA macro language has been critical to making excellent user interfaces for clients. However, VS Code was built for Python (and many other language) development but not for VBA directly. It cannot directly access Excel files.

There is a workaround. Traditionally, we access the Excel VBA editor and run macros/code from within an open Excel workbook. The editor is literally unchanged since the mid 1990’s, so it is truly ancient albeit highly useful tech. Felix Zumstein’s brilliant extension to the xlwings open source package syncs code from the VBA editor into VS Code. This gives the AI agent access to do its work, and current models know VBA very well. My screen pic above shows a terminal at bottom of the screen for invoking this. I keep separate Terminals open for the project and test workbooks and run separate xlwings vba edit sessions for each. This Youtube video by Felix gives a demo of how this works. To note, xlwings vba edit is Windows only. That necessitates using Windows VS Code. I was happy to switch to that using OSX/Parallels to take advantage of the capability.