Skip to main content

AI-powered documentation drift detection - Ensure your docs stay in sync with your code

Project description

Secrin Auditor

AI-powered documentation drift detection - Ensure your docs stay in sync with your code.

PyPI version License: MIT

Installation

pip install secrin-auditor

Quick Start

# Set your Gemini API key
export GEMINI_API_KEY="your-key-from-aistudio.google.com"

# Run the audit
secrin-audit ./docs ./src

Features

  • ๐Ÿ” Drift Detection - Find where docs say X but code does Y
  • ๐Ÿท๏ธ CodeWiki Tags - Link docs to specific code files
  • ๐Ÿค– AI-Powered - Uses Gemini 2.0 Flash for intelligent comparison
  • ๐Ÿ“Š Rich Output - Beautiful terminal tables with issue details
  • ๐Ÿš€ CI/CD Ready - Exit code 1 on failures for pipeline integration

Usage

Basic Audit

secrin-audit <docs_folder> <repo_folder>

Arguments:

Argument Description
docs_folder Path to your documentation folder
repo_folder Path to your codebase

Options:

Option Description
-v, --verbose Show verbose output

Example Output

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Secrin Auditor V1           โ”‚
โ”‚ Powered by Gemini 2.0 Flash โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

                    Audit Results
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Document      โ”ƒ Linked Code      โ”ƒ Status โ”ƒ AI Feedback               โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ api-routes.md โ”‚ routes/api.py    โ”‚ FAIL   โ”‚ โ€ข [WRONG_ENDPOINT] Doc    โ”‚
โ”‚               โ”‚                  โ”‚        โ”‚   says /api/users but     โ”‚
โ”‚               โ”‚                  โ”‚        โ”‚   code has /api/v1/users  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ auth.md       โ”‚ auth/handler.py  โ”‚ PASS   โ”‚ โœ… Accurate               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary: 2 docs audited

โœ– Audit Failed: 1 document(s) have drifted from code.

Linking Docs to Code

Explicit Links (Recommended)

Add CodeWiki tags to link documentation to specific code files:

<!-- codewiki:src/auth/jwt_handler.py -->

# JWT Authentication

This module handles JWT token generation and validation...

Multiple Files

<!-- codewiki:src/auth/jwt_handler.py -->
<!-- codewiki:src/auth/middleware.py -->

# Authentication System

This document covers the complete auth system...

Implicit Matching

If no tags are present, the auditor tries to match by filename:

  • auth.md โ†’ looks for auth.py, auth.ts, etc.

For overview docs without matches, the entire codebase context is used.

Issue Types

Type Description
MISSING_ROUTE Route documented but not in code
WRONG_ENDPOINT Endpoint path or method mismatch
OUTDATED_PARAM Parameter no longer exists or changed
NOT_IMPLEMENTED Feature documented but not coded
WRONG_PATH File or module path incorrect
CONFIG_DRIFT Environment variable mismatch

CI/CD Integration

GitHub Actions

name: Documentation Audit

on:
  push:
    branches: [main]
  pull_request:

jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - name: Install Secrin Auditor
        run: pip install secrin-auditor

      - name: Run Documentation Audit
        env:
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
        run: secrin-audit ./docs ./src

Pre-commit Hook

# .pre-commit-config.yaml
repos:
  - repo: local
    hooks:
      - id: docs-audit
        name: Documentation Audit
        entry: secrin-audit ./docs ./src
        language: system
        pass_filenames: false
        always_run: true

Python API

from secrin_auditor import run_audit, audit_with_gemini

# Run full audit
issues = run_audit("./docs", "./src", verbose=True)

# Audit single doc
result = audit_with_gemini(
    doc_text="# API Routes\nGET /users - List users",
    code_text="@app.get('/api/v1/users')\ndef list_users(): ...",
    filename="api.md"
)
print(result)  # "โ€ข [WRONG_ENDPOINT] Doc says /users but code has /api/v1/users"

Requirements

License

MIT License - see LICENSE for details.

Contributing

Contributions welcome! Please read our Contributing Guide.


Part of the Secrin project - The memory layer for engineering teams.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auditrin-0.1.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auditrin-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file auditrin-0.1.0.tar.gz.

File metadata

  • Download URL: auditrin-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for auditrin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1907530316c54bb97bc7a7b1ae3234b3f3ed48229f8e47549657ab265616cef8
MD5 8ba6a96b618270a101e9caa0c4faad51
BLAKE2b-256 bcb4cb0d1773ece9b8200d62e9bfc3490bf60a6bf4787a5a819b1ede7297f461

See more details on using hashes here.

File details

Details for the file auditrin-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: auditrin-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for auditrin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6b7eae718af529dfc0a296f4680ae66a9aaa113bafd0768ea13804170850dd4
MD5 349c4e3e39d3f119430fe107f2328fe9
BLAKE2b-256 942db75ab3253b131c161c8408e836b6002d6b3cc488de0fefbe85e952b73fd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page