Skip to main content

A semantic code analysis tool designed to help Claude Code navigate repositories efficiently while dramatically reducing token consumption.

Project description

Athena Code Knowledge

A semantic code analysis tool designed to help Claude Code navigate repositories efficiently while dramatically reducing token consumption.

Motivation

Claude Code currently incurs significant token costs during repository navigation. A typical planning phase involves reading 10-20 files to understand codebase architecture, consuming substantially more tokens than the targeted modifications themselves. This linear scaling with codebase size makes work on large repositories inefficient.

Most discovery queries ("What does this file contain?", "Where is function X?") don't require reading entire source files. By building a queryable semantic index, we can answer these questions using structured metadata instead, potentially reducing planning token costs by 15-30x.

What's the deal with the name?

Athena was an Ancient Greek goddess associated with strategic wisdom, logic, crafts, architecture and discipline. She is a patron of engineers and planners, not dreamers. Seemed appropriate.

One of her symbolic animals was the owl.

Installation

NOTE: Athena currently only works in a Python codebase. More supported languages coming soon!

Install with pipx:

pipx install athena-code

Requires at least Python 3.12, so if that's not installed you should do that with your system package manager. It doesn't need to be the default Python, you can leave that at whatever you want and point Pipx at Python 3.12 explicitly:

pipx install --python python3.12 athena-code

Usage

use athena --help to see up-to-date information about the available features:

╭─ Commands ─────────────────────────────────────────────────────────────────────╮
│ locate          Locate entities (functions, classes, methods, modules,         │
│                 packages) by name.                                             │
│ search          Search entities by docstring content using natural language.   │
│ info            Get detailed information about a code entity or package.       │
│ mcp-server      Start the MCP server for Claude Code integration.              │
│ install-mcp     Install MCP server configuration for Claude Code.              │
│ sync            Update @athena hash tags in docstrings.                        │
│ status          Check docstring hash synchronization status.                   │
│ uninstall-mcp   Remove MCP server configuration from Claude Code.              │
╰────────────────────────────────────────────────────────────────────────────────╯

Generally, you will install athena and then:

  • Run athena sync in your codebase. This will add Athena's hashes to all the docstrings (for functions, classes, methods, modules, and packages) and allow athena to detect code changes that have invalidated the docstrings.
  • After code changes, run athena status to see a table of all the entities that have been updated and may have had their docstrings invalidated.
  • Update the necessary docstrings and then run athena sync again to update all the necessary hashes.

Supported Entity Types

Athena tracks docstrings for:

  • Functions — Standalone functions
  • Classes — Class definitions
  • Methods — Class methods
  • Modules — Individual Python files (module-level docstrings)
  • Packages — Directories with __init__.py (package-level docstrings in __init__.py)

For modules and packages, Athena uses intelligent hashing:

  • Module hashes are based on the complete file AST (excluding docstrings), capturing all semantic changes
  • Package hashes are based on __init__.py content plus the manifest of direct children (files and sub-packages)
  • This means package hashes change when files are added/removed/renamed, but remain stable when only implementation details change within existing modules

If you want to find an entity in the codebase, then just run athena locate <entity> to get details on the file and lines the entity occupies:

> athena locate get_task
 Kind    Path                    Extent
 method  src/tasktree/parser.py  277-286

If you want to search for entities based on what they do (rather than their name), use athena search with a natural language query:

> athena search "parse Python code"
 Kind      Path                              Extent   Summary
 class     src/athena/parsers/python_parser  19-400   Parser for extracting entities from Python files
 function  src/athena/parsers/utils.py      45-67    Parse a Python file and return its AST

The search command uses BM25 ranking to find the most relevant entities based on their docstrings. You can customize the number of results:

> athena search --max-results 5 "authentication"
> athena search -k 3 "JWT token"  # Short form

Search also supports JSON output for programmatic use:

> athena search --json "parse Python code"

Configuration can be customized via a .athena file in your repository root:

search:
  term_frequency_saturation: 1.5  # BM25 k1 parameter (1.2-2.0)
  length_normalization: 0.75      # BM25 b parameter (0.5-0.75)
  max_results: 10                 # Default number of results

Once you know where a thing is, then you can ask for info about it:

> athena info src/tasktree/parser.py:get_task
{
  "method": {
    "name": "Recipe.get_task",
    "path": "src/tasktree/parser.py",
    "extent": {
      "start": 277,
      "end": 286
    },
    "sig": {
      "name": "get_task",
      "args": [
        {
          "name": "self"
        },
        {
          "name": "name",
          "type": "str"
        }
      ],
      "return_type": "Task | None"
    },
    "summary": "Get task by name.\n\n        Args:\n            name: Task name (may be namespaced like 'build.compile')\n\n        Returns:\n            Task if found, None otherwise\n        "
  }
}

Install Claude MCP integrations

Athena includes Model Context Protocol (MCP) integration, exposing code navigation capabilities as first-class tools in Claude Code.

Benefits

  • Native tool discovery — Tools appear in Claude Code's capabilities list
  • Structured I/O — Type-safe parameters and responses

Available Tools

  • ack_locate — Find entity location (file path + line range)
  • ack_info — Get information about an entity (kind, summary, etc.)
  • ack_status — Check whether all docstrings are up-to-date with the code they describe

Installation

athena install-mcp

This automatically configures Claude Code by adding the MCP server entry to your config file. You will need to restart Claude Code for changes to take effect.

Uninstalling:

If you don't like using your Anthropic tokens more efficiently to generate better code, for some reason, then:

athena uninstall-mcp

to remove the MCP integration

Usage Workflow

cd /path/to/repository
athena locate validateSession  # Find the locations of entities in the codebase

Contributing

This is an active development project. Early-stage contributions welcome, particularly:

  • Tree-sitter AST extraction improvements
  • Language-specific signature formatting
  • LLM prompt engineering for summary quality
  • Performance benchmarking

License

MIT - See LICENSE

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

athena_code-0.0.16.tar.gz (73.0 kB view details)

Uploaded Source

Built Distribution

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

athena_code-0.0.16-py3-none-any.whl (44.9 kB view details)

Uploaded Python 3

File details

Details for the file athena_code-0.0.16.tar.gz.

File metadata

  • Download URL: athena_code-0.0.16.tar.gz
  • Upload date:
  • Size: 73.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for athena_code-0.0.16.tar.gz
Algorithm Hash digest
SHA256 c38e6c34fe26c885c33a6d2946c051bd43bb364b34e6a386a1168b548acb07b1
MD5 695d412ec3ca69b83672daf2053b605c
BLAKE2b-256 1ff5c21991f52fb1ab903563fd0d39464aed0411b88df6f8e0ecb613996010ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for athena_code-0.0.16.tar.gz:

Publisher: release.yml on kevinchannon/athena

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file athena_code-0.0.16-py3-none-any.whl.

File metadata

  • Download URL: athena_code-0.0.16-py3-none-any.whl
  • Upload date:
  • Size: 44.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for athena_code-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 c1b70008ecaab5e31c45d1fb2ee243446b16d7e2e12810988f13eeddd5a26334
MD5 94f8d7cd501fbff854c17cc28a4fd0a8
BLAKE2b-256 4fb96d755fb4b33b6abe750a65dab65cc673e2fafd0a55c7e12d6c7f1066451f

See more details on using hashes here.

Provenance

The following attestation bundles were made for athena_code-0.0.16-py3-none-any.whl:

Publisher: release.yml on kevinchannon/athena

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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