Build Your Own Local AI Agent (Part 3): The Code Archaeologist 🔦

Published: (January 7, 2026 at 07:00 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Overview

In Part 2 we queried data. Now we’ll document code.

You probably have a file like legacy_math.py with no comments and generic variable names (x, y, z). Modifying it directly can feel risky.

Enter the Private Code Archaeologist – an agent that reads your code, understands it, and adds professional Google‑style docstrings locally.

What the agent does

  1. Reads a target file.
  2. Identifies undocumented functions.
  3. Generates Google‑style docstrings that describe arguments and return values.
  4. Overwrites the file with the new content without changing any logic.

Why run it locally?

You may not want to paste proprietary algorithms into a hosted service like ChatGPT. By using Goose + Ollama, all processing stays on your SSD, keeping your intellectual property private.

Agent instructions (frontmatter)

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.

We used the gpt-oss:20b model for this task. It correctly identified a Haversine formula hidden among generic variable names and added a clear explanation.

Example

Before

def f2(lat1, lon1...):
    # implementation omitted
    ...

After (Agent generated)

def f2(lat1, lon1, lat2, lon2):
    """
    Compute the great‑circle distance between two points on the Earth.

    Args:
        lat1 (float): Latitude of the first point in degrees.
        lon1 (float): Longitude of the first point in degrees.
        lat2 (float): Latitude of the second point in degrees.
        lon2 (float): Longitude of the second point in degrees.

    Returns:
        float: Distance between the two points in meters, calculated using the
        haversine formula.
    """
    # implementation unchanged
    ...

Next up

The grand finale—Part 4: Handling Sensitive PII Data.

Back to Blog

Related posts

Read more »