explaingit

zeeshan78699/codetruthagent

0PythonAudience · developerComplexity · 3/5ActiveSetup · easy

TLDR

Python prototype that finds duplicate functions across a codebase, classifies merge risk, requires human approval, and writes a dependency report with backups.

Mindmap

mindmap
  root((CodeTruthAgent))
    Inputs
      Python source files
      Human approval
    Outputs
      Merge report
      Dependency map
      Backups
    Use Cases
      Find duplicate functions
      Block unsafe merges
      Track refactor decisions
    Tech Stack
      Python
      AST

Things people build with this

USE CASE 1

Scan a Python codebase for identical, semantically equivalent, or cross-file duplicate functions.

USE CASE 2

Block a merge when two similar functions touch different systems such as production vs test databases.

USE CASE 3

Generate a dependency map and report before refactoring large legacy modules.

USE CASE 4

Keep a memory of past approval decisions so the same duplicate is not reviewed twice.

Tech stack

PythonAST

Getting it running

Difficulty · easy Time to first run · 30min

Pure Python prototype with a small CLI entry point and sample files; no external services required.

In plain English

CodeTruth Agent V1 is a Python tool that looks for duplicate functions inside a Python codebase and decides whether merging the duplicates would actually be safe. The README frames it as a prototype rather than a production library, and positions it as an alternative to simpler duplicate detectors that only compare text or look at the structure of the code. The pipeline has seven stages. It scans Python files, parses them into an abstract syntax tree, compares functions for similarity, classifies the risk and any conflicts, runs an approval step that can block the merge, performs the merge with a backup of the original files, and finally writes a report including a dependency map. The README gives an example where two functions look almost identical, but one connects to a production PostgreSQL database and the other to a test MySQL database. The tool flags this as a business-rule conflict and blocks the merge, on the principle that the same structure does not always mean a safe merge. The README lists the detection capabilities, which include catching identical duplicates, functions with different names but the same logic, duplicates across files, recursion, and nested versus flat versions of the same code. Safety features include automatic backups before any change, a required human approval step, dependency tracking across files, and a learning memory that remembers past decisions so the user does not have to answer the same question again. A large section of the README is given over to a test scorecard. The author reports 22 test cases all passing, covering things like identical detection, semantic duplicates, false positive rejection, recursion, default argument conflicts, and a real-world run against a file from the requests library. The README also notes that the test scenarios themselves were drafted with help from several AI assistants, while the final implementation and validation were done by hand. The repository layout includes a main entry point and several sample Python files used by the tests. The README does not state a license.

Copy-paste prompts

Prompt 1
Walk me through the seven-stage pipeline in CodeTruthAgent from AST parsing to the final report.
Prompt 2
Show me how the tool decides that two functions are semantic duplicates but still flags them as a business-rule conflict.
Prompt 3
Run CodeTruthAgent on a small sample project and explain how to interpret the dependency map it writes.
Prompt 4
Help me extend the classifier so it also blocks merges when one function uses async and the other is sync.
Prompt 5
Explain how the learning memory stores past approvals and where I can clear it to start fresh.
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.