In Part 2, we queried data. Now, let's document code.
We all have that one file. legacy_math.py. No comments. Variables named x, y, z. You're afraid to touch it.
Meet the Private Code Archaeologist. An agent that reads your code, understands it, and comments it for you—locally.
The Goal
- Read a target file.
- Identify undocumented functions.
- Generate professional Google-style DocStrings.
- Edit the file in place.
The Architecture
The Power of Local
Why local? Because you don't want to paste your proprietary algorithms into ChatGPT. With Goose + Ollama, your IP stays on your SSD.
The Recipe
We instruct Goose to use the Developer Extension (which can read/write files).
title: Code Archaeologist
instructions: |
1. Read the file.
2. For every function, write a DocString explaining Args & Returns.
3. Overwrite the file with the new content.
4. Do NOT change the logic.
Seeing it in Action
We used gpt-oss:20b for this. The model correctly identified a "Haversine formula" buried in math variables and added a perfect explanation.
# Before
def f2(lat1, lon1...): ...
# After (Agent Generated)
def f2(lat1, lon1, lat2, lon2):
"""
Compute the great‑circle distance...
Uses the haversine formula...
"""
...
Next Up: The grand finale—[Part 4]: Handling Sensitive PII Data.



Top comments (0)