@juancr11/sibu 0.1.0
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.
- package/README.md +198 -0
- package/bin/entrypoints/cli/command.js +1 -0
- package/bin/entrypoints/cli/create-program.js +33 -0
- package/bin/entrypoints/cli/execute-command.js +28 -0
- package/bin/entrypoints/cli/main.js +5 -0
- package/bin/features/doctor-project/command.js +1 -0
- package/bin/features/doctor-project/handler.js +194 -0
- package/bin/features/init-project/command.js +1 -0
- package/bin/features/init-project/handler.js +63 -0
- package/bin/features/list-skills/command.js +1 -0
- package/bin/features/list-skills/handler.js +55 -0
- package/bin/features/stop-managing-file/command.js +1 -0
- package/bin/features/stop-managing-file/handler.js +213 -0
- package/bin/features/sync-project/action-prompt.js +65 -0
- package/bin/features/sync-project/apply-action.js +81 -0
- package/bin/features/sync-project/command.js +1 -0
- package/bin/features/sync-project/handler.js +77 -0
- package/bin/features/sync-project/log-preview.js +62 -0
- package/bin/features/sync-project/preview.js +1 -0
- package/bin/features/use-skill/command.js +1 -0
- package/bin/features/use-skill/handler.js +197 -0
- package/bin/shared/catalog.js +199 -0
- package/bin/shared/hash.js +11 -0
- package/bin/shared/npm-version.js +178 -0
- package/bin/shared/object.js +3 -0
- package/bin/shared/paths.js +41 -0
- package/bin/shared/prompts.js +205 -0
- package/bin/shared/state.js +76 -0
- package/bin/shared/sync-preview.js +166 -0
- package/bin/shared/templates.js +60 -0
- package/bin/shared/types.js +1 -0
- package/bin/shared/workflow-mutation-readiness.js +30 -0
- package/bin/shared/workflow-targets.js +119 -0
- package/bin/sibu.js +6 -0
- package/package.json +68 -0
- package/templates/.codex/config.toml +1 -0
- package/templates/AGENTS.md +60 -0
- package/templates/CLAUDE.md +5 -0
- package/templates/GEMINI.md +5 -0
- package/templates/manifest.json +129 -0
- package/templates/skills/ai-implementation-plan-executor/SKILL.md +138 -0
- package/templates/skills/ai-implementation-planner/SKILL.md +213 -0
- package/templates/skills/architecture/command-pattern/SKILL.md +77 -0
- package/templates/skills/architecture/ddd-hexagonal/SKILL.md +212 -0
- package/templates/skills/clean-code/SKILL.md +109 -0
- package/templates/skills/feature-brief-writer/SKILL.md +219 -0
- package/templates/skills/golang/SKILL.md +82 -0
- package/templates/skills/nextjs/SKILL.md +94 -0
- package/templates/skills/product-vision-writer/SKILL.md +128 -0
- package/templates/skills/react/SKILL.md +75 -0
- package/templates/skills/scrum-master-planner/SKILL.md +191 -0
- package/templates/skills/technical-design-writer/SKILL.md +109 -0
- package/templates/skills/typescript/SKILL.md +111 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: typescript
|
|
3
|
+
description: Use this skill when writing or modifying .ts or .tsx files and you need practical TypeScript guidance.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# typescript
|
|
7
|
+
|
|
8
|
+
Use this skill when writing or modifying `.ts` or `.tsx` files and you need practical TypeScript guidance.
|
|
9
|
+
|
|
10
|
+
Apply this skill together with the `clean-code` skill. Favor readable, maintainable type design over clever type tricks.
|
|
11
|
+
|
|
12
|
+
## Use this skill for
|
|
13
|
+
|
|
14
|
+
- designing types for new code
|
|
15
|
+
- improving type safety in existing code
|
|
16
|
+
- modeling domain, API, and UI state
|
|
17
|
+
- reviewing TypeScript quality
|
|
18
|
+
- reducing unsafe casts and weak typing
|
|
19
|
+
|
|
20
|
+
## Core principles
|
|
21
|
+
|
|
22
|
+
### 1. Prefer precise types over broad types
|
|
23
|
+
- Choose the narrowest type that matches the real contract.
|
|
24
|
+
- Prefer specific object shapes, literal unions, and well-named interfaces over broad catch-all types.
|
|
25
|
+
- Do not use `any` when a better type is available.
|
|
26
|
+
|
|
27
|
+
### 2. Prefer `unknown` at boundaries, then narrow
|
|
28
|
+
- Use `unknown` for untrusted external input.
|
|
29
|
+
- Narrow with checks before using values.
|
|
30
|
+
- Do not spread unsafe assumptions through the codebase.
|
|
31
|
+
|
|
32
|
+
#### Prefer
|
|
33
|
+
```ts
|
|
34
|
+
function parsePayload(input: unknown): PlaylistRequest {
|
|
35
|
+
if (!isPlaylistRequest(input)) {
|
|
36
|
+
throw new Error("Invalid playlist request");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return input;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Avoid
|
|
44
|
+
```ts
|
|
45
|
+
function parsePayload(input: any): PlaylistRequest {
|
|
46
|
+
return input as PlaylistRequest;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 3. Prefer narrowing over casting
|
|
51
|
+
- Use control flow, guards, discriminated unions, and predicates to refine types.
|
|
52
|
+
- Use casts only when you truly know more than TypeScript can infer.
|
|
53
|
+
- Keep casts local and rare.
|
|
54
|
+
|
|
55
|
+
### 4. Model states explicitly
|
|
56
|
+
- When values can be in distinct states, prefer explicit modeling.
|
|
57
|
+
- Use discriminated unions when they make invalid states harder to represent.
|
|
58
|
+
- Avoid boolean-flag combinations when a named state model is clearer.
|
|
59
|
+
|
|
60
|
+
#### Prefer
|
|
61
|
+
```ts
|
|
62
|
+
type LoadState =
|
|
63
|
+
| { status: "idle" }
|
|
64
|
+
| { status: "loading" }
|
|
65
|
+
| { status: "success"; tracks: Track[] }
|
|
66
|
+
| { status: "error"; message: string };
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Avoid
|
|
70
|
+
```ts
|
|
71
|
+
type LoadState = {
|
|
72
|
+
isLoading: boolean;
|
|
73
|
+
hasError: boolean;
|
|
74
|
+
tracks?: Track[];
|
|
75
|
+
message?: string;
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 5. Keep public types readable
|
|
80
|
+
- Function signatures, exported types, and shared contracts should be easy to understand.
|
|
81
|
+
- Prefer named types when they make intent clearer.
|
|
82
|
+
- Avoid deeply nested inline types for important boundaries.
|
|
83
|
+
|
|
84
|
+
### 6. Use optionality carefully
|
|
85
|
+
- Only mark fields optional when absence is a real part of the contract.
|
|
86
|
+
- Prefer explicit unions such as `string | null` when they better communicate intent.
|
|
87
|
+
- Avoid stacking `undefined | null | optional` unless the distinction is meaningful.
|
|
88
|
+
|
|
89
|
+
### 7. Keep generics useful, not impressive
|
|
90
|
+
- Use generics when they improve correctness or reuse.
|
|
91
|
+
- Do not introduce complex generic abstractions unless they clearly pay off.
|
|
92
|
+
- Prefer simple, understandable generic constraints.
|
|
93
|
+
|
|
94
|
+
### 8. Let inference help, but not hide intent
|
|
95
|
+
- Use inference for obvious local values.
|
|
96
|
+
- Add explicit annotations at important boundaries such as exports, shared contracts, and complex return types.
|
|
97
|
+
- If inferred types become confusing, make them explicit.
|
|
98
|
+
|
|
99
|
+
### 9. Encode invariants where helpful
|
|
100
|
+
- Use TypeScript to make invalid states harder to represent.
|
|
101
|
+
- Do not try to force every runtime guarantee into the type system.
|
|
102
|
+
- Balance safety with readability and development speed.
|
|
103
|
+
|
|
104
|
+
## Decision rule
|
|
105
|
+
|
|
106
|
+
When unsure, prefer:
|
|
107
|
+
1. narrower types
|
|
108
|
+
2. narrowing over casting
|
|
109
|
+
3. explicit state models
|
|
110
|
+
4. readable public contracts
|
|
111
|
+
5. simpler type designs over advanced tricks
|