PHPackages                             quiche-lorraine/code-context - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. quiche-lorraine/code-context

ActiveLibrary[CLI &amp; Console](/categories/cli)

quiche-lorraine/code-context
============================

Standalone CLI that generates codebase context (JSON + Markdown) for AI agents.

v1.1.3(1w ago)184↓23.3%[1 issues](https://github.com/quiche-lorraine/code-context/issues)MITPHPPHP &gt;=8.2CI passing

Since May 22Pushed 4d agoCompare

[ Source](https://github.com/quiche-lorraine/code-context)[ Packagist](https://packagist.org/packages/quiche-lorraine/code-context)[ RSS](/packages/quiche-lorraine-code-context/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (18)Versions (18)Used By (0)

code-context
============

[](#code-context)

Standalone CLI (built on `symfony/console`) that analyses a PHP codebase and produces a context folder for AI agents, consisting of a structured `context.json` and several agent-oriented `.md` files.

> Status: **Phase 2 in progress**. The foundation is operational: `init`, `generate`, `serve` commands, strict config validation, extractor architecture, Symfony detection, thematic `.md` files.

Installation
------------

[](#installation)

```
composer require --dev quiche-lorraine/code-context
```

Then initialise the agent configuration:

```
vendor/bin/code-context init --agent=mcp         # merge .mcp.json (preserves other servers)
vendor/bin/code-context init --agent=claude-code  # writes .claude/settings.json + rebuild hook
vendor/bin/code-context init --agent=cursor       # writes .cursor/rules/code-context.md
vendor/bin/code-context init --agent=all          # all three agents at once
```

Then generate the first index:

```
vendor/bin/code-context generate
```

`init --agent` command
----------------------

[](#init---agent-command)

```
vendor/bin/code-context init --agent=mcp         # merge into .mcp.json (preserves other servers)
vendor/bin/code-context init --agent=claude-code  # writes .claude/settings.json + hook (skipped if already present)
vendor/bin/code-context init --agent=cursor       # writes .cursor/rules/code-context.md (skipped if already present)
vendor/bin/code-context init --agent=all          # all agents
vendor/bin/code-context init --agent=mcp --dry-run  # prints the result without writing
```

MCP merge is idempotent: a second run is a no-op if the config is already up to date.

For `--agent=claude-code` and `--agent=cursor`: if the target file already exists, the command leaves it untouched (no clobber).

**Projects with an existing `session-start.sh`**: add the hook call from your orchestrator:

```
if [ -x .claude/hooks/code-context-rebuild.sh ]; then
    .claude/hooks/code-context-rebuild.sh
fi
```

Usage
-----

[](#usage)

Main options:

- `generate --config=PATH`: path to a `code-context.yaml` file.
- `generate --output=DIR`: overrides `output.directory` from the YAML.
- `generate --cwd=DIR`: analyse a directory other than the current working directory.

Output generated in `` (default `.code-context/`):

- `context.json`: structured representation consumed by the MCP server.
- `AGENTS.md`: narrative view grouped by namespace.
- `architecture.md`, `routes.md`, `entities.md`, `services.md`, `commands.md`: specialised Symfony views.

SessionStart Hook (Claude Code)
-------------------------------

[](#sessionstart-hook-claude-code)

The `.claude/hooks/code-context-rebuild.sh` file (installed by `init --agent=claude-code`) rebuilds the index at every Claude Code session start.

Architecture
------------

[](#architecture)

```
bin/code-context           Symfony Console entrypoint
src/
    Application.php
    Command/
        InitCommand        init --agent=mcp|claude-code|cursor|all + legacy yaml init
        GenerateCommand    Orchestrates scan + extractors + renderers
        ServeCommand       MCP stdio server
    Config/
        Config             Immutable value object
        ConfigLoader       default.yaml + user override + validation
        ConfigSchema       Strict schema via symfony/config
    Detector/
        SymfonyDetector    Symfony framework detection
    Extractor/             ComposerExtractor, PhpStructureExtractor, SymfonyExtractor, ...
    Kernel/
        ProjectContext     Target project path resolution
    Mcp/
        McpManifestMerger  Non-destructive merge of .mcp.json (idempotent)
        MergeResult        Merge result DTO
    Scanner/
        FileScanner        Discovery via symfony/finder
    Analyzer/
        PhpAstAnalyzer     AST via nikic/php-parser
    Model/                 Immutable DTOs: Context, ClassInfo, MethodInfo, ...
    Renderer/
        JsonRenderer       context.json
        Markdown/          AGENTS.md, architecture.md, routes.md, etc.
    Output/
        OutputWriter       Writes to disk
config/
    default.yaml           Bundled default configuration
recipes/
    quiche-lorraine/code-context/1.0/
        manifest.json      gitignore /.code-context/, copies hook + cursor rules
        .claude/           settings.json + hooks/code-context-rebuild.sh
        .cursor/           rules/code-context.md
    quiche-lorraine/code-context/dev-main/
        manifest.json      (same, for installation from the main branch)
resources/agents/
    claude-code/           Source for init --agent=claude-code
    cursor/                Source for init --agent=cursor

```

Code quality
------------

[](#code-quality)

- `composer test` (PHPUnit)
- `composer lint` (PHPStan)
- `composer fix` (php-cs-fixer)

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance79

Regular maintenance activity

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

9

Last Release

11d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/feccdf52607a7e55db7b2f778ee2932c15a15fd7192fa496b491c95e50d395dd?d=identicon)[quiche-lorraine](/maintainers/quiche-lorraine)

---

Top Contributors

[![wirabelle](https://avatars.githubusercontent.com/u/12933976?v=4)](https://github.com/wirabelle "wirabelle (34 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (19 commits)")

---

Tags

phpclisymfonydevmcpaiContextdevelopmentcode analysisai-agentModel Context Protocol

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/quiche-lorraine-code-context/health.svg)

```
[![Health](https://phpackages.com/badges/quiche-lorraine-code-context/health.svg)](https://phpackages.com/packages/quiche-lorraine-code-context)
```

###  Alternatives

[jolicode/castor

A lightweight and modern task runner. Automate everything. In PHP.

54642.4k4](/packages/jolicode-castor)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M195](/packages/sulu-sulu)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k44](/packages/friendsoftypo3-content-blocks)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M506](/packages/shopware-core)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)[symfony/ai-mate

AI development assistant MCP server for Symfony projects

22104.4k21](/packages/symfony-ai-mate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
