crewly
CLAUDE.md84 starsChanged 9 months agoMITView on GitHub
This document outlines the technical preferences and workflow standards for maintaining the Crewly codebase. All Claude Code instances working on this project should follow these guidelines. For both frontend and backend development, every source file must have a corresponding test file placed directly next to it: Mandatory Requirements: - Every .ts file → Must have corresponding .test.ts file - Every .tsx file → Must have corresponding .test.tsx file - Test files → Must be in the same directory as source…
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
34 rules. About 0 are common, 26 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈26
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
All TypeScript code compiles to /dist/ directory
- Distinctive: line 28
Always use TypeScript: - No vanilla JavaScript files in source
- Very specific: line 31
No
anytypes: - Use proper typing or unknown with type guards - Very specific: line 71
Use ES modules (import/export) - No CommonJS require()
- Very specific: line 74
Always include .js extension in imports for Node.js compatibility
- Very specific: line 150
Import from
/config: - Use centralized config directory for all constants - Distinctive: line 152
Never inline magic numbers: - always extract to named constants
- Distinctive: line 154
Maintain 1:1 source-to-test ratio: - Every constants file needs a test file
- Distinctive: line 169
Critical: Write test files next to source files, not in separate test directories.
- Very specific: line 212
Read system specifications: - Always review /specs/ directory to understand system design:
- Distinctive: line 229
Update types: when modifying data structures
- Distinctive: line 230
Update specifications: when making significant architectural changes:
- Distinctive: line 232
Create new spec files for new features or components
- Distinctive: line 233
Ensure specs accurately reflect implemented functionality
- Distinctive: line 234
Update technical diagrams and workflow descriptions
- Distinctive: line 237
MANDATORY: Always perform this checklist before marking work as complete:
- Distinctive: line 287
All deployments must pass:
- Distinctive: line 288
TypeScript compilation: - No type errors
- Distinctive: line 291
Integration tests: - All must pass
- Distinctive: line 295
Use environment variables for configuration
- Distinctive: line 305
Every function, method, and class must include:
- Distinctive: line 347
Explain why: - Not just what the code does, but why it's needed
- Distinctive: line 348
Include edge cases: - Document special handling or limitations
- Distinctive: line 372
Async/await: - no callback-style code
- Very specific: line 395
Always read system specifications: before starting implementation - Review /specs/ directory
- Distinctive: line 398
Always run the full build: before completion
- Distinctive: line 399
Always verify tests pass: before marking work complete
- Distinctive: line 400
Always update specifications: when making significant architectural changes
- Distinctive: line 408
Type check: before every commit
- Distinctive: line 415
Use this checklist for every development task:
- Distinctive: line 480
CRITICAL: When creating any new source file:
- Distinctive: line 487
CRITICAL: Before committing any code:
- Very specific: line 494
CRITICAL: When working on Crewly:
- Distinctive: line 497
Verify implementation matches specs: - Ensure code aligns with documented system design
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Claude Code Development Guidelines for Crewly
This document outlines the technical preferences and workflow standards for maintaining the Crewly codebase. All Claude Code instances working on this project should follow these guidelines.
🏗️ Project Structure
Core Components
- Backend (
/backend/src/) - Express.js server with TypeScript - Frontend (
/frontend/src/) - React.js with TypeScript - MCP Server (
/mcp-server/src/) - TypeScript MCP server for agent communication - CLI (
/cli/src/) - Command-line interface for Crewly operations
Build System
- All TypeScript code compiles to
/dist/directory - Frontend builds to
/frontend/dist/ - Each component has its own
tsconfig.json
System Design Documentation
- Specifications Directory (
/specs/) - Contains authoritative system design documents - Technical Architecture - Documented in
specs/project.md - MCP Implementation - Detailed in
specs/mcp-design.md - UI/UX Guidelines - Defined in
specs/frontend-design.md - User Workflows - Mapped in
specs/user-journey.md
📝 Code Standards
TypeScript Requirements
- Always use TypeScript - No vanilla JavaScript files in source
- Strict type checking - Enable all TypeScript strict mode options
- Explicit types - Define interfaces and types for all data structures
- No
anytypes - Use proper typing orunknownwith type guards
File Organization
CRITICAL: One Source File, One Test File Policy
For both frontend and backend development, every source file must have a corresponding test file placed directly next to it:
✅ Correct Structure (Frontend & Backend):
src/
├── components/
│ ├── TeamCard.tsx
│ ├── TeamCard.test.tsx
│ ├── Modal.tsx
│ └── Modal.test.tsx
├── services/
│ ├── api.service.ts
│ ├── api.service.test.ts
│ ├── auth.service.ts
│ └── auth.service.test.ts
├── types/
│ ├── index.ts
│ └── index.test.ts # Test type utilities and validators
└── utils/
├── helpers.ts
└── helpers.test.ts
❌ Incorrect - NO separate test directories:
src/services/api.service.ts
tests/services/api.service.test.ts
__tests__/api.service.test.tsMandatory Requirements:
- Every
.tsfile → Must have corresponding.test.tsfile - Every
.tsxfile → Must have corresponding.test.tsxfile - Test files → Must be in the same directory as source files
- No exceptions → Even utility files and type definitions need tests
Import/Export Standards
- Use ES modules (
import/export) - No CommonJSrequire() - Relative imports for local files:
./component.js - Absolute imports for packages:
express,react - Always include
.jsextension in imports for Node.js compatibility
Constants and Configuration Management
CRITICAL: No hardcoded values in source code
Constants Organization
- Cross-domain constants →
/config/constants.ts(shared across backend, frontend, CLI, MCP) - Backend-specific constants →
/config/backend-constants.ts(backend-only values) - Frontend-specific constants →
/config/frontend-constants.ts(UI-related constants) - CLI-specific constants →
/config/cli-constants.ts(CLI command configurations) - Centralized exports →
/config/index.ts(single import point for all constants)
Centralized Constants Structure
// /config/constants.ts - Cross-domain shared constants
export const CREWLY_CONSTANTS = {
SESSIONS: {
ORCHESTRATOR_NAME: 'crewly-orc',
DEFAULT_TIMEOUT: 120000,
REGISTRATION_CHECK_INTERVAL: 5000,
},
PATHS: {
CREWLY_HOME: '.crewly',
TEAMS_FILE: 'teams.json',
PROJECTS_FILE: 'projects.json',
CONFIG_DIR: 'config',
PROMPTS_DIR: 'prompts',
},
AGENT_STATUSES: {
INACTIVE: 'inactive',
ACTIVATING: 'activating',
ACTIVE: 'active',
},
WORKING_STATUSES: {
IDLE: 'idle',
IN_PROGRESS: 'in_progress',
},
} as const;
export const MCP_CONSTANTS = {
PORTS: {
DEFAULT: 3001,
HEALTH_CHECK: '/health',
},
TIMEOUTS: {
RESPONSE: 30000,
CONNECTION: 10000,
},
} as const;Import Patterns
// ✅ Import cross-domain constants
import { CREWLY_CONSTANTS, MCP_CONSTANTS } from '../config';
// ✅ Import specific backend constants
import { ORCHESTRATOR_SESSION_NAME, DEFAULT_WEB_PORT } from '../config';
// ✅ Import domain-specific constants
import * as BackendConstants from '../config/backend-constants.js';
// ✅ Import grouped constants for convenience
import { BACKEND_CONSTANTS, CROSS_DOMAIN_CONSTANTS } from '../config';
// ❌ Don't import from individual domain files directly
import { ORCHESTRATOR_SESSION_NAME } from '../config/backend-constants.js'; // Avoid
// ❌ Don't use hardcoded values
const sessionName = 'crewly-orc'; // Use ORCHESTRATOR_SESSION_NAME insteadConstants Best Practices
- Use const assertions (
as const) for immutable objects - Group related constants into logical namespaces
- Use SCREAMING_SNAKE_CASE for constant names
- Import from
/config- Use centralized config directory for all constants - Document constant purposes with JSDoc comments
- Never inline magic numbers - always extract to named constants
- Use enums for related string/number values that form a closed set
- Maintain 1:1 source-to-test ratio - Every constants file needs a test file
Prohibited Hardcoded Values
- Port numbers (3000, 3001, 8080, etc.)
- Timeout values (30000, 120000, etc.)
- File paths ('.crewly', 'config/prompts', etc.)
- Status strings ('active', 'inactive', 'pending', etc.)
- Session names ('crewly-orc', default session patterns)
- API endpoints ('/health', '/api/teams', etc.)
- Magic numbers (retry counts, buffer sizes, etc.)
- Default configurations (check intervals, batch sizes, etc.)
🧪 Testing Standards
Test File Placement
Critical: Write test files next to source files, not in separate test directories.
✅ Correct:
src/
├── user.service.ts
├── user.service.test.ts
├── auth.controller.ts
└── auth.controller.test.ts
❌ Incorrect:
src/user.service.ts
tests/user.service.test.tsTest File Naming
- Unit tests:
*.test.ts - Integration tests:
*.integration.test.ts - End-to-end tests:
*.e2e.test.ts
Testing Requirements
MANDATORY: Every source file must have tests
- Unit tests for all business logic functions
- Integration tests for API endpoints and database operations
- Component tests for React components
- MCP server tests for all MCP tools and protocols
One-to-One Mapping Policy:
- Backend services →
service.test.tsnext toservice.ts - Frontend components →
Component.test.tsxnext toComponent.tsx - API controllers →
controller.test.tsnext tocontroller.ts - Utility functions →
utils.test.tsnext toutils.ts - Type definitions →
types.test.tsfor type guards and validators
Test Coverage Goals
- Minimum 80% code coverage for new features
- 100% coverage for critical business logic
- All public API methods must have tests
🔄 Development Workflow
Before Starting Development
- Read system specifications - Always review
/specs/directory to understand system design:specs/project.md- Core architecture and technical specificationsspecs/mcp-design.md- MCP server implementation detailsspecs/frontend-design.md- UI/UX design patternsspecs/user-journey.md- User workflows and interactions- Task-specific specs in
specs/tasks/subdirectories
- Read existing code to understand patterns and conventions
- Check for existing tests to understand expected behavior
- Run the build to ensure starting from a clean state:
npm run build
During Development
- Write code following TypeScript standards
- Write tests immediately after implementing features
- Use existing patterns found in the codebase
- Update types when modifying data structures
- Update specifications when making significant architectural changes:
- Modify existing spec files in
/specs/when changing system behavior - Create new spec files for new features or components
- Ensure specs accurately reflect implemented functionality
- Update technical diagrams and workflow descriptions
- Modify existing spec files in
Before Completing Work
MANDATORY: Always perform this checklist before marking work as complete:
1. Build Verification
# Build all components
npm run build
# Verify no TypeScript errors
npm run typecheck
# Check linting
npm run lint2. Test Execution
# Run all unit tests
npm run test:unit
# Run integration tests
npm run test:integration
# Run MCP server tests
npm run test:mcp
# Run full test suite
npm test3. Functionality Verification
# Test CLI functionality
npx crewly start --no-browser
# Verify MCP server integration
curl http://localhost:3001/health
# Test backend health
curl http://localhost:3000/health4. Code Quality Checks
- No console.log statements in production code
- No commented-out code blocks
- No TODO comments without GitHub issues
- Proper error handling with try/catch blocks
🚀 Deployment Standards
Build Process
All deployments must pass:
- TypeScript compilation - No type errors
- Linting - ESLint rules must pass
- Unit tests - 100% pass rate required
- Integration tests - All must pass
- Build verification - Compiled code must run successfully
Environment Configuration
- Use environment variables for configuration
- No hardcoded values in source code
- Support for development, test, and production environments
📚 Documentation Requirements
Code Documentation
MANDATORY: All functions must have proper descriptions
Function Documentation Requirements
Every function, method, and class must include:
/**
* Brief description of what this function does (one line)
*
* Detailed explanation if the function is complex, including:
* - Purpose and business logic
* - Algorithm or approach used
* - Side effects or state changes
*
* @param paramName - Description of what this parameter does
* @param options - Configuration object with specific properties
* @returns Description of return value and its structure
* @throws Description of when and what errors might be thrown
*
* @example
* ```typescript
* const result = await processUserData(userData, { validate: true });
* ```
*/
async function processUserData(
userData: UserInput,
options: ProcessOptions
): Promise<ProcessedUser> {
// Implementation
}Documentation Standards
- JSDoc comments for all public functions, methods, and classes
- Inline comments for complex business logic within functions
- Parameter descriptions for all function parameters
- Return type descriptions explaining what is returned
- Example usage for non-trivial functions
- Error handling documentation for functions that can throw
- README.md updates for new features
- API documentation for new endpoints
- Type definitions with descriptive comments
Comment Quality Requirements
- Be specific - "Validates user input" not "Validates data"
- Explain why - Not just what the code does, but why it's needed
- Include edge cases - Document special handling or limitations
- Update with changes - Comments must stay current with code
Commit Standards
# Feature commits
feat: add get_agent_logs MCP tool with terminal monitoring
# Bug fixes
fix: resolve TypeScript compilation errors in MCP server
# Tests
test: add comprehensive unit tests for ActivityMonitor service
# Refactoring
refactor: migrate MCP server from JavaScript to TypeScript🔧 Tool-Specific Guidelines
Backend Development
- Express.js with TypeScript
- Service layer pattern - separate business logic from controllers
- Dependency injection where appropriate
- Async/await - no callback-style code
Frontend Development
- React with TypeScript and hooks
- Component composition over inheritance
- Custom hooks for shared logic
- Proper state management (Context API or external library)
MCP Server Development
- HTTP-based MCP protocol implementation
- Tool definitions with proper TypeScript interfaces
- Error handling with appropriate HTTP status codes
- Rate limiting for tool calls
CLI Development
- Commander.js for argument parsing
- Chalk for colored output
- Proper error codes and user-friendly messages
- Help text for all commands and options
🚨 Critical Rules
Never Skip These Steps
- Always read system specifications before starting implementation - Review
/specs/directory - Always write tests alongside code - One source file = One test file
- Always document functions with proper JSDoc comments
- Always run the full build before completion
- Always verify tests pass before marking work complete
- Always update specifications when making significant architectural changes
- Never commit untested code to main branch
- Never leave TypeScript errors unresolved
- Never create source files without corresponding test files
- Never put premium/paid content in the OSS repo - Premium templates, norms/SOPs, and paid skills belong on Cloud Service (crewlyai.com), not in
config/templates/. OSS repo only has basic/free templates. Enforced bynpm run check:oss-boundary(backend/src/scripts/check-oss-boundary.ts, run in CI by.github/workflows/oss-boundary.ymland insidenpm test): it fails on a paidrequiredTierorworkflows/verificationPipeline/qualityGatesinconfig/templates/, apro-*/*premium*path underconfig/, or an import ofcrewly-pro/@crewly/pro. Exceptions go inconfig/oss-boundary-allowlist.jsonwith a one-line reason (#809). - Always follow the Code Commit SOP (9 steps, 3 review rounds) - See
specs/git-workflow.mdand team norms
Error Prevention
- Type check before every commit
- Test coverage verification required
- Build success mandatory before completion
- Manual testing of modified functionality
📋 Completion Checklist Template
Use this checklist for every development task:
## Pre-Completion Checklist
### Code Quality
- [ ] TypeScript compilation successful (`npm run build`)
- [ ] No linting errors (`npm run lint`)
- [ ] No TypeScript type errors (`npm run typecheck`)
- [ ] Tests written for new functionality (1:1 source-to-test ratio)
- [ ] Test coverage meets requirements
- [ ] All functions have proper JSDoc documentation
- [ ] Every source file has corresponding test file in same directory
### Testing
- [ ] Unit tests pass (`npm run test:unit`)
- [ ] Integration tests pass (`npm run test:integration`)
- [ ] MCP tests pass (`npm run test:mcp`)
- [ ] Full test suite passes (`npm test`)
### Functionality
- [ ] Feature works as expected in development
- [ ] CLI commands function properly (`npx crewly start`)
- [ ] MCP server responds correctly (health check)
- [ ] Backend API endpoints accessible
### Documentation
- [ ] JSDoc comments added to all functions and classes
- [ ] Complex business logic has inline comments
- [ ] All function parameters and return types documented
- [ ] README updated if applicable
- [ ] CHANGELOG.md updated for user-facing changes
- [ ] Type definitions documented
- [ ] Error handling documented for functions that throw
### Specifications
- [ ] Reviewed relevant specs in `/specs/` directory before implementation
- [ ] Updated system specs when making architectural changes
- [ ] Created new spec files for new features or major components
- [ ] Verified implementation matches specification requirements
- [ ] Updated technical diagrams and workflow descriptions if affected
### Final Verification
- [ ] Clean build from scratch works
- [ ] No console errors in browser/terminal
- [ ] All modified files saved and committed
- [ ] Work matches requirements exactly🎯 Success Criteria
Work is considered complete only when:
- All builds pass without errors or warnings
- All tests pass with 100% success rate
- Functionality works as demonstrated by manual testing
- Code quality meets all standards outlined above
- Documentation is updated appropriately
Remember: The goal is not just working code, but maintainable, tested, and documented code that follows project conventions.
🔒 Enforcement Rules
File Creation Policy
CRITICAL: When creating any new source file:
- Create the test file first or immediately after the source file
- Test file must be in the same directory as the source file
- Test file must follow naming convention:
filename.test.tsorfilename.test.tsx - No source file exists without its corresponding test file
Function Documentation Policy
CRITICAL: Before committing any code:
- Every function must have JSDoc comments with description, parameters, and return value
- Complex functions must include examples in JSDoc comments
- Functions that throw errors must document when and what they throw
- No undocumented public functions or methods allowed
Specification Compliance Policy
CRITICAL: When working on Crewly:
- Read specifications first - Review
/specs/directory before any implementation - Update specifications during development - Modify or create spec files when making architectural changes
- Verify implementation matches specs - Ensure code aligns with documented system design
- Keep specifications current - Specs must accurately reflect the implemented system
Violations Are Blocking Issues
- Ignoring system specifications → Implementation review failure, must align with specs first
- Missing test files → Code review failure, must fix before merge
- Missing function documentation → Build failure, must fix before deploy
- Test files in wrong location → Immediate refactoring required
- Incomplete JSDoc → Documentation review failure
- Outdated specifications → Architecture review failure, must update specs with changes
These policies ensure code quality, maintainability, team consistency, and architectural alignment across the entire Crewly project.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

