brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
codemodCodemod (JSSG, ast-grep, workflows) best practices for writing efficient, safe, and maintainable code transformations. This skill should be used when writing, reviewing, or debugging codemods, AST transformations, or automated refactoring tools. Triggers on tasks involving codemod, ast-grep, JSSG, code transformation, or automated migration.
Independent GitHub snapshot · Automated classification · Original documentation governs
Comprehensive best practices guide for Codemod (JSSG, ast-grep, workflows), designed for AI agents and LLMs. Contains 48 rules across 11 categories, prioritized by impact to guide automated refactoring and code generation.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | AST Understanding | CRITICAL | ast- |
| 2 | Pattern Efficiency | CRITICAL | pattern- |
| 3 | Parsing Strategy | CRITICAL | parse- |
| 4 | Node Traversal | HIGH | traverse- |
| 5 | Semantic Analysis | HIGH | semantic- |
| 6 | Edit Operations | MEDIUM-HIGH | edit- |
| 7 | Workflow Design | MEDIUM-HIGH | workflow- |
| 8 | Testing Strategy | MEDIUM | test- |
| 9 | State Management | MEDIUM | state- |
| 10 | Security and Capabilities | LOW-MEDIUM | security- |
| 11 | Package Structure | LOW | pkg- |
ast-explore-before-writing - Use AST Explorer before writing patternsast-understand-named-vs-anonymous - Understand named vs anonymous nodesast-use-kind-for-precision - Use kind constraint for precisionast-field-access-for-structure - Use field access for structural queriesast-check-null-before-access - Check null before property accesspattern-use-meta-variables - Use meta variables for flexible matchingpattern-avoid-overly-generic - Avoid overly generic patternspattern-combine-with-rules - Combine patterns with rule operatorspattern-use-constraints - Use constraints for reusable matching logicpattern-use-relational-patterns - Use relational patterns for contextpattern-ensure-idempotency - Ensure patterns are idempotentparse-select-correct-parser - Select the correct parser for file typeparse-handle-embedded-languages - Handle embedded languages with parseAsyncparse-provide-pattern-context - Provide context for ambiguous patternsparse-early-return-non-applicable - Early return for non-applicable filestraverse-use-find-vs-findall - Use find() for single match, findAll() for multipletraverse-single-pass-collection - Collect multiple patterns in single traversaltraverse-use-stopby-for-depth - Use stopBy to control traversal depthtraverse-use-siblings-efficiently - Use sibling navigation efficientlytraverse-cache-repeated-lookups - Cache repeated node lookupssemantic-use-file-scope-first - Use file scope semantic analysis firstsemantic-check-null-results - Handle null semantic analysis resultssemantic-verify-file-ownership - Verify file ownership before cross-file editssemantic-cache-cross-file-results - Cache semantic analysis resultsedit-batch-before-commit - Batch edits before committingedit-preserve-formatting - Preserve surrounding formatting in editsedit-handle-overlapping-ranges - Handle overlapping edit rangesedit-use-flatmap-for-conditional - Use flatMap for conditional editsedit-add-imports-correctly - Add imports at correct positionworkflow-order-nodes-by-dependency - Order nodes by dependencyworkflow-use-matrix-for-parallelism - Use matrix strategy for parallelismworkflow-use-manual-gates - Use manual gates for critical stepsworkflow-validate-before-run - Validate workflows before runningworkflow-use-conditional-steps - Use conditional steps for dynamic workflowstest-use-fixture-pairs - Use input/expected fixture pairstest-cover-edge-cases - Cover edge cases in test fixturestest-use-strictness-levels - Choose appropriate test strictness leveltest-update-fixtures-intentionally - Update test fixtures intentionallytest-run-on-subset-first - Test on file subset before full runstate-use-for-resumability - Use state for resumable migrationsstate-make-transforms-idempotent - Make transforms idempotent for safe rerunsstate-log-progress-for-observability - Log progress for long-running migrationssecurity-minimize-capabilities - Minimize requested capabilitiessecurity-validate-external-inputs - Validate external inputs before usesecurity-review-before-running-third-party - Review third-party codemods before runningpkg-use-semantic-versioning - Use semantic versioning for packagespkg-write-descriptive-metadata - Write descriptive package metadatapkg-organize-by-convention - Organize package by conventionRead individual reference files for detailed explanations and code examples:
For a complete guide with all rules expanded, see AGENTS.md.