-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Problem
ECC installs rules for multiple languages (common + python + typescript + golang), but all rules are loaded into the context window on every session, regardless of the actual project type. This wastes context tokens and can introduce irrelevant guidance.
For example, a user working on a pure Python data analysis project still gets TypeScript coding style rules loaded ("use interface not type", React hooks patterns, etc.), consuming context space and potentially confusing Claude's recommendations.
This was briefly discussed in #143, where @MawJPhysics noted that having unused language agents loaded consumes context tokens unnecessarily for single-language workflows.
Proposed Solution
A SessionStart hook that auto-detects the project type by inspecting files in the working directory, and outputs a JSON summary for Claude to reference.
Detection logic:
| File detected | Project type |
|---|---|
requirements.txt, pyproject.toml, setup.py, *.py |
python |
package.json, tsconfig.json, *.ts, *.tsx |
typescript |
go.mod |
golang |
requirements.txt + package.json (both) |
fullstack |
Example output:
{"project_types": "python", "project_dir": "/home/user/my-project"}Reference implementation (bash):
#!/bin/bash
# detect-project-type.sh — SessionStart hook
PROJECT_DIR="${PWD}"
DETECTED_TYPES=""
if [ -f "$PROJECT_DIR/requirements.txt" ] || [ -f "$PROJECT_DIR/pyproject.toml" ] || [ -f "$PROJECT_DIR/setup.py" ]; then
DETECTED_TYPES="${DETECTED_TYPES}python,"
fi
if [ -f "$PROJECT_DIR/package.json" ] || [ -f "$PROJECT_DIR/tsconfig.json" ]; then
DETECTED_TYPES="${DETECTED_TYPES}typescript,"
fi
if [ -f "$PROJECT_DIR/go.mod" ]; then
DETECTED_TYPES="${DETECTED_TYPES}golang,"
fi
DETECTED_TYPES=$(echo "$DETECTED_TYPES" | sed 's/,$//')
if [ -z "$DETECTED_TYPES" ]; then
DETECTED_TYPES="unknown"
fi
echo "{\"project_types\": \"$DETECTED_TYPES\", \"project_dir\": \"$PROJECT_DIR\"}"Hook config in settings.json:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "bash ~/.claude/scripts/detect-project-type.sh"
}
]
}
]
}
}Potential Extensions
-
Conditional hook execution — Other hooks (e.g., TypeScript type-checking, Biome/Prettier formatting) could check the detected project type and skip themselves if irrelevant.
-
Node.js version for cross-platform — The reference implementation is in bash. For consistency with ECC's existing hooks (all Node.js), this could be rewritten in Node.js.
-
Integration with
install.sh— The installer could optionally set up this hook automatically. -
Framework-level detection — Beyond language, detect specific frameworks (FastAPI, Django, Next.js, React, Flask) to enable even more targeted skill/agent recommendations.
Context
I work primarily in Python but am transitioning some projects to use web frontends (Python backend + React/Next.js frontend). After installing ECC with both python and typescript rules, I noticed the TypeScript rules loaded on every Python-only session. This hook solves the problem by giving Claude awareness of the current project's tech stack at session start.
Environment
- Claude Code: latest
- ECC: v1.6.0 (installed via
install.sh python typescript) - OS: macOS