Skip to content

Latest commit

 

History

History
112 lines (78 loc) · 3.74 KB

CONTRIBUTING.md

File metadata and controls

112 lines (78 loc) · 3.74 KB

Contributing to Claude Code Auto-Router

Thanks for your interest in making Claude Code cheaper and smarter for everyone.

How to Contribute

1. New Classification Patterns

The biggest impact contribution. If you've found prompts that get misclassified, submit a PR:

File: hooks/classify.sh

# T0 patterns: should be cheap (Haiku)
if re.match(r"^(your_new_pattern)", prompt):

# T2 patterns: should be thorough (full model)
elif re.search(r"(your_new_keyword)", prompt):

Requirements for new patterns:

  • Include 3+ real-world prompt examples that the pattern catches
  • Don't break existing classifications (run bash tests/verify.sh)
  • Avoid overly broad patterns (e.g., don't match "is" as a T0 keyword)
  • Add test cases to tests/verify.sh for your new patterns

2. Better Classifiers

The regex classifier is intentionally simple. Contributions for smarter classification are welcome:

  • TF-IDF or embedding-based: Use a lightweight model to classify prompt complexity
  • Token counting heuristic: Short prompts are more likely T0, long ones T1/T2
  • History-aware: If the last 3 prompts were T1, the next one probably is too
  • Project-aware: Read .claude/settings.json to know what tools are available

Rules for alternative classifiers:

  • Must run in <100ms (hook latency matters)
  • Must not require network access (offline-only)
  • Must fall back gracefully to regex if dependencies are missing
  • Must produce the same JSON output format

3. Platform Support

  • Windows edge cases: Git Bash vs WSL vs native PowerShell differences
  • Linux distros: Testing on various distributions
  • CI/CD integration: GitHub Actions, GitLab CI testing

4. Documentation

  • Usage examples with real-world scenarios
  • Screenshots showing the routing in action
  • Translations (especially Chinese, Japanese, Spanish)
  • Blog posts or tutorials about the approach

Development Setup

git clone https://github.com/bijumailbox/claude-auto-router.git
cd claude-auto-router

# Test the hook directly
echo '{"input": "find all python files"}' | bash hooks/classify.sh

# Run the full verification suite
bash tests/verify.sh

# Install locally to test
bash scripts/install.sh

Pull Request Process

  1. Fork the repo
  2. Create a feature branch: git checkout -b feat/better-t0-patterns
  3. Make your changes
  4. Run bash tests/verify.sh — all checks must pass
  5. Submit a PR with:
    • What you changed and why
    • Example prompts that demonstrate the improvement
    • Before/after classification results

Security Requirements

This project handles user input through a shell hook. Security is non-negotiable:

  1. Never interpolate user input into shell strings. All user input must flow through sys.stdin to Python. No $(), no backticks, no eval.
  2. Never use shell=True in any subprocess call.
  3. Never require network access. The classifier must work fully offline.
  4. Always exit 0. The hook must never block user prompts, even on errors.
  5. No dependencies beyond Python stdlib. The hook must work on a fresh system with only Python 3.8+.

If a PR introduces any of these patterns, it will be rejected regardless of the feature value.

Commit Convention

feat: add pattern for database migration prompts
fix: handle unicode prompts in classifier
docs: add Windows troubleshooting section
test: add edge case for empty JSON input
chore: update .gitignore

Code of Conduct

Be kind. Be helpful. Ship improvements.

We're building something useful for the community. Disagreements about classification logic are expected and healthy — resolve them with data (real prompt examples), not opinions.

License

By contributing, you agree that your contributions will be licensed under the MIT License.