Skip to content

Feature Request: SessionStart Hook for Automatic Project Type Detection #293

@Barton0411

Description

@Barton0411

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

  1. Conditional hook execution — Other hooks (e.g., TypeScript type-checking, Biome/Prettier formatting) could check the detected project type and skip themselves if irrelevant.

  2. 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.

  3. Integration with install.sh — The installer could optionally set up this hook automatically.

  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions