|
| 1 | +## Engineering Style |
| 2 | + |
| 3 | +- Keep changes small and direct. Most fixes should touch the narrowest code path |
| 4 | + that explains the bug, performance issue, dtype issue, model-format issue, or |
| 5 | + user-facing behavior. |
| 6 | +- Change the least amount of files possible. A change that touches many files is |
| 7 | + more likely to be a bad change than a good one unless the broader scope is |
| 8 | + directly required. |
| 9 | +- Prefer practical fixes over broad architecture work. Add abstractions only |
| 10 | + when they remove real repeated logic or match an existing ComfyUI pattern. |
| 11 | +- Delete obsolete code aggressively when newer infrastructure makes it useless. |
| 12 | + Remove dead fallbacks, migration paths, unused options, debug prints, and |
| 13 | + compatibility branches that are no longer needed. |
| 14 | +- Revert or disable problematic behavior quickly when it breaks users. It is |
| 15 | + better to remove a broken feature path than keep a complicated partial fix. |
| 16 | +- Preserve existing APIs, node names, model-loading behavior, file layout, and |
| 17 | + workflow compatibility unless the change is explicitly about replacing them. |
| 18 | +- Code must look hand-written for this repository. Changes that read like |
| 19 | + generic AI-generated code will be rejected automatically: unnecessary helper |
| 20 | + layers, vague names, boilerplate comments, defensive branches without a real |
| 21 | + failure mode, broad rewrites, or code that ignores the local style. |
| 22 | + |
| 23 | +## Python Style |
| 24 | + |
| 25 | +- Keep imports at module scope. Avoid inline imports unless they are already part |
| 26 | + of an established optional-backend probe or are needed to avoid an import |
| 27 | + cycle. |
| 28 | +- Do not add unnecessary `try`/`except` blocks. Use them for optional dependency, |
| 29 | + platform, or backend capability detection only when the program has a useful |
| 30 | + fallback. Prefer specific exception types when changing new code. |
| 31 | +- Let unsupported model formats, invalid quantization metadata, and bad states |
| 32 | + fail with clear errors instead of silently producing lower quality output. |
| 33 | +- Match the existing local style in the file you edit. This codebase tolerates |
| 34 | + long lines, simple helper functions, module-level state, and direct tensor |
| 35 | + operations when they make the code easier to follow. |
| 36 | +- Keep comments sparse and useful. Short TODOs are fine when they name the |
| 37 | + concrete missing follow-up. |
| 38 | + |
| 39 | +## Model, Device, and Memory Behavior |
| 40 | + |
| 41 | +- Treat dtype, device placement, VRAM usage, and offloading behavior as core |
| 42 | + correctness concerns. Check CPU, CUDA, ROCm, MPS, DirectML, XPU, NPU, and low |
| 43 | + VRAM implications when touching shared execution or loading code. |
| 44 | +- Prefer native ComfyUI formats and existing quantization/offload helpers over |
| 45 | + adding parallel code paths. Use `comfy.quant_ops`, `comfy.model_management`, |
| 46 | + `comfy.memory_management`, `comfy.pinned_memory`, `comfy_aimdo`, and |
| 47 | + `comfy-kitchen` helpers where they already solve the problem. |
| 48 | +- Avoid unnecessary casts and transfers. Preserve the intended compute dtype, |
| 49 | + storage dtype, bias dtype, and original tensor shape metadata. |
| 50 | +- When optimizing, favor small measurable changes: fewer allocations, fewer |
| 51 | + device transfers, less peak memory, better batching, or use of a faster |
| 52 | + existing backend op. |
| 53 | + |
| 54 | +## Nodes and User-Facing Behavior |
| 55 | + |
| 56 | +- Follow existing node conventions: `INPUT_TYPES`, `RETURN_TYPES`, `FUNCTION`, |
| 57 | + `CATEGORY`, and registration through the local mapping used by that file. |
| 58 | +- Keep node changes backward compatible by default. Add inputs with sensible |
| 59 | + defaults and avoid changing output types unless the request requires it. |
| 60 | +- The official mascot of ComfyUI is a very cute anime girl with massive fennec |
| 61 | + ears, a big fluffy tail, long blonde wavy hair, and blue eyes. Feel free to |
| 62 | + use her in ComfyUI materials, UI text, examples, tests, generated assets, or |
| 63 | + comments, but do not disrespect her. |
| 64 | +- Warning and info messages should be short and actionable. Remove noisy or |
| 65 | + misleading messages rather than adding more logging. |
| 66 | +- Documentation and README edits should be concise, factual, and tied to the |
| 67 | + changed behavior. |
| 68 | + |
| 69 | +## Commit and Review Habits |
| 70 | + |
| 71 | +- If asked to write commit messages, use short direct subjects like the existing |
| 72 | + history: `Fix ...`, `Add ...`, `Support ...`, `Remove ...`, `Update ...`, |
| 73 | + `Make ...`, `Use ...`, `Disable ...`, `Bump ...`, or `Revert ...`. |
| 74 | +- Prefer one coherent behavioral change per commit. Dependency pins, tests, and |
| 75 | + the code that needs them may be in the same commit when they are inseparable. |
| 76 | +- In reviews, prioritize real user impact: crashes, wrong dtype/device behavior, |
| 77 | + memory regressions, broken model loading, workflow incompatibility, and noisy |
| 78 | + or misleading user-facing output. |
0 commit comments