Skip to content

Commit 934f267

Browse files
authored
[refactor] Reorganize CLAUDE.md into hierarchical subdirectory files (#4640)
1 parent 907662a commit 934f267

File tree

5 files changed

+169
-58
lines changed

5 files changed

+169
-58
lines changed

CLAUDE.md

Lines changed: 50 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,50 @@
1-
- use `npm run` to see what commands are available
2-
- For component communication, prefer Vue's event-based pattern (emit/@event-name) for state changes and notifications; use defineExpose with refs only for imperative operations that need direct control (like form.validate(), modal.open(), or editor.focus()); events promote loose coupling and are better for reusable components, while exposed methods are acceptable for tightly-coupled component pairs or when wrapping third-party libraries that require imperative APIs
3-
- After making code changes, follow this general process: (1) Create unit tests, component tests, browser tests (if appropriate for each), (2) run unit tests, component tests, and browser tests until passing, (3) run typecheck, lint, format (with prettier) -- you can use `npm run` command to see the scripts available, (4) check if any READMEs (including nested) or documentation needs to be updated, (5) Decide whether the changes are worth adding new content to the external documentation for (or would requires changes to the external documentation) at https://docs.comfy.org, then present your suggestion
4-
- When referencing PrimeVue, you can get all the docs here: https://primevue.org. Do this instead of making up or inferring names of Components
5-
- When trying to set tailwind classes for dark theme, use "dark-theme:" prefix rather than "dark:"
6-
- Never add lines to PR descriptions or commit messages that say "Generated with Claude Code"
7-
- When making PR names and commit messages, if you are going to add a prefix like "docs:", "feat:", "bugfix:", use square brackets around the prefix term and do not use a colon (e.g., should be "[docs]" rather than "docs:").
8-
- When I reference GitHub Repos related to Comfy-Org, you should proactively fetch or read the associated information in the repo. To do so, you should exhaust all options: (1) Check if we have a local copy of the repo, (2) Use the GitHub API to fetch the information; you may want to do this IN ADDITION to the other options, especially for reading specific branches/PRs/comments/reviews/metadata, and (3) curl the GitHub website and parse the html or json responses
9-
- For information about ComfyUI, ComfyUI_frontend, or ComfyUI-Manager, you can web search or download these wikis: https://deepwiki.com/Comfy-Org/ComfyUI-Manager, https://deepwiki.com/Comfy-Org/ComfyUI_frontend/1-overview, https://deepwiki.com/comfyanonymous/ComfyUI/2-core-architecture
10-
- If a question/project is related to Comfy-Org, Comfy, or ComfyUI ecosystem, you should proactively use the Comfy docs to answer the question. The docs may be referenced with URLs like https://docs.comfy.org
11-
- When operating inside a repo, check for README files at key locations in the repo detailing info about the contents of that folder. E.g., top-level key folders like tests-ui, browser_tests, composables, extensions/core, stores, services often have their own README.md files. When writing code, make sure to frequently reference these README files to understand the overall architecture and design of the project. Pay close attention to the snippets to learn particular patterns that seem to be there for a reason, as you should emulate those.
12-
- Prefer running single tests, and not the whole test suite, for performance
13-
- If using a lesser known or complex CLI tool, run the --help to see the documentation before deciding what to run, even if just for double-checking or verifying things.
14-
- IMPORTANT: the most important goal when writing code is to create clean, best-practices, sustainable, and scalable public APIs and interfaces. Our app is used by thousands of users and we have thousands of mods/extensions that are constantly changing and updating; and we are also always updating. That's why it is IMPORTANT that we design systems and write code that follows practices of domain-driven design, object-oriented design, and design patterns (such that you can assure stability while allowing for all components around you to change and evolve). We ABSOLUTELY prioritize clean APIs and public interfaces that clearly define and restrict how/what the mods/extensions can access.
15-
- If any of these technologies are referenced, you can proactively read their docs at these locations: https://primevue.org/theming, https://primevue.org/forms/, https://www.electronjs.org/docs/latest/api/browser-window, https://vitest.dev/guide/browser/, https://atlassian.design/components/pragmatic-drag-and-drop/core-package/drop-targets/, https://playwright.dev/docs/api/class-test, https://playwright.dev/docs/api/class-electron, https://www.algolia.com/doc/api-reference/rest-api/, https://pyav.org/docs/develop/cookbook/basics.html
16-
- IMPORTANT: Never add Co-Authored by Claude or any reference to Claude or Claude Code in commit messages, PR descriptions, titles, or any documentation whatsoever
17-
- The npm script to type check is called "typecheck" NOT "type check"
18-
- Use the Vue 3 Composition API instead of the Options API when writing Vue components. An exception is when overriding or extending a PrimeVue component for compatibility, you may use the Options API.
19-
- when we are solving an issue we know the link/number for, we should add "Fixes #n" (where n is the issue number) to the PR description.
20-
- Never write css if you can accomplish the same thing with tailwind utility classes
21-
- Utilize ref and reactive for reactive state
22-
- Implement computed properties with computed()
23-
- Use watch and watchEffect for side effects
24-
- Implement lifecycle hooks with onMounted, onUpdated, etc.
25-
- Utilize provide/inject for dependency injection
26-
- Use vue 3.5 style of default prop declaration. Do not define a `props` variable; instead, destructure props. Since vue 3.5, destructuring props does not strip them of reactivity.
27-
- Use Tailwind CSS for styling
28-
- Leverage VueUse functions for performance-enhancing styles
29-
- Use lodash for utility functions
30-
- Implement proper props and emits definitions
31-
- Utilize Vue 3's Teleport component when needed
32-
- Use Suspense for async components
33-
- Implement proper error handling
34-
- Follow Vue 3 style guide and naming conventions
35-
- IMPORTANT: Use vue-i18n for ALL user-facing strings - no hard-coded text in services/utilities. Place new translation entries in src/locales/en/main.json
36-
- Avoid using `@ts-expect-error` to work around type issues. We needed to employ it to migrate to TypeScript, but it should not be viewed as an accepted practice or standard.
37-
- DO NOT use deprecated PrimeVue components. Use these replacements instead:
38-
* `Dropdown` → Use `Select` (import from 'primevue/select')
39-
* `OverlayPanel` → Use `Popover` (import from 'primevue/popover')
40-
* `Calendar` → Use `DatePicker` (import from 'primevue/datepicker')
41-
* `InputSwitch` → Use `ToggleSwitch` (import from 'primevue/toggleswitch')
42-
* `Sidebar` → Use `Drawer` (import from 'primevue/drawer')
43-
* `Chips` → Use `AutoComplete` with multiple enabled and typeahead disabled
44-
* `TabMenu` → Use `Tabs` without panels
45-
* `Steps` → Use `Stepper` without panels
46-
* `InlineMessage` → Use `Message` component
47-
* Use `api.apiURL()` for all backend API calls and routes
48-
- Actual API endpoints like /prompt, /queue, /view, etc.
49-
- Image previews: `api.apiURL('/view?...')`
50-
- Any backend-generated content or dynamic routes
51-
* Use `api.fileURL()` for static files served from the public folder:
52-
- Templates: `api.fileURL('/templates/default.json')`
53-
- Extensions: `api.fileURL(extensionPath)` for loading JS modules
54-
- Any static assets that exist in the public directory
55-
- When implementing code that outputs raw HTML (e.g., using v-html directive), always ensure dynamic content has been properly sanitized with DOMPurify or validated through trusted sources. Prefer Vue templates over v-html when possible.
56-
- For any async operations (API calls, timers, etc), implement cleanup/cancellation in component unmount to prevent memory leaks
57-
- Extract complex template conditionals into separate components or computed properties
58-
- Error messages should be actionable and user-friendly (e.g., "Failed to load data. Please refresh the page." instead of "Unknown error")
1+
# ComfyUI Frontend Project Guidelines
2+
3+
## Quick Commands
4+
5+
- `npm run`: See all available commands
6+
- `npm run typecheck`: Type checking
7+
- `npm run lint`: Linting
8+
- `npm run format`: Prettier formatting
9+
10+
## Development Workflow
11+
12+
1. Make code changes
13+
2. Run tests (see subdirectory CLAUDE.md files)
14+
3. Run typecheck, lint, format
15+
4. Check README updates
16+
5. Consider docs.comfy.org updates
17+
18+
## Git Conventions
19+
20+
- Use [prefix] format: [feat], [bugfix], [docs]
21+
- Add "Fixes #n" to PR descriptions
22+
- Never mention Claude/AI in commits
23+
24+
## External Resources
25+
26+
- PrimeVue docs: <https://primevue.org>
27+
- ComfyUI docs: <https://docs.comfy.org>
28+
- Electron: <https://www.electronjs.org/docs/latest/>
29+
- Wiki: <https://deepwiki.com/Comfy-Org/ComfyUI_frontend/1-overview>
30+
31+
## Project Philosophy
32+
33+
- Clean, stable public APIs
34+
- Domain-driven design
35+
- Thousands of users and extensions
36+
- Prioritize clean interfaces that restrict extension access
37+
38+
## Repository Navigation
39+
40+
- Check README files in key folders (tests-ui, browser_tests, composables, etc.)
41+
- Prefer running single tests for performance
42+
- Use --help for unfamiliar CLI tools
43+
44+
## GitHub Integration
45+
46+
When referencing Comfy-Org repos:
47+
48+
1. Check for local copy
49+
2. Use GitHub API for branches/PRs/metadata
50+
3. Curl GitHub website if needed

browser_tests/CLAUDE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# E2E Testing Guidelines
2+
3+
## Browser Tests
4+
- Test user workflows
5+
- Use Playwright fixtures
6+
- Follow naming conventions
7+
8+
## Best Practices
9+
- Check assets/ for test data
10+
- Prefer specific selectors
11+
- Test across viewports
12+
13+
## Testing Process
14+
After code changes:
15+
1. Create browser tests as appropriate
16+
2. Run tests until passing
17+
3. Then run typecheck, lint, format

src/CLAUDE.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Source Code Guidelines
2+
3+
## Service Layer
4+
5+
### API Calls
6+
7+
- Use `api.apiURL()` for backend endpoints
8+
- Use `api.fileURL()` for static files
9+
- Examples:
10+
- Backend: `api.apiURL('/prompt')`
11+
- Static: `api.fileURL('/templates/default.json')`
12+
13+
### Error Handling
14+
15+
- User-friendly and actionable messages
16+
- Proper error propagation
17+
18+
### Security
19+
20+
- Sanitize HTML with DOMPurify
21+
- Validate trusted sources
22+
- Never log secrets
23+
24+
## State Management (Stores)
25+
26+
### Store Design
27+
28+
- Follow domain-driven design
29+
- Clear public interfaces
30+
- Restrict extension access
31+
32+
### Best Practices
33+
34+
- Use TypeScript for type safety
35+
- Implement proper error handling
36+
- Clean up subscriptions
37+
- Avoid @ts-expect-error
38+
39+
## General Guidelines
40+
41+
- Use lodash for utility functions
42+
- Implement proper TypeScript types
43+
- Follow Vue 3 composition API style guide
44+
- Use vue-i18n for ALL user-facing strings in `src/locales/en/main.json`

src/components/CLAUDE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Component Guidelines
2+
3+
## Vue 3 Composition API
4+
5+
- Use setup() function
6+
- Destructure props (Vue 3.5 style)
7+
- Use ref/reactive for state
8+
- Implement computed() for derived state
9+
- Use provide/inject for dependency injection
10+
11+
## Component Communication
12+
13+
- Prefer `emit/@event-name` for state changes
14+
- Use `defineExpose` only for imperative operations (`form.validate()`, `modal.open()`)
15+
- Events promote loose coupling
16+
17+
## UI Framework
18+
19+
- Deprecated PrimeVue component replacements:
20+
- Dropdown → Select
21+
- OverlayPanel → Popover
22+
- Calendar → DatePicker
23+
- InputSwitch → ToggleSwitch
24+
- Sidebar → Drawer
25+
- Chips → AutoComplete with multiple enabled
26+
- TabMenu → Tabs without panels
27+
- Steps → Stepper without panels
28+
- InlineMessage → Message
29+
30+
## Styling
31+
32+
- Use Tailwind CSS only (no custom CSS)
33+
- Dark theme: use "dark-theme:" prefix
34+
- For common operations, try to use existing VueUse composables that automatically handle effect scope
35+
- Example: Use `useElementHover` instead of manually managing mouseover/mouseout event listeners
36+
- Example: Use `useIntersectionObserver` for visibility detection instead of custom scroll handlers
37+
38+
## Best Practices
39+
40+
- Extract complex conditionals to computed
41+
- Implement cleanup for async operations
42+
- Use vue-i18n for ALL UI strings
43+
- Use lifecycle hooks: onMounted, onUpdated
44+
- Use Teleport/Suspense when needed
45+
- Proper props and emits definitions

tests-ui/CLAUDE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Unit Testing Guidelines
2+
3+
## Testing Approach
4+
5+
- Write tests for new features
6+
- Run single tests for performance
7+
- Follow existing test patterns
8+
9+
## Test Structure
10+
11+
- Check @tests-ui/README.md for guidelines
12+
- Use existing test utilities
13+
- Mock external dependencies

0 commit comments

Comments
 (0)