Codexray is a local-first code-health and refactoring analysis tool for TypeScript repositories. It's a CLI tool that runs entirely offline and is designed to be easy to Dockerize.
The project follows a clean architecture with these layers:
- CLI layer (
src/cli/) - Command definitions and entry point - Core analysis engine (
src/core/) - Scanner, analyzer, project loader - Rule system (
src/rules/) - Rule types, registry, and implementations - Findings model (
src/findings/) - Finding types and interfaces - Fix/edit model (
src/fixes/) - Fix types and application logic - Reporters (
src/reporters/) - Terminal and JSON output adapters - Config (
src/config/) - Configuration types and defaults - Utils (
src/utils/) - AST helper utilities
- Use TypeScript strict mode
- Prefer simple, explicit code over clever abstractions
- Avoid overengineering
- Keep files focused and avoid giant god files
- One primary export per file when practical
- Use
index.tsfiles for barrel exports - Keep tests in
tests/directory mirroringsrc/structure
- Use camelCase for variables and functions
- Use PascalCase for types, interfaces, and classes
- Use kebab-case for file names
- Rule IDs use kebab-case (e.g.,
no-large-functions)
- Use
.jsextensions for local imports (required for ESM compatibility) - Group imports: external → internal → local
- Throw descriptive errors
- Handle errors gracefully in CLI commands
- Exit with appropriate codes (0 for success, 1 for errors)
- Use Vitest for testing
- Place tests in
tests/directory - Use
describe/itblocks - Reset counters and state in
beforeEach - Use in-memory file system for unit tests when possible
npm run build # Compile TypeScript to dist/npm start -- <command> # Run CLI locally
node dist/cli/index.js <command> # Run compiled CLI- Create a new file in
src/rules/implementations/ - Implement the
Ruleinterface fromsrc/rules/types.ts - Export from
src/rules/implementations/index.ts - Add to
builtInRulesarray - Add tests in
tests/rules/
For autofix support, implement AutoFixableRule interface.
- Create a new file in
src/reporters/ - Implement format and output functions
- Add to CLI commands as needed
Configuration is via codexray.config.json or rule-specific options in CLI.
The architecture supports future additions:
- Action planning from findings
- Local plan files
- External issue creation (Jira, etc.)
- Markdown reporter
- More rules
These are extension points only - not currently implemented.