<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/medium-4ldzlfdn3" -->

---
title: Medium | daily.dev
description: A developer built a zero-dependency Python CLI tool called `project_context` to automate feeding codebase context to LLMs like ChatGPT and Claude, replacing...
canonical: https://daily.dev/posts/medium-4ldzlfdn3
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Medium | daily.dev
og:description: A developer built a zero-dependency Python CLI tool called `project_context` to automate feeding codebase context to LLMs like ChatGPT and Claude, replacing...
og:url: https://daily.dev/posts/medium-4ldzlfdn3
og:image: https://api.daily.dev/og/posts/4LDZlFDN3.png
og:image:alt: Medium
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Medium

**[Medium](https://daily.dev/sources/medium_js)** · 11 min read · 0 upvotes · 0 comments

## Summary

A developer built a zero-dependency Python CLI tool called `project_context` to automate feeding codebase context to LLMs like ChatGPT and Claude, replacing manual copy-pasting. The tool recursively scans a project, filters out noise (.venv, __pycache__, binaries), respects .gitignore, and generates a clean Markdown prompt with an ASCII directory tree and file contents. Key features include a --changed-only flag using `git status --porcelain` to send only modified files, --signatures-only mode that uses Python's AST to extract just function/class signatures (reducing tokens to ~6% of a full dump), and a --grep flag for scoped full-content extraction. Benchmarking with tiktoken revealed a full filtered dump still cost 72,224 tokens, 15x more than needed for most sessions. The tool also warns when an unscoped run touches more than 40 files.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@patan4ik/i-stopped-copy-pasting-code-to-chatgpt-99218555dcbf>

## Questions this post answers

### How can I reduce the number of tokens I send to an LLM when giving it my codebase for context?

Extracting just function and class signatures via Python's AST instead of dumping full file contents costs roughly 6% of the tokens a full dump requires, while still giving the LLM enough architectural understanding. On a real project, a full filtered dump used 72,224 input tokens, while a signatures-only extraction reduced that dramatically, since irrelevant tokens dilute model attention and degrade output quality.

_For anyone tuning LLM context strategy, daily.dev surfaces practical techniques like signature extraction and token budgeting._

### How do I avoid sending irrelevant files like .venv or __pycache__ when generating an LLM prompt from my repository?

Use os.walk and modify the dirnames list in place during traversal so the scanner never enters excluded directories like .venv, node_modules, or __pycache__, rather than filtering files after a full walk. Combining this with .gitignore parsing and a defined DEFAULT_EXCLUDE_DIRS set prevents binary and cache noise from ever reaching the token count.

_Developers automating repo-to-prompt pipelines can find similar filtering patterns curated on daily.dev._

### How can I send only the files I changed to an LLM mid-conversation instead of resending the whole project?

Wrap git status --porcelain in a subprocess call to collect the set of modified file paths, then filter the file collection step to include only those paths when a --changed-only flag is passed. This isolates just the files being actively edited so re-sending context mid-refactor does not blow up the token budget with unchanged code.

_For those wiring git-aware context refresh into an AI workflow, daily.dev tracks similar tooling patterns._

## Similar posts on daily.dev

- [Coding Agents Don’t Need Bigger Context Windows — They Need a Context Compiler](https://daily.dev/posts/coding-agents-don-t-need-bigger-context-windows-they-need-a-context-compiler-kef8o2bp5) · Towards Data Science · 0 upvotes · 0 comments
- [I stopped giving Claude Code my entire project, and my Claude usage lasted 4x longer](https://daily.dev/posts/i-stopped-giving-claude-code-my-entire-project-and-my-claude-usage-lasted-4x-longer-0o1ubxjob) · XDA Developers · 0 upvotes · 0 comments
- [GitHub - drona23/claude-token-efficient: Universal CLAUDE.md - cut Claude output tokens by 63%. Drop-in. No code changes.](https://daily.dev/posts/github---drona23-claude-token-efficient-universal-claude-md---cut-claude-output-tokens-by-63-drop-cba3nnscu) · Hacker News · 3 upvotes · 0 comments
- [Context Is a Budget — Reducing Token Usage in AI-Assisted Development](https://daily.dev/posts/context-is-a-budget-reducing-token-usage-in-ai-assisted-development-avoeycwia) · Foojay.io · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#git](https://daily.dev/tags/git), [#cli](https://daily.dev/tags/cli), [#context-engineering](https://daily.dev/tags/context-engineering)

[View this post on daily.dev](https://daily.dev/posts/medium-4ldzlfdn3)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Medium","url":"https://daily.dev/posts/medium-4ldzlfdn3","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/medium-4ldzlfdn3"},"datePublished":"2026-07-24T11:11:50.060Z","dateModified":"2026-09-14T07:39:07.732Z","description":"A developer built a zero-dependency Python CLI tool called `project_context` to automate feeding codebase context to LLMs like ChatGPT and Claude, replacing...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/157da307e40c7a96587b37917ff64d2e?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/157da307e40c7a96587b37917ff64d2e?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/medium-4ldzlfdn3","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,git,cli,context-engineering","timeRequired":"PT11M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Medium"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/medium-4ldzlfdn3#faq","mainEntity":[{"@type":"Question","name":"How can I reduce the number of tokens I send to an LLM when giving it my codebase for context?","acceptedAnswer":{"@type":"Answer","text":"Extracting just function and class signatures via Python's AST instead of dumping full file contents costs roughly 6% of the tokens a full dump requires, while still giving the LLM enough architectural understanding. On a real project, a full filtered dump used 72,224 input tokens, while a signatures-only extraction reduced that dramatically, since irrelevant tokens dilute model attention and degrade output quality. For anyone tuning LLM context strategy, daily.dev surfaces practical techniques like signature extraction and token budgeting."}},{"@type":"Question","name":"How do I avoid sending irrelevant files like .venv or __pycache__ when generating an LLM prompt from my repository?","acceptedAnswer":{"@type":"Answer","text":"Use os.walk and modify the dirnames list in place during traversal so the scanner never enters excluded directories like .venv, node_modules, or __pycache__, rather than filtering files after a full walk. Combining this with .gitignore parsing and a defined DEFAULT_EXCLUDE_DIRS set prevents binary and cache noise from ever reaching the token count. Developers automating repo-to-prompt pipelines can find similar filtering patterns curated on daily.dev."}},{"@type":"Question","name":"How can I send only the files I changed to an LLM mid-conversation instead of resending the whole project?","acceptedAnswer":{"@type":"Answer","text":"Wrap git status --porcelain in a subprocess call to collect the set of modified file paths, then filter the file collection step to include only those paths when a --changed-only flag is passed. This isolates just the files being actively edited so re-sending context mid-refactor does not blow up the token budget with unchanged code. For those wiring git-aware context refresh into an AI workflow, daily.dev tracks similar tooling patterns."}}]}
```

