@plaited/development-skills 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.claude/commands/lsp-analyze.md +66 -0
  2. package/.claude/commands/lsp-find.md +51 -0
  3. package/.claude/commands/lsp-hover.md +48 -0
  4. package/.claude/commands/lsp-refs.md +55 -0
  5. package/.claude/commands/scaffold-rules.md +221 -0
  6. package/.claude/commands/validate-skill.md +29 -0
  7. package/.claude/rules/accuracy.md +64 -0
  8. package/.claude/rules/bun-apis.md +80 -0
  9. package/.claude/rules/code-review.md +276 -0
  10. package/.claude/rules/git-workflow.md +66 -0
  11. package/.claude/rules/github.md +154 -0
  12. package/.claude/rules/testing.md +125 -0
  13. package/.claude/settings.local.json +47 -0
  14. package/.claude/skills/code-documentation/SKILL.md +47 -0
  15. package/.claude/skills/code-documentation/references/internal-templates.md +113 -0
  16. package/.claude/skills/code-documentation/references/maintenance.md +164 -0
  17. package/.claude/skills/code-documentation/references/public-api-templates.md +100 -0
  18. package/.claude/skills/code-documentation/references/type-documentation.md +116 -0
  19. package/.claude/skills/code-documentation/references/workflow.md +60 -0
  20. package/.claude/skills/scaffold-rules/SKILL.md +97 -0
  21. package/.claude/skills/typescript-lsp/SKILL.md +239 -0
  22. package/.claude/skills/validate-skill/SKILL.md +105 -0
  23. package/LICENSE +15 -0
  24. package/README.md +149 -0
  25. package/bin/cli.ts +109 -0
  26. package/package.json +57 -0
  27. package/src/lsp-analyze.ts +223 -0
  28. package/src/lsp-client.ts +400 -0
  29. package/src/lsp-find.ts +100 -0
  30. package/src/lsp-hover.ts +87 -0
  31. package/src/lsp-references.ts +83 -0
  32. package/src/lsp-symbols.ts +73 -0
  33. package/src/resolve-file-path.ts +28 -0
  34. package/src/scaffold-rules.ts +435 -0
  35. package/src/tests/fixtures/sample.ts +27 -0
  36. package/src/tests/lsp-client.spec.ts +180 -0
  37. package/src/tests/resolve-file-path.spec.ts +33 -0
  38. package/src/tests/scaffold-rules.spec.ts +286 -0
  39. package/src/tests/validate-skill.spec.ts +231 -0
  40. package/src/validate-skill.ts +492 -0
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: code-documentation
3
+ description: TSDoc standards for TypeScript/JavaScript code. Automatically invoked when writing, reviewing, or editing any TSDoc comments, code documentation, or API documentation. (project)
4
+ license: ISC
5
+ compatibility: Requires bun
6
+ ---
7
+
8
+ # Code Documentation Skill
9
+
10
+ ## Purpose
11
+
12
+ This skill provides TSDoc format templates, type documentation guidelines, and maintenance workflows. Use this when:
13
+ - Writing or editing TSDoc comments for any function, type, or module
14
+ - Reviewing documentation quality
15
+ - Creating comprehensive API documentation
16
+ - Documenting complex type structures
17
+ - Cleaning up non-compliant comments (performance notes, timestamps, inline explanations)
18
+ - Synchronizing out-of-sync TSDoc with code changes
19
+ - Removing orphaned documentation for deleted code
20
+
21
+ **Key Standard**: No `@example` sections - tests and stories serve as living examples.
22
+
23
+ ## Quick Reference
24
+
25
+ - **Creating TSDoc**: See [workflow.md](references/workflow.md) for the generation workflow
26
+ - **Maintaining TSDoc**: See [maintenance.md](references/maintenance.md) for cleanup and sync guidelines
27
+
28
+ This skill contains detailed templates for:
29
+ - Public API Functions
30
+ - Internal Module Documentation
31
+ - Public and Internal Types
32
+ - Helper Functions
33
+ - Behavioral Programming Functions
34
+ - Special Annotations (Security, Performance, Deprecated)
35
+ - Type Documentation (Complex Objects, Unions, Functions, Utilities, Branded Types, etc.)
36
+
37
+ ## Navigation
38
+
39
+ - [workflow.md](references/workflow.md) - TSDoc generation workflow (4 phases)
40
+ - [maintenance.md](references/maintenance.md) - Comment policy, sync tasks, orphaned doc handling
41
+ - [public-api-templates.md](references/public-api-templates.md) - Templates for public-facing APIs
42
+ - [internal-templates.md](references/internal-templates.md) - Templates for internal code and modules
43
+ - [type-documentation.md](references/type-documentation.md) - Comprehensive type documentation templates
44
+
45
+ ## Related Skills
46
+
47
+ - **typescript-lsp**: Use for type verification and discovery during documentation workflow. Essential for Phase 1 (type analysis) and Phase 2 (usage discovery) of the TSDoc generation process. Run `lsp-hover` to verify signatures, `lsp-references` to find usages, and `lsp-symbols` to understand file structure.
@@ -0,0 +1,113 @@
1
+ # Internal Templates
2
+
3
+ ## Internal Module Documentation
4
+
5
+ ```typescript
6
+ /**
7
+ * @internal
8
+ * @module module-name
9
+ *
10
+ * Purpose: Why this module exists in the codebase
11
+ * Architecture: How it fits into the overall system design
12
+ * Dependencies: What this module depends on (be specific)
13
+ * Consumers: What parts of the system use this module
14
+ *
15
+ * Maintainer Notes:
16
+ * - Key implementation details and design decisions
17
+ * - Important invariants that must be maintained
18
+ * - Tricky aspects of the implementation
19
+ * - Performance-critical sections with complexity analysis
20
+ *
21
+ * Common modification scenarios:
22
+ * - When you might need to modify this module
23
+ * - How to extend functionality safely
24
+ * - What to watch out for when making changes
25
+ *
26
+ * Performance considerations:
27
+ * - Optimization strategies used
28
+ * - Memory management concerns
29
+ * - Computational complexity (Big-O notation)
30
+ *
31
+ * Known limitations:
32
+ * - Current constraints or technical debt
33
+ * - Planned improvements
34
+ * - Workarounds for known issues
35
+ */
36
+ ```
37
+
38
+ ## Internal Types
39
+
40
+ ```typescript
41
+ /**
42
+ * @internal
43
+ * What this type represents internally and why it exists.
44
+ * How it's used in the implementation.
45
+ *
46
+ * @property propName - Internal property purpose
47
+ *
48
+ * @remarks
49
+ * - Implementation-specific constraints
50
+ * - Why this structure was chosen
51
+ */
52
+ type InternalType = {
53
+ // Implementation-specific properties
54
+ }
55
+ ```
56
+
57
+ ## Internal Helper Functions
58
+
59
+ ```typescript
60
+ /**
61
+ * @internal
62
+ * Brief description of what this internal function does.
63
+ * Why it exists and how it's used within the module.
64
+ *
65
+ * @param paramName - Parameter purpose
66
+ * @returns Return value meaning
67
+ *
68
+ * @remarks
69
+ * - Algorithm details (e.g., "Fisher-Yates shuffle")
70
+ * - Complexity: O(n) where n is...
71
+ * - Why this approach was chosen
72
+ */
73
+ const internalHelper = () => { ... }
74
+ ```
75
+
76
+ ## Security-Sensitive Code
77
+
78
+ ```typescript
79
+ /**
80
+ * @internal
81
+ * SECURITY: This function handles [sensitive operation].
82
+ *
83
+ * Security considerations:
84
+ * - Input sanitization approach
85
+ * - XSS/injection prevention measures
86
+ * - Authentication/authorization requirements
87
+ */
88
+ ```
89
+
90
+ ## Performance-Critical Code
91
+
92
+ ```typescript
93
+ /**
94
+ * @internal
95
+ * PERFORMANCE: Hot path - called [frequency/context].
96
+ *
97
+ * Performance notes:
98
+ * - Optimization strategy (e.g., "minimal allocations")
99
+ * - Caching approach (e.g., "WeakMap cache")
100
+ * - Complexity: O(1) lookup after initial computation
101
+ */
102
+ ```
103
+
104
+ ## Required Elements for Internal Modules
105
+
106
+ ### All Internal Modules Must Include
107
+
108
+ - Purpose and architecture context
109
+ - Dependencies and consumers
110
+ - Maintainer notes
111
+ - Modification scenarios
112
+ - Performance considerations
113
+ - Known limitations
@@ -0,0 +1,164 @@
1
+ # Documentation Maintenance
2
+
3
+ Guidelines for maintaining documentation hygiene: synchronizing TSDoc with code, removing non-compliant comments, and handling orphaned documentation.
4
+
5
+ ## Comment Policy
6
+
7
+ ### Allowed Comments
8
+
9
+ 1. **TSDoc comment blocks** following project standards
10
+ 2. **TODO comments**: `// TODO: description of future work`
11
+ 3. **FIXME comments**: `// FIXME: description of issue to fix`
12
+
13
+ ### Remove These Comments
14
+
15
+ 1. **Performance notes**: `// Performance: this is O(n)`
16
+ 2. **Update timestamps**: `// Updated 2024-12-15 to fix bug`
17
+ 3. **Historical notes**: `// This used to use Array.filter`
18
+ 4. **Implementation notes**: `// Hack to work around limitation`
19
+ 5. **Inline explanations**: `// Loop through items and process`
20
+ 6. **Rationale comments**: `// We do this because...`
21
+
22
+ ### Convert to TSDoc
23
+
24
+ Valuable information from inline comments should be moved to TSDoc `@remarks`:
25
+
26
+ ```typescript
27
+ // This function is O(n) because it iterates all items
28
+ // We use a for-loop instead of .filter for better performance
29
+
30
+ // ↓ CONVERT TO ↓
31
+
32
+ /**
33
+ * @internal
34
+ * Processes items with linear complexity.
35
+ *
36
+ * @remarks
37
+ * - Complexity: O(n) where n is number of items
38
+ * - Uses for-loop instead of .filter for performance
39
+ */
40
+ ```
41
+
42
+ ## Synchronization Tasks
43
+
44
+ ### Parameter Sync
45
+
46
+ ```typescript
47
+ // OUT OF SYNC:
48
+ /**
49
+ * @param name - User name
50
+ * @param age - User age
51
+ */
52
+ function createUser({ username, age }: UserData) { ... }
53
+
54
+ // FIXED:
55
+ /**
56
+ * @param options - User data
57
+ * @param options.username - User's username
58
+ * @param options.age - User's age
59
+ */
60
+ function createUser({ username, age }: UserData) { ... }
61
+ ```
62
+
63
+ ### Return Type Sync
64
+
65
+ ```typescript
66
+ // OUT OF SYNC:
67
+ /**
68
+ * @returns User object
69
+ */
70
+ function getUser(): Promise<User> { ... }
71
+
72
+ // FIXED:
73
+ /**
74
+ * @returns Promise resolving to User object
75
+ */
76
+ function getUser(): Promise<User> { ... }
77
+ ```
78
+
79
+ ### Generic Parameter Sync
80
+
81
+ ```typescript
82
+ // OUT OF SYNC:
83
+ /**
84
+ * @template T - Generic type
85
+ */
86
+ function process<T extends BaseType>() { ... }
87
+
88
+ // FIXED:
89
+ /**
90
+ * @template T - Type extending BaseType for processing
91
+ */
92
+ function process<T extends BaseType>() { ... }
93
+ ```
94
+
95
+ ## Orphaned Documentation
96
+
97
+ When TSDoc comments reference code that no longer exists:
98
+
99
+ 1. **Deleted functions/types**: Remove the entire TSDoc block
100
+ 2. **Moved code**: Report the TSDoc location and ask where code moved to
101
+ 3. **Invalid @see references**: Remove `@see` tags referencing deleted code
102
+ 4. **Uncertain**: If confidence < 95%, report for manual review
103
+
104
+ **Examples:**
105
+
106
+ ```typescript
107
+ // ORPHANED: Function deleted, TSDoc remains
108
+ /**
109
+ * @deprecated Use newFunction instead
110
+ * @param x - Input value
111
+ */
112
+ // <--- Nothing here, function was deleted
113
+
114
+ // ACTION: Remove entire TSDoc block
115
+
116
+ // INVALID REFERENCE: @see points to deleted code
117
+ /**
118
+ * Processes user data.
119
+ * @see {@link validateInput} - Function no longer exists
120
+ * @see {@link sanitizeData} - Still exists
121
+ */
122
+ function processUser(data: UserData) { ... }
123
+
124
+ // ACTION: Remove @see for validateInput, keep sanitizeData reference
125
+ ```
126
+
127
+ ## Maintenance Process
128
+
129
+ When cleaning documentation in a file or directory:
130
+
131
+ 1. **Scan for comments**
132
+ - Identify all comment types (TSDoc, inline, TODO/FIXME)
133
+ - Classify each comment (KEEP, REMOVE, CONVERT)
134
+
135
+ 2. **Remove non-compliant**
136
+ - Delete performance notes, timestamps, historical notes
137
+ - Remove inline explanations and implementation details
138
+
139
+ 3. **Remove orphaned TSDoc**
140
+ - Delete TSDoc blocks for deleted functions/types
141
+ - Remove invalid @see references to deleted code
142
+ - Report uncertain cases for manual review
143
+
144
+ 4. **Update TSDoc blocks**
145
+ - Sync parameter names and types
146
+ - Update return type descriptions
147
+ - Verify generic parameter documentation
148
+
149
+ 5. **Convert valuable inline to TSDoc**
150
+ - Move complexity notes to @remarks
151
+ - Move important context to @remarks
152
+
153
+ 6. **Validate completeness**
154
+ - All public exports have TSDoc
155
+ - All public APIs have @param/@returns
156
+ - Types have @property for all properties
157
+ - @internal marker on non-public code
158
+
159
+ ## Safety Guidelines
160
+
161
+ 1. **Start small** - Test on one file before batch processing
162
+ 2. **Review changes** - Examine diffs before committing
163
+ 3. **Preserve TODOs** - Never remove TODO/FIXME comments
164
+ 4. **No code changes** - Only modify comments and TSDoc
@@ -0,0 +1,100 @@
1
+ # Public API Templates
2
+
3
+ ## Public API Functions
4
+
5
+ ```typescript
6
+ /**
7
+ * Concise one-line description of functionality.
8
+ * Extended explanation providing context, use cases, and when to use this.
9
+ *
10
+ * @template T - Description of generic type parameter and constraints
11
+ * @param paramName - Parameter purpose, constraints, and expected values
12
+ * @returns Description of return value, what it represents, and guarantees
13
+ *
14
+ * @remarks
15
+ * - Key behavioral characteristics
16
+ * - Important execution details
17
+ * - Performance considerations (with Big-O if relevant)
18
+ * - Common pitfalls or gotchas
19
+ * - Threading/async behavior if applicable
20
+ *
21
+ * @throws {ErrorType} When and why this error occurs
22
+ *
23
+ * @see {@link RelatedFunction} for related functionality
24
+ * @see {@link RelatedType} for type details
25
+ * @since 1.0.0
26
+ */
27
+ ```
28
+
29
+ ## Public Types
30
+
31
+ ```typescript
32
+ /**
33
+ * Description of what this type represents in the API.
34
+ * When and why to use this type.
35
+ *
36
+ * @template T - Generic parameter description and constraints
37
+ * @property propName - What this property controls or represents
38
+ * @property optionalProp - Purpose and when to include this property
39
+ *
40
+ * @remarks
41
+ * - Type constraints and relationships
42
+ * - Common usage patterns
43
+ * - Integration with other types
44
+ *
45
+ * @see {@link RelatedType} for related type definitions
46
+ * @since 1.0.0
47
+ */
48
+ export type TypeName<T> = {
49
+ propName: string;
50
+ optionalProp?: number;
51
+ }
52
+ ```
53
+
54
+ ## Behavioral Programming Functions
55
+
56
+ **CRITICAL:** For behavioral programming APIs (bSync, bThread, behavioral, useBehavioral), always use factory functions in documentation - never raw `yield` statements.
57
+
58
+ ```typescript
59
+ /**
60
+ * Creates a behavioral thread for coordinating async operations.
61
+ * Explain the coordination pattern and synchronization approach.
62
+ *
63
+ * @param config - Thread configuration options
64
+ * @returns Configured behavioral thread
65
+ *
66
+ * @remarks
67
+ * - Thread execution model (sequential through sync points)
68
+ * - Event coordination semantics
69
+ * - Blocking precedence rules
70
+ * - Repetition behavior
71
+ * - Integration with trigger/feedback mechanisms
72
+ *
73
+ * @see {@link bSync} for creating sync points
74
+ * @see {@link behavioral} for program setup
75
+ * @see {@link Idioms} for synchronization options
76
+ * @since 1.0.0
77
+ */
78
+ ```
79
+
80
+ ## Deprecated Code
81
+
82
+ ```typescript
83
+ /**
84
+ * @deprecated Use {@link NewFunction} instead. Will be removed in v8.0.
85
+ *
86
+ * Migration path: [Brief guidance on how to migrate]
87
+ *
88
+ * @see {@link NewFunction}
89
+ */
90
+ ```
91
+
92
+ ## Required Elements by Context
93
+
94
+ ### All Public APIs Must Include
95
+
96
+ - One-line description + extended context
97
+ - `@param` for all parameters
98
+ - `@returns` for return values
99
+ - `@remarks` section with behavioral notes
100
+ - `@see` tags to related APIs
@@ -0,0 +1,116 @@
1
+ # Type Documentation Guidelines
2
+
3
+ **IMPORTANT**: This project prefers `type` over `interface` in both code and TSDoc comments. Always use `type` declarations unless there's a specific need for interface features like declaration merging.
4
+
5
+ ## Type Analysis Process
6
+
7
+ When documenting types, use the **typescript-lsp** skill for accurate type discovery:
8
+
9
+ 1. **Analyze type structure** using typescript-lsp:
10
+ - Run `lsp-symbols` to list all type definitions in a file
11
+ - Run `lsp-hover` on the type to get the full signature
12
+ - Identify all properties and their types
13
+ - Find optional vs required properties
14
+ - Trace generic type parameters
15
+ - Identify union and intersection types
16
+
17
+ 2. **Find type relationships** using typescript-lsp:
18
+ - Run `lsp-references` to find all usages of the type
19
+ - Run `lsp-find` to search for related types by name pattern
20
+ - What types does this extend or implement?
21
+ - What types reference this type?
22
+ - What utility types are derived from this?
23
+ - Are there branded/nominal types involved?
24
+
25
+ 3. **Discover usage patterns:**
26
+ - How is this type constructed?
27
+ - What validation occurs?
28
+ - Are there Zod schemas associated?
29
+ - What are the common configurations?
30
+
31
+ 4. **Document from analysis:**
32
+ - Property purposes from usage context
33
+ - Constraints from validation/tests
34
+ - Relationships from type dependencies
35
+ - Patterns from real usage in framework code, stories, and test files
36
+
37
+ ## Type Documentation Requirements
38
+
39
+ All TypeScript type patterns (complex objects, unions, functions, mapped types, recursive types, etc.) should follow standard TSDoc format with these conventions:
40
+
41
+ ### Core Requirements
42
+
43
+ - **Always use `type` over `interface`** (unless extending a single interface for branding)
44
+ - **Include `@property`** for all properties with: purpose, constraints, and when to use
45
+ - **Document `@template`** parameters with: constraint, purpose, and where it flows
46
+ - **Add `@remarks`** for: validation rules, constraints, common patterns, performance notes
47
+ - **Cross-reference** related types, factory functions, type guards, and Zod schemas using `@see`
48
+ - **Mark internal types** with `@internal` for non-public APIs
49
+
50
+ ### Zod Schema Integration
51
+
52
+ When types have associated Zod schemas, document validation in `@remarks`:
53
+
54
+ ```typescript
55
+ /**
56
+ * @remarks
57
+ * Validation:
58
+ * - Schema: {@link ConfigSchema}
59
+ * - Required fields: [list]
60
+ * - Optional fields: [list]
61
+ * - Default values: [from schema defaults]
62
+ */
63
+ ```
64
+
65
+ ## Property Documentation
66
+
67
+ **Required for each property:**
68
+ ```typescript
69
+ @property propName - [Purpose] [Constraints] [When to use]
70
+ ```
71
+
72
+ **Discovery sources:**
73
+ 1. From usage: How the property is accessed/used
74
+ 2. From tests: What values are tested, edge cases
75
+ 3. From validation: Zod schemas, type guards
76
+ 4. From defaults: Default values in code
77
+
78
+ ## Generic Type Parameters
79
+
80
+ **Always document with:**
81
+ ```typescript
82
+ @template T - [Constraint] [Purpose] [Where it flows]
83
+ ```
84
+
85
+ **Discovery process:**
86
+ 1. Find where T is used in type body
87
+ 2. Identify constraints (extends clauses)
88
+ 3. Trace how T flows through type
89
+ 4. Note variance (in/out if relevant)
90
+
91
+ ## Cross-Referencing Types
92
+
93
+ **Always link:**
94
+ - Related types (subtypes, supertypes)
95
+ - Factory functions that create instances
96
+ - Type guards that check instances
97
+ - Validation schemas
98
+ - Consumer functions/classes
99
+
100
+ **Format:**
101
+ ```typescript
102
+ /**
103
+ * @see {@link ParentType} for base type definition
104
+ * @see {@link createInstance} for creating valid instances
105
+ * @see {@link isInstanceOf} for runtime type checking
106
+ * @see {@link InstanceSchema} for validation schema
107
+ * @see {@link Consumer} for primary consumer
108
+ */
109
+ ```
110
+
111
+ ## Required Elements for All Types
112
+
113
+ - Description of what it represents
114
+ - `@property` documentation for all properties
115
+ - `@template` for generic parameters
116
+ - `@remarks` for constraints and patterns
@@ -0,0 +1,60 @@
1
+ # TSDoc Generation Workflow
2
+
3
+ When creating or updating TSDoc comments, follow this systematic exploration process.
4
+
5
+ **Prerequisite**: Use the **typescript-lsp** skill for type verification throughout this workflow. The LSP tools provide accurate type information directly from the TypeScript compiler.
6
+
7
+ ## Phase 1: Type & Interface Analysis
8
+
9
+ 1. **Identify the target** (function, type, class, or module)
10
+ 2. **Analyze type signatures** using typescript-lsp:
11
+ - Run `lsp-symbols` to get file structure overview
12
+ - Run `lsp-hover` on the target to get exact type signatures
13
+ - Parameter types and constraints
14
+ - Return types
15
+ - Generic type parameters
16
+ - Type relationships and dependencies
17
+ 3. **Trace type dependencies:**
18
+ - Run `lsp-references` to find what depends on this type
19
+ - What types does this depend on?
20
+ - What types depend on this?
21
+ - Are there related utility types?
22
+
23
+ ## Phase 2: Usage Reference Discovery
24
+
25
+ 1. **Find all usage locations** using typescript-lsp:
26
+ - Run `lsp-references` on the target symbol
27
+ - Run `lsp-find` to search for related patterns
28
+ - Identify calling patterns
29
+ - Note common usage contexts
30
+ 2. **Analyze integration points:**
31
+ - How is this used in the architecture?
32
+ - What modules consume this?
33
+ - What are the typical call chains?
34
+
35
+ ## Phase 3: Test & Story Analysis
36
+
37
+ 1. **Review test files** (`.test.ts`, `.spec.ts`):
38
+ - What behaviors are tested?
39
+ - What edge cases are covered?
40
+ - What scenarios are validated?
41
+ 2. **Review story files** (`.stories.tsx`):
42
+ - How is this used in practice?
43
+ - What real-world scenarios exist?
44
+ - What configurations are demonstrated?
45
+
46
+ ## Phase 4: Documentation Generation
47
+
48
+ 1. **Synthesize findings** from phases 1-3
49
+ 2. **Apply appropriate TSDoc template** from this skill
50
+ 3. **Cross-reference related APIs** using `@see` tags
51
+ 4. **Document discovered constraints** in `@remarks`
52
+ 5. **Note performance characteristics** if evident from usage
53
+ 6. **Identify limitations** found in tests or usage patterns
54
+
55
+ ## Templates
56
+
57
+ After completing the workflow phases, apply the appropriate template:
58
+ - @public-api-templates.md - Public-facing APIs
59
+ - @internal-templates.md - Internal code and modules
60
+ - @type-documentation.md - Type documentation
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: scaffold-rules
3
+ description: Scaffold development rules for AI coding agents. Auto-invoked when user asks about setting up rules, coding conventions, or configuring their AI agent environment.
4
+ license: ISC
5
+ compatibility: Requires bun
6
+ allowed-tools: Glob, Read, Write, Edit, AskUserQuestion
7
+ ---
8
+
9
+ # Scaffold Rules
10
+
11
+ Scaffold and merge development rules adapted to different AI coding agent environments.
12
+
13
+ ## Purpose
14
+
15
+ Use this skill when the user wants to:
16
+ - Set up development rules or coding conventions
17
+ - Configure their AI coding agent (Claude Code, Cursor, Copilot, etc.)
18
+ - Add or update project guidelines
19
+ - Standardize conventions across a team
20
+
21
+ ## Supported Agents
22
+
23
+ | Agent | Config Location | Format |
24
+ |-------|-----------------|--------|
25
+ | Claude Code | `.claude/rules/*.md` | Separate markdown files |
26
+ | Cursor | `.cursorrules` or `.cursor/rules/*.md` | Single or multi-file |
27
+ | GitHub Copilot | `.github/copilot-instructions.md` | Single file |
28
+ | Windsurf | `.windsurfrules` | Single file |
29
+ | Cline/Roo | `.clinerules` | Single file |
30
+ | Aider | `.aider.conf.yml` | YAML config |
31
+
32
+ ## Rule Categories
33
+
34
+ ### Bun APIs
35
+ Prefer Bun's native APIs over Node.js equivalents:
36
+ - `Bun.file()` over `fs` APIs
37
+ - `Bun.$` for shell commands
38
+ - `Bun.write()` for file writes
39
+ - `import.meta.dir` for current directory
40
+
41
+ ### Git Workflow
42
+ Commit conventions and version control:
43
+ - Conventional commit prefixes: `feat:`, `fix:`, `refactor:`, `docs:`, `chore:`, `test:`
44
+ - Multi-line commit message formatting
45
+ - Agent-specific sandbox workarounds
46
+
47
+ ### GitHub CLI
48
+ Prefer `gh` CLI for GitHub operations:
49
+ - PR review and creation patterns
50
+ - Issue management
51
+ - JSON output field references
52
+ - Authentication benefits over WebFetch
53
+
54
+ ### TypeScript Conventions
55
+ Code style standards:
56
+ - Prefer `type` over `interface`
57
+ - No `any` types (use `unknown` with type guards)
58
+ - Arrow functions preferred
59
+ - Object parameter pattern for 2+ parameters
60
+ - PascalCase for types, `PascalCaseSchema` suffix for Zod schemas
61
+
62
+ ### Testing Patterns
63
+ Bun test runner conventions:
64
+ - Use `test()` instead of `it()`
65
+ - `*.spec.ts` file naming
66
+ - No conditionals around assertions
67
+ - Assert existence before checking values
68
+
69
+ ## Merge Behavior
70
+
71
+ **Always scans existing rules first.** When existing rules are found:
72
+
73
+ 1. **Analyze overlap** - Identify sections covering same topics
74
+ 2. **Propose merge** - Show what would be added/changed
75
+ 3. **User approval** - Ask before modifying:
76
+ - Keep existing (skip new content)
77
+ - Merge (add missing sections)
78
+ - Replace entirely
79
+
80
+ This ensures the command never overwrites user customizations without consent.
81
+
82
+ ## Agent Adaptations
83
+
84
+ Content is adapted based on agent capabilities:
85
+
86
+ - **Sandbox awareness**: Include/exclude sandbox workarounds based on agent
87
+ - **Tool references**: Adjust tool names (e.g., "Bash tool" → "terminal")
88
+ - **Format**: Single file vs multi-file based on agent convention
89
+ - **Length**: Condense for agents with size limits
90
+
91
+ ## Usage
92
+
93
+ Run the `/scaffold-rules` command to interactively scaffold rules, or invoke when user asks about:
94
+ - "Set up coding conventions"
95
+ - "Configure my AI agent"
96
+ - "Add development rules"
97
+ - "What rules should I have?"