Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions .cursor/rules/development-philosophy.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
description: Core development philosophy and successful patterns for beautiful, maintainable code
alwaysApply: true
---

# Development Philosophy & Successful Patterns

## Core Values

### Beauty as Architecture
- Optimize for code that is both beautiful to read AND architecturally sound
- Never settle for "just working" - always ask "how can this be more beautiful and maintainable?"
- Code should make developers smile when they read it

### Incrementalism Rocks
- Tackle one problem at a time, building on each success
- Get tests passing first, then extract for beauty
- Build reusable frameworks that benefit the entire codebase

### Single Source of Truth
- Eliminate duplication through shared constants and utilities
- Production and test code must use the same constants for perfect sync
- Extract magic strings and repeated patterns into reusable helpers

## Testing Excellence

### Follow Testing Rules Religiously
- **Always use `yarn test:ci`** (never `yarn test` - that's watch mode)
- **Fix tests one at a time** using `.only` to isolate failing tests
- **Run specific test files** with `yarn test:ci path/to/test-file.test.ts`

### Beautiful Test Structure
- **BDD-style naming**: Tests should read like sentences
```typescript
when("handling volunteer applications", (discord) => {
it("sends application form when user clicks volunteer button", async () => {
```
- **Intent-revealing helpers**: Extract complex assertions into beautiful functions
- **Reusable test frameworks**: Build helpers that work across all features
- **Shared constants**: Use production constants in tests for consistency

### Discord Testing Patterns
```typescript
// ✅ Beautiful pattern to follow everywhere
when("handling feature X", (discord) => {
it("accomplishes user goal Y", async () => {
await updateFeatureX(discord);
expectButtonCreated(FEATURE_X.CUSTOM_ID, FEATURE_X.LABEL);
expectInstructionsCreated("featureInstructions");
// ... rest of test
});
});
```

## Code Organization Success Patterns

### File Structure That Works
```
src/features/[feature]/
├── constants.ts # Shared between prod and test
├── [feature].ts # Main implementation
├── [feature].test.ts # Beautiful BDD tests
└── ...

src/test/helpers/
├── describe-discord.ts # when() helper
├── discord-ui-expectations.ts # Reusable UI testing
└── ...
```

### Development Flow
1. **Start with working solution** - Get tests passing first
2. **Extract for beauty** - Move constants, helpers to shared locations
3. **Build reusable frameworks** - Create tools future features can use
4. **Optimize formatting** - Ensure code is beautiful (100 char line width)
5. **Maintain consistency** - Every improvement should benefit whole codebase

## Architectural Patterns

### Constants Strategy
- Create shared constants files (e.g., `features/[feature]/constants.ts`)
- Export structured constant objects with clear naming
- Use `as const` for immutability and strict typing
- Import same constants in both production and test code

### Testing Frameworks
- Build reusable helpers like `discord-ui-expectations.ts`
- Create semantic assertion functions that reveal intent
- Extract repetitive setup into scenario builders
- Use global mocks with proper reset strategies

### Formatting & Style
- Use 100 character line width for readability
- Consistent formatting via `.prettierrc` configuration
- Beautiful imports and function calls
- Meaningful whitespace and organization

## Project-Specific Commands

### Essential Commands
- **Run tests**: `yarn test:ci`
- **Format code**: `yarn format`
- **Lint and fix**: `yarn lint:fix`
- **Full cleanup**: `yarn cleanup`

### Testing Workflow
1. Run `yarn test:ci` to see all failing tests
2. Use `.only` on one failing test to isolate it
3. Run `yarn test:ci path/to/test-file.test.ts` for that file only
4. Fix the test thoroughly and properly
5. Remove `.only` and verify it passes
6. Move to next failing test

## Success Metrics

Code is successful when:
- **Tests read like stories** - Anyone can understand what the feature does
- **Constants are shared** - No duplication between prod and test
- **Helpers are reusable** - New features can use existing test infrastructure
- **Formatting is beautiful** - Code is pleasant to read and maintain
- **Architecture is sound** - Changes in one place automatically benefit everywhere

Remember: **Optimize for beauty AND architectural soundness at every step.**
46 changes: 46 additions & 0 deletions .cursor/rules/formatting-and-linting.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
description: Guidelines for fixing formatting and linting issues
alwaysApply: true
---

# Formatting and Linting Guidelines

## Automatic Fix Commands

**Always use automated tools to fix formatting and linting issues before attempting manual fixes.**

### For All Files

- **`yarn lint:fix`** - Fixes ESLint issues including formatting (recommended first step)
- **`yarn format`** - Formats code using prettier-eslint
- **`yarn cleanup`** - Runs both lint:fix AND format (most comprehensive)

### For Specific Files

When targeting a specific file, use npx directly:

- **`npx eslint --fix path/to/file.ts`** - Fix ESLint issues in specific file
- **`npx prettier-eslint --write path/to/file.ts`** - Format specific file

## Command Priority and Usage

1. **Start with `yarn lint:fix`** - This fixes most ESLint issues including formatting since prettier is integrated as an ESLint rule
2. **Follow with `yarn format`** if needed - This handles any remaining formatting that prettier-eslint might catch
3. **Use `yarn cleanup`** for comprehensive fixing - Runs both commands in sequence
4. **For specific files** - Use the npx commands shown above

## Why Both Commands Exist

- **`yarn lint:fix`**: Fixes ESLint issues (including prettier formatting since prettier is integrated)
- **`yarn format`**: Uses prettier-eslint to ensure formatting meets both prettier and ESLint standards
- They complement each other and are not redundant

## Manual Fixes

Only attempt manual fixes for linting/formatting issues after running the automated tools. The automated tools handle:

- Indentation and spacing
- Semicolons and commas
- Quotes and brackets
- Import organization
- Most TypeScript-specific formatting rules
33 changes: 33 additions & 0 deletions .cursor/rules/unit-tests.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
description: Testing guidelines and best practices for unit tests
alwaysApply: true
---

# Unit Testing Guidelines

## Test Execution Rules

- **Always use `yarn test:ci`** to run tests in CI mode
- **Never use `yarn test`** - it runs in watch mode which is not suitable for one-off test runs
- **Always fix tests one at a time** in a tight development loop
- **Always use `.only`** to isolate a single test when debugging or fixing issues
- **When using `.only`, run the specific test file** with `yarn test:ci path/to/test-file.test.ts` for complete isolation

## Test Quality Standards

- **Always fix tests properly** - never give up on a failing test
- **Never remove or descope tests** - good tests are crucial and cannot be skipped
- **Tests must be comprehensive** and cover all important functionality
- **Maintain high test quality** as tests are essential for code reliability

## Development Workflow

1. Run `yarn test:ci` to identify failing tests
2. Use `.only` on a single failing test to isolate it
3. Run `yarn test:ci path/to/test-file.test.ts` to run only that test file
4. Fix the test thoroughly and properly
5. Remove `.only` and verify the test passes with `yarn test:ci path/to/test-file.test.ts`
6. Move to the next failing test
7. Repeat until all tests pass

Remember: **Good tests are non-negotiable** - they ensure code quality and prevent regressions.
12 changes: 9 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"plugins": ["@typescript-eslint", "prettier", "import"],
"rules": {
"prettier/prettier": ["error", { "endOfLine": "auto" }],
"import/prefer-default-export": "off"
"prettier/prettier": "error",
"import/prefer-default-export": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
],
"no-unused-vars": "off",
"curly": ["error", "all"]
}
}
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"quoteProps": "as-needed",
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "auto"
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
83 changes: 83 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Claude Development Memory

## Successful Development Patterns & Philosophy

### Our Core Values
- **Beauty as Architecture** - We optimize for code that is both beautiful to read and architecturally sound
- **Incrementalism Rocks** - Tackle one problem at a time, building on each success
- **Reusability Over Repetition** - Create frameworks and patterns that benefit the entire codebase
- **Single Source of Truth** - Eliminate duplication through shared constants and utilities

### Testing Excellence
- **Follow cursor rules religiously** - Always use `yarn test:ci`, fix tests one at a time with `.only`
- **BDD-style naming** - Tests should read like sentences: `when("handling X", (discord) => { it("does Y") })`
- **Beautiful helpers over repetition** - Extract complex assertions into intent-revealing functions
- **Shared constants** - Production and test code use the same constants for perfect sync
- **Reusable test frameworks** - Build helpers that work across all features (like `discord-ui-expectations.ts`)

### Code Organization Success Patterns
1. **Start with working solution** - Get tests passing first
2. **Extract for beauty** - Move constants, helpers, and utilities to shared locations
3. **Build reusable frameworks** - Create tools that future features can use
4. **Optimize formatting** - Ensure code is beautiful and readable (100 char line width)
5. **Maintain architectural consistency** - Every improvement should benefit the whole codebase

### Architectural Wins from Recent Session
- **Global Discord mocks** in `test/setup.ts` - Consistent testing environment
- **`when()` helper** - Beautiful BDD-style test syntax with automatic Discord setup
- **Shared constants** - Production code and tests use same values (see `features/applications/constants.ts`)
- **Reusable UI expectations** - `discord-ui-expectations.ts` works across all Discord features
- **Beautiful formatting** - 100 char lines, consistent style via `.prettierrc`

### Discord Testing Patterns
```typescript
// ✅ Beautiful pattern to follow
when("handling feature X", (discord) => {
it("accomplishes user goal Y", async () => {
await updateFeatureX(discord);
expectButtonCreated(FEATURE_X.CUSTOM_ID, FEATURE_X.LABEL);
// ... rest of test
});
});
```

### File Organization That Works
```
src/features/[feature]/
├── constants.ts # Shared between prod and test
├── [feature].ts # Main implementation
├── [feature].test.ts # Beautiful BDD tests
└── ...

src/test/helpers/
├── describe-discord.ts # when() helper
├── discord-ui-expectations.ts # Reusable UI testing
└── ...
```

## Project-Specific Context

### Cursor Rules Location
- **Cursor rules directory**: `.cursor/rules/`
- **Current rules**:
- `unit-tests.mdc` - Testing guidelines and best practices
- `formatting-and-linting.mdc` - Code formatting automation
- `development-philosophy.mdc` - Core development philosophy (this session's learnings)
- All rules are set to `alwaysApply: true` for consistent guidance

### Testing Commands
- **Run tests**: `yarn test:ci` (never `yarn test` - that's watch mode)
- **Format code**: `yarn format`
- **Lint and fix**: `yarn lint:fix`
- **Full cleanup**: `yarn cleanup`

### Current Architecture
- **Discord bot** using discord.js with TypeScript
- **Global test setup** in `src/test/setup.ts` with automatic mock management
- **BDD-style testing** with `when()` helper for readable test organization
- **Shared constants** between production and test code for consistency
- **100 character line width** for beautiful, readable formatting

---

*This memory captures our successful collaborative approach. The key is always optimizing for both beauty and architectural soundness, building reusable patterns that make the entire codebase better.*
Loading