Skip to content

Commit b9ded83

Browse files
fix: code quality improvements (#3649)
## Summary - Fixed incorrect `await` on SQLAlchemy `delete()` calls - Extracted duplicate Claude prompts from workflows to `prompts/workflow-prompts/` - Added React ErrorBoundary component - Fixed test warnings for unawaited coroutines - Removed deprecated prompt files ## Changes - `core/database/repositories.py` - Remove await from sync delete() - `app/src/components/ErrorBoundary.tsx` - New component - `app/src/router.tsx` - Wrap with ErrorBoundary - `.github/workflows/impl-generate.yml` - Use external prompt file - `.github/workflows/impl-repair.yml` - Use external prompt file - `prompts/workflow-prompts/impl-generate-claude.md` - New - `prompts/workflow-prompts/impl-repair-claude.md` - New - `tests/unit/api/test_analytics.py` - Fix coroutine warnings ## Test plan - [x] 848 unit tests pass - [x] Lint/format checks pass - [x] Frontend builds successfully - [x] YAML syntax validated 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent dc2c1fc commit b9ded83

File tree

14 files changed

+657
-431
lines changed

14 files changed

+657
-431
lines changed

.claude/commands/check.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Quick Code Check
2+
3+
> Fast code quality check for recent changes. Use `/refactor` for comprehensive analysis.
4+
5+
## Run Checks
6+
7+
```bash
8+
# Lint check
9+
uv run ruff check .
10+
11+
# Format check
12+
uv run ruff format . --check && echo "Formatting OK" || echo "Formatting issues found"
13+
14+
# Quick unit tests
15+
uv run pytest tests/unit -x -q --tb=short 2>/dev/null | tail -30
16+
```
17+
18+
## Check Recent Changes
19+
20+
```bash
21+
# Files changed vs main
22+
git diff --name-only main... 2>/dev/null || git diff --name-only HEAD~5
23+
```
24+
25+
## Summary
26+
27+
Provide a brief summary:
28+
1. Any lint/format issues found
29+
2. Test status
30+
3. Quick recommendations for the changed files

.claude/commands/prime.md

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,52 @@
11
# Prime
22

3-
> Execute the following sections to understand the codebase then summarize your understanding.
3+
> Quickly understand the pyplots codebase - structure, rules, and current state.
44
5-
## Run
5+
## Project Rules
66

7-
git ls-files
7+
@CLAUDE.md
88

9-
## Read
9+
## Project Config
1010

11-
@README.md
1211
@pyproject.toml
13-
@docs/concepts/vision.md
14-
@docs/workflows/overview.md
15-
@docs/reference/repository.md
1612

17-
## Read and Execute
13+
## Quick Stats
1814

15+
```bash
16+
# Repository overview
17+
echo "=== Repository Stats ==="
18+
echo "Plot specifications: $(ls -d plots/*/ 2>/dev/null | wc -l)"
19+
echo "Python files: $(find api core automation tests -name '*.py' 2>/dev/null | wc -l)"
20+
echo "Frontend files: $(find app/src -name '*.tsx' -o -name '*.ts' 2>/dev/null | wc -l)"
21+
echo "Workflows: $(ls .github/workflows/*.yml 2>/dev/null | wc -l)"
22+
echo "Prompts: $(find prompts -name '*.md' 2>/dev/null | wc -l)"
23+
```
1924

25+
## Structure
2026

27+
```bash
28+
# Key directories
29+
ls -la api/ core/ app/src/ prompts/ .github/workflows/ 2>/dev/null | head -50
2130

31+
# Documentation
32+
find docs -name "*.md" 2>/dev/null | sort
33+
```
34+
35+
## Current State
36+
37+
```bash
38+
# Git status
39+
git status --short
40+
41+
# Recent activity
42+
git log --oneline -10
43+
```
44+
45+
## Summarize
46+
47+
After reading, provide:
48+
1. **Purpose**: What does this project do?
49+
2. **Architecture**: Key components and how they connect
50+
3. **Workflow**: How specs become implementations
51+
4. **Tech Stack**: Languages, frameworks, infrastructure
52+
5. **Key Rules**: Critical constraints from CLAUDE.md

.claude/commands/refactor.md

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# Code Quality Refactor
2+
3+
> Comprehensive code quality analysis for the pyplots repository. Checks readability, performance, code smells, consistency, and modernization opportunities across all components.
4+
5+
## Context
6+
7+
@CLAUDE.md
8+
@pyproject.toml
9+
10+
## Analysis Scope
11+
12+
Analyze the following areas systematically. For each area, identify:
13+
- **Code Smells**: Dead code, duplication, overly complex functions, god classes
14+
- **Readability**: Unclear naming, missing/outdated comments, inconsistent formatting
15+
- **Performance**: Inefficient patterns, N+1 queries, unnecessary computations
16+
- **Modernization**: Deprecated APIs, old Python patterns, outdated dependencies
17+
- **Consistency**: Naming conventions, import styles, error handling patterns
18+
- **Type Safety**: Missing type hints, incorrect types, Any overuse
19+
- **Test Quality**: Missing tests, flaky tests, poor assertions
20+
21+
## Discover Structure
22+
23+
```bash
24+
# Overview of repository structure
25+
find . -type f -name "*.py" | grep -E "^\./(api|core|automation|tests)/" | head -80
26+
27+
# Frontend structure
28+
find ./app/src -type f -name "*.ts" -o -name "*.tsx" 2>/dev/null | head -40
29+
30+
# Workflow files
31+
ls -la .github/workflows/*.yml 2>/dev/null
32+
33+
# Prompt files
34+
find ./prompts -type f -name "*.md" 2>/dev/null
35+
36+
# Documentation
37+
find ./docs -type f -name "*.md" 2>/dev/null
38+
```
39+
40+
## Run Quality Checks
41+
42+
```bash
43+
# Linting issues
44+
uv run ruff check .
45+
46+
# Format check (dry-run)
47+
uv run ruff format . --check --diff
48+
```
49+
50+
## Analyze Backend (api/)
51+
52+
Check for:
53+
- Router organization and REST conventions
54+
- Dependency injection patterns
55+
- Error handling consistency
56+
- Response schema completeness
57+
- Async/await correctness
58+
- Caching strategies
59+
60+
```bash
61+
ls -la api/*.py api/**/*.py 2>/dev/null
62+
```
63+
64+
## Analyze Core Logic (core/)
65+
66+
Check for:
67+
- Repository pattern implementation
68+
- Database model design
69+
- Configuration management
70+
- Utility function organization
71+
- Type definitions
72+
73+
```bash
74+
ls -la core/*.py core/**/*.py 2>/dev/null
75+
```
76+
77+
## Analyze Automation (automation/)
78+
79+
Check for:
80+
- Script modularity
81+
- Error handling in workflows
82+
- CLI argument parsing
83+
- Logging consistency
84+
85+
```bash
86+
ls -la automation/**/*.py 2>/dev/null
87+
```
88+
89+
## Analyze Frontend (app/src/)
90+
91+
Check for:
92+
- Component structure and reusability
93+
- Hook patterns and custom hooks
94+
- TypeScript strictness (no `any`, proper interfaces)
95+
- Performance (memo, useCallback only where truly needed)
96+
- Accessibility (aria-labels, keyboard navigation, focus management)
97+
- Consistent error handling and error boundaries
98+
- Loading states and skeletons
99+
- Unused imports and dead code
100+
101+
```bash
102+
ls -la app/src/**/*.tsx app/src/**/*.ts 2>/dev/null | head -30
103+
```
104+
105+
## Analyze Tests (tests/)
106+
107+
Check for:
108+
- Test coverage gaps
109+
- Fixture organization
110+
- Mock patterns
111+
- Assertion quality
112+
- Test naming conventions
113+
114+
```bash
115+
find tests -name "*.py" -type f | head -30
116+
```
117+
118+
## Analyze GitHub Workflows (.github/workflows/)
119+
120+
Check for:
121+
- Workflow consistency and naming
122+
- Job dependencies and parallelization
123+
- Secret handling and security
124+
- Error handling and failure modes
125+
- Concurrency settings
126+
- Reusable workflows vs duplication
127+
- Environment variable consistency
128+
- Trigger conditions (labels, paths, branches)
129+
130+
```bash
131+
ls -la .github/workflows/*.yml
132+
```
133+
134+
## Analyze AI Prompts (prompts/)
135+
136+
Check for:
137+
- Prompt clarity and structure
138+
- Consistency across prompt files
139+
- Outdated instructions or references
140+
- Missing edge cases
141+
- Template completeness
142+
- Library-specific rules alignment
143+
144+
```bash
145+
find prompts -name "*.md" -o -name "*.yaml" | sort
146+
```
147+
148+
## Analyze Documentation (docs/)
149+
150+
Check for:
151+
- Outdated information vs actual code
152+
- Missing documentation for new features
153+
- Broken internal links
154+
- Inconsistent formatting
155+
- Sync with CLAUDE.md
156+
157+
```bash
158+
find docs -name "*.md" | sort
159+
```
160+
161+
## Cross-Check: Consistency
162+
163+
Verify alignment across components:
164+
- Do workflows reference existing prompt files?
165+
- Are library names consistent across `prompts/library/`, `core/constants.py`, workflows?
166+
- Do workflow labels match documentation?
167+
- Are schema definitions in sync between API and frontend types?
168+
169+
```bash
170+
# Check prompt references in workflows
171+
grep -r "prompts/" .github/workflows/ 2>/dev/null | head -20
172+
173+
# Library definitions
174+
ls prompts/library/ 2>/dev/null | sed 's/.md//' | sort
175+
grep -E "SUPPORTED_LIBRARIES|LIBRARIES" core/constants.py 2>/dev/null | head -5
176+
```
177+
178+
## Run Test Suite
179+
180+
```bash
181+
# Quick test run to check for failures
182+
uv run pytest tests/unit -x -q --tb=no 2>/dev/null | tail -20
183+
```
184+
185+
## Output Format
186+
187+
After analysis, provide a structured report:
188+
189+
### 1. Critical Issues (Must Fix)
190+
Issues that could cause bugs, security problems, or break functionality.
191+
192+
### 2. High Priority (Should Fix)
193+
Code smells, performance issues, or maintainability concerns.
194+
195+
### 3. Medium Priority (Consider)
196+
Modernization opportunities, style improvements, minor inconsistencies.
197+
198+
### 4. Low Priority (Nice to Have)
199+
Minor improvements, documentation updates, cosmetic changes.
200+
201+
### 5. Positive Patterns
202+
Good practices found that should be maintained or expanded.
203+
204+
For each issue, provide:
205+
- **Location**: File path and line number
206+
- **Problem**: Clear description of the issue
207+
- **Impact**: Why this matters
208+
- **Solution**: Specific fix recommendation
209+
- **Effort**: Low/Medium/High
210+
211+
## Exclusions
212+
213+
Do NOT flag:
214+
- Plot implementations in `plots/` (AI-generated, different style rules)
215+
- Generated files or lock files (`uv.lock`, `yarn.lock`, etc.)
216+
- Third-party code
217+
- Issues already tracked in pyproject.toml exclusions

0 commit comments

Comments
 (0)