Inspiration

I use AI coding tools often while learning, building projects, and understanding unfamiliar code. A problem I repeatedly face is that my available usage can run out after only a few questions, sometimes while I am still in the middle of solving a problem.

That made me think about how much unnecessary project context might be sent with every request. A question about one feature may depend on only two or three files, but an entire repository can still be included. Repeating the same question can also trigger another model request even when neither the question nor the relevant code has changed.

That inspired me to build ContextSift, a command-line developer tool that reduces unnecessary project context before sending a question to Codex.

What it does

ContextSift scans a codebase and analyzes the developer's question. It ranks project files using:

  • Matches in filenames
  • Keyword matches inside file contents
  • Special rules for entry points, documentation, and package.json

Instead of sending the entire repository, it sends only the files that appear most relevant to the question.

ContextSift also creates a SHA-256 cache key using both the user's question and the selected project context. If the same question is asked again without changes to the selected code, the previous answer is returned from the local cache instead of starting another Codex request.

During my demo, ContextSift reduced the estimated context for one question from 4,089 tokens to 2,146 tokens, an estimated reduction of 1,943 context tokens. Repeating the same question resulted in a cache hit, so only one Codex invocation was needed for two questions.

These figures represent estimated project-context size, not complete billed model usage.

How I built it

I built ContextSift as an interactive Node.js CLI and used Codex with GPT-5.6 throughout the development process.

The project includes:

  • A recursive project-file scanner
  • Rules for excluding private and unnecessary files such as .env, .git, and node_modules
  • A keyword-based relevance-ranking system
  • Estimated token measurement
  • SHA-256 response caching
  • An interactive terminal interface
  • A read-only integration with codex exec

At runtime, ContextSift launches Codex in a read-only sandbox and provides only the selected project context. This allows Codex to answer questions without modifying the developer's files.

I also used Codex during development to inspect the architecture, test the command-line workflow, identify unused components, and verify the final behavior.

Challenges I faced

My original idea focused on sending only file differences between requests. However, reliably preserving enough context while proving real token reduction became more complicated than expected.

I decided to simplify the project into a practical MVP that selects the most relevant files for each independent question. This made the behavior easier to understand, easier to test, and more useful within the hackathon timeframe.

Another challenge was API access. My API account did not have available credits, so the first integration returned a quota error. I adapted the project to use the Codex CLI authenticated through a user's ChatGPT account instead of requiring separate paid API credits.

I also learned the importance of protecting secrets. The scanner excludes .env, and the repository's .gitignore prevents sensitive files from being uploaded.

What I learned

This project taught me that building a useful AI tool is not only about selecting a powerful model. It is also about carefully deciding what information the model receives.

I learned how to:

  • Build an interactive Node.js CLI
  • Rank files with lightweight relevance scoring
  • Integrate a program with the Codex CLI
  • Run Codex inside a read-only sandbox
  • Build safe cache keys with cryptographic hashing
  • Measure and explain estimated context savings
  • Package and document a developer tool

Most importantly, I learned how to reduce the scope of an idea while preserving its core value.

What's next

Future versions could include:

  • Model-specific tokenization
  • Persistent caching
  • Semantic file selection
  • Full .gitignore support
  • Binary-file detection
  • Better handling of very large repositories
  • A visual dashboard for context savings

The long-term goal is simple:

Help developers spend their AI context on the code that matters instead of repeatedly sending the entire repository.

Built With

Share this project:

Updates