Step-by-step bug fix workflow for Composition Support. Use when: - Fixing a bug or issue - Debugging unexpected behavior - User reports something broken - Need structured approach to bug resolution
Structured workflow for diagnosing and fixing bugs in Composition Support Dashboard.
Phase 1: Reproduce ──► Phase 2: Diagnose ──► Phase 3: Fix ──► Phase 4: Verify
│ │ │ │
▼ ▼ ▼ ▼
Confirm bug Find root cause Apply fix Test & review
Ask user if not provided:
| Question | Why |
|---|---|
| What did you expect? | Defines success criteria |
| What actually happened? | Confirms the bug |
| Steps to reproduce? | Essential for diagnosis |
| Browser/device? | May be environment-specific |
| Screenshots/console errors? | Visual evidence |
1. Start dev server: npm run dev
2. Navigate to affected area
3. Follow reported steps
4. Check browser console for errors
5. Check terminal for server errors
## Bug Report
**Expected**: [behavior]
**Actual**: [behavior]
**Steps**:
1. [step 1]
2. [step 2]
**Environment**: [browser/device]
**Console Errors**: [errors if any]
| Severity | Criteria | Action |
|---|---|---|
| Critical | App unusable, data loss, security | Fix immediately |
| Major | Feature broken, no workaround | Fix soon |
| Minor | Feature impaired, workaround exists | Fix eventually |
| Cosmetic | Visual issue only | Low priority |
1. Identify affected component (grep by text/feature)
2. Check related store state
3. Check engine calculations (if music theory)
4. Check i18n keys (if translation issue)
5. Check theme/styles (if visual issue)
// Check if state is updating
const { currentKey, harmonyResult } = useAppStore();
console.log('currentKey:', currentKey);
// Check if action is called
setKey(root, tonality);
Symptoms: UI doesn't update, stale data
Causes: Missing state update, wrong selector, race condition
// Check engine output
import { calculateHarmony } from '@/lib/music-theory/engine';
const result = calculateHarmony('C', 'Major');
console.log('Harmony result:', result);
Symptoms: Wrong notes/chords, unexpected values
Causes: Wrong formula, edge case not handled, wrong constants
// Check props and rendering
const Component = ({ value }: Props) => {
console.log('Component render:', value);
// ...
};
Symptoms: UI glitch, wrong display, crash
Causes: Missing prop, wrong prop type, null/undefined
// Check theme values
const StyledDiv = styled.div`
background: ${({ theme }) => {
console.log('theme:', theme);
return theme.colors.background;
}};
`;
Symptoms: Wrong colors, layout break, overflow
Causes: Wrong theme path, missing responsive styles, CSS specificity
| Tool | Use For |
|---|---|
console.log | Quick value inspection |
| React DevTools | Component state, props |
| Redux/Zustand DevTools | Store state changes |
| Browser Network Tab | API calls, assets |
| TypeScript compiler | Type errors |
## Diagnosis Summary
**Location**: [file:line]
**Root Cause**: [description]
**Type**: [state/calculation/component/style/other]
**Affected Code**:
- [file1]
- [file2]
**Side Effects**: [other affected areas]
| Bug Type | Approach |
|---|---|
| State | Ensure proper updates, check selectors |
| Calculation | Fix formula, add edge case handling |
| Component | Add null checks, fix prop types |
| Style | Use theme values, add responsive rules |
| i18n | Add missing keys to all locales |
DO:
- Make smallest change that fixes the bug
- Preserve existing behavior elsewhere
- Add defensive checks (null guards, edge cases)
- Follow existing code patterns
DON'T:
- Refactor surrounding code
- Add new features
- Change unrelated behavior
- Over-engineer the solution
// Before
const name = user.profile.name;
// After
const name = user?.profile?.name ?? 'Unknown';
// Before
set({ value: newValue });
// After - if depending on previous state
set((state) => ({ ...state, value: newValue }));
// Before
const scale = scales[tonality];
// After
const scale = scales[tonality] ?? scales['Major']; // fallback
if (!scales[tonality]) {
console.warn(`Unknown tonality: ${tonality}, using Major`);
}
// Before
const Container = styled.div`
width: 500px;
`;
// After
const Container = styled.div`
width: 100%;
max-width: 500px;
@media (max-width: 768px) {
width: 100%;
max-width: none;
}
`;
Document the bug to prevent recurrence:
## Bug: [Title]
**Issue**: [description]
**Fix**: [what was changed]
**Files**: [list]
**Test case**: [steps that would have caught this]
1. Reproduce original bug - should NOT occur
2. Test the fix in isolation
3. Test with edge cases
4. Test on different browsers (if relevant)
5. Test responsive behavior (if UI)
1. Check related features still work
2. Check no new console errors
3. Check no TypeScript errors
4. Check no ESLint warnings
npm run lint
npm run build
## Bug Fix Verification
- [ ] Original bug is fixed
- [ ] No new errors introduced
- [ ] Edge cases handled
- [ ] Lint passes
- [ ] Build passes
- [ ] Related features still work
Bug fix complete. I recommend code review:
"@SeniorCodeReviewer please review this bug fix in [file]:
- Original issue: [description]
- Root cause: [cause]
- Fix: [change made]"
| Bug | Symptoms | Fix |
|---|---|---|
| Wrong enharmonic | Shows D# instead of Eb | Check enharmonicMap in constants |
| Missing tonality | Crash or undefined | Add fallback to Major |
| Wrong chord quality | Incorrect chord symbol | Check quality calculation in engine |
| Bug | Symptoms | Fix |
|---|---|---|
| State not persisting | Lost on refresh | Check persist config in store |
| Stale harmony result | Doesn't update | Ensure setKey recalculates |
| Tier not updating | Premium features wrong | Check userTier persistence |
| Bug | Symptoms | Fix |
|---|---|---|
| Missing translation | Shows key instead of text | Add key to all 3 locale files |
| Wrong language | Text in wrong language | Check i18n initialization |
| Bug | Symptoms | Fix |
|---|---|---|
| Theme not applied | Wrong colors | Check theme provider wrapper |
| Mobile broken | Layout issues | Add responsive breakpoints |
| Animation janky | Stuttering | Check Framer Motion config |
Escalate to specialists when:
| Situation | Escalate To |
|---|---|
| UX implications | @SeniorMusicUXDesigner |
| Architecture change needed | @SeniorMusicAppDeveloper |
| Scope creep detected | @SeniorMusicProductOwner |
| Complex multi-file fix | @SeniorTaskPlanner for breakdown |
# Start dev server
npm run dev
# Check for errors
npm run lint
npm run build
# Search for code
grep -r "search term" src/
# Check specific file
cat src/path/to/file.tsx