cp-toolkit 2.2.3 → 2.2.4

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 (71) hide show
  1. package/package.json +1 -1
  2. package/src/commands/add.js +23 -16
  3. package/src/commands/doctor.js +15 -10
  4. package/src/commands/init.js +55 -16
  5. package/templates/AGENTS.md +47 -0
  6. package/templates/ARCHITECTURE.md +42 -0
  7. package/templates/agents/backend-specialist.md +1 -0
  8. package/templates/agents/code-archaeologist.md +116 -106
  9. package/templates/agents/database-architect.md +1 -0
  10. package/templates/agents/debugger.md +1 -0
  11. package/templates/agents/devops-engineer.md +1 -0
  12. package/templates/agents/documentation-writer.md +1 -0
  13. package/templates/agents/explorer-agent.md +83 -73
  14. package/templates/agents/frontend-specialist.md +1 -0
  15. package/templates/agents/game-developer.md +1 -0
  16. package/templates/agents/mobile-developer.md +1 -0
  17. package/templates/agents/orchestrator.md +426 -416
  18. package/templates/agents/penetration-tester.md +1 -0
  19. package/templates/agents/performance-optimizer.md +1 -0
  20. package/templates/agents/product-manager.md +122 -112
  21. package/templates/agents/product-owner.md +105 -95
  22. package/templates/agents/project-planner.md +416 -406
  23. package/templates/agents/qa-automation-engineer.md +113 -103
  24. package/templates/agents/security-auditor.md +1 -0
  25. package/templates/agents/seo-specialist.md +1 -0
  26. package/templates/agents/test-engineer.md +1 -0
  27. package/templates/skills/core/behavioral-modes/SKILL.md +244 -242
  28. package/templates/skills/core/brainstorming/SKILL.md +166 -163
  29. package/templates/skills/core/mcp-builder/SKILL.md +178 -176
  30. package/templates/skills/core/parallel-agents/SKILL.md +187 -175
  31. package/templates/skills/core/plan-writing/SKILL.md +154 -152
  32. package/templates/skills/optional/api-patterns/SKILL.md +83 -81
  33. package/templates/skills/optional/app-builder/SKILL.md +78 -75
  34. package/templates/skills/optional/app-builder/templates/SKILL.md +41 -39
  35. package/templates/skills/optional/architecture/SKILL.md +58 -55
  36. package/templates/skills/optional/bash-linux/SKILL.md +201 -199
  37. package/templates/skills/optional/code-review-checklist/SKILL.md +110 -109
  38. package/templates/skills/optional/database-design/SKILL.md +54 -52
  39. package/templates/skills/optional/deployment-procedures/SKILL.md +243 -241
  40. package/templates/skills/optional/documentation-templates/SKILL.md +196 -194
  41. package/templates/skills/optional/frontend-design/SKILL.md +421 -418
  42. package/templates/skills/optional/game-development/2d-games/SKILL.md +120 -119
  43. package/templates/skills/optional/game-development/3d-games/SKILL.md +136 -135
  44. package/templates/skills/optional/game-development/SKILL.md +169 -167
  45. package/templates/skills/optional/game-development/game-art/SKILL.md +187 -185
  46. package/templates/skills/optional/game-development/game-audio/SKILL.md +192 -190
  47. package/templates/skills/optional/game-development/game-design/SKILL.md +131 -129
  48. package/templates/skills/optional/game-development/mobile-games/SKILL.md +110 -108
  49. package/templates/skills/optional/game-development/multiplayer/SKILL.md +133 -132
  50. package/templates/skills/optional/game-development/pc-games/SKILL.md +146 -144
  51. package/templates/skills/optional/game-development/vr-ar/SKILL.md +124 -123
  52. package/templates/skills/optional/game-development/web-games/SKILL.md +152 -150
  53. package/templates/skills/optional/geo-fundamentals/SKILL.md +158 -156
  54. package/templates/skills/optional/i18n-localization/SKILL.md +156 -154
  55. package/templates/skills/optional/lint-and-validate/SKILL.md +48 -45
  56. package/templates/skills/optional/mobile-design/SKILL.md +397 -394
  57. package/templates/skills/optional/nextjs-react-expert/SKILL.md +271 -267
  58. package/templates/skills/optional/nodejs-best-practices/SKILL.md +335 -333
  59. package/templates/skills/optional/performance-profiling/SKILL.md +145 -143
  60. package/templates/skills/optional/powershell-windows/SKILL.md +169 -167
  61. package/templates/skills/optional/python-patterns/SKILL.md +443 -441
  62. package/templates/skills/optional/red-team-tactics/SKILL.md +201 -199
  63. package/templates/skills/optional/seo-fundamentals/SKILL.md +130 -129
  64. package/templates/skills/optional/server-management/SKILL.md +163 -161
  65. package/templates/skills/optional/systematic-debugging/SKILL.md +111 -109
  66. package/templates/skills/optional/tailwind-patterns/SKILL.md +271 -269
  67. package/templates/skills/optional/tdd-workflow/SKILL.md +150 -149
  68. package/templates/skills/optional/testing-patterns/SKILL.md +179 -178
  69. package/templates/skills/optional/vulnerability-scanner/SKILL.md +278 -276
  70. package/templates/skills/optional/web-design-guidelines/SKILL.md +60 -57
  71. package/templates/skills/optional/webapp-testing/SKILL.md +188 -187
@@ -1,39 +1,41 @@
1
- ---
2
- name: templates
3
- description: Project scaffolding templates for new applications. Use when creating new projects from scratch. Contains 12 templates for various tech stacks.
4
- allowed-tools: Read, Glob, Grep
5
- ---
6
-
7
- # Project Templates
8
-
9
- > Quick-start templates for scaffolding new projects.
10
-
11
- ---
12
-
13
- ## 🎯 Selective Reading Rule
14
-
15
- **Read ONLY the template matching user's project type!**
16
-
17
- | Template | Tech Stack | When to Use |
18
- |----------|------------|-------------|
19
- | [nextjs-fullstack](nextjs-fullstack/TEMPLATE.md) | Next.js + Prisma | Full-stack web app |
20
- | [nextjs-saas](nextjs-saas/TEMPLATE.md) | Next.js + Stripe | SaaS product |
21
- | [nextjs-static](nextjs-static/TEMPLATE.md) | Next.js + Framer | Landing page |
22
- | [express-api](express-api/TEMPLATE.md) | Express + JWT | REST API |
23
- | [python-fastapi](python-fastapi/TEMPLATE.md) | FastAPI | Python API |
24
- | [react-native-app](react-native-app/TEMPLATE.md) | Expo + Zustand | Mobile app |
25
- | [flutter-app](flutter-app/TEMPLATE.md) | Flutter + Riverpod | Cross-platform |
26
- | [electron-desktop](electron-desktop/TEMPLATE.md) | Electron + React | Desktop app |
27
- | [chrome-extension](chrome-extension/TEMPLATE.md) | Chrome MV3 | Browser extension |
28
- | [cli-tool](cli-tool/TEMPLATE.md) | Node.js + Commander | CLI app |
29
- | [monorepo-turborepo](monorepo-turborepo/TEMPLATE.md) | Turborepo + pnpm | Monorepo |
30
- | [astro-static](astro-static/TEMPLATE.md) | Astro + MDX | Blog / Docs |
31
-
32
- ---
33
-
34
- ## Usage
35
-
36
- 1. User says "create [type] app"
37
- 2. Match to appropriate template
38
- 3. Read ONLY that template's TEMPLATE.md
39
- 4. Follow its tech stack and structure
1
+ ---
2
+ name: templates
3
+ description: Project scaffolding templates for new applications. Use when creating
4
+ new projects from scratch. Contains 12 templates for various tech stacks.
5
+ allowed-tools: Read, Glob, Grep
6
+ version: '1.0'
7
+ ---
8
+
9
+ # Project Templates
10
+
11
+ > Quick-start templates for scaffolding new projects.
12
+
13
+ ---
14
+
15
+ ## 🎯 Selective Reading Rule
16
+
17
+ **Read ONLY the template matching user's project type!**
18
+
19
+ | Template | Tech Stack | When to Use |
20
+ |----------|------------|-------------|
21
+ | [nextjs-fullstack](nextjs-fullstack/TEMPLATE.md) | Next.js + Prisma | Full-stack web app |
22
+ | [nextjs-saas](nextjs-saas/TEMPLATE.md) | Next.js + Stripe | SaaS product |
23
+ | [nextjs-static](nextjs-static/TEMPLATE.md) | Next.js + Framer | Landing page |
24
+ | [express-api](express-api/TEMPLATE.md) | Express + JWT | REST API |
25
+ | [python-fastapi](python-fastapi/TEMPLATE.md) | FastAPI | Python API |
26
+ | [react-native-app](react-native-app/TEMPLATE.md) | Expo + Zustand | Mobile app |
27
+ | [flutter-app](flutter-app/TEMPLATE.md) | Flutter + Riverpod | Cross-platform |
28
+ | [electron-desktop](electron-desktop/TEMPLATE.md) | Electron + React | Desktop app |
29
+ | [chrome-extension](chrome-extension/TEMPLATE.md) | Chrome MV3 | Browser extension |
30
+ | [cli-tool](cli-tool/TEMPLATE.md) | Node.js + Commander | CLI app |
31
+ | [monorepo-turborepo](monorepo-turborepo/TEMPLATE.md) | Turborepo + pnpm | Monorepo |
32
+ | [astro-static](astro-static/TEMPLATE.md) | Astro + MDX | Blog / Docs |
33
+
34
+ ---
35
+
36
+ ## Usage
37
+
38
+ 1. User says "create [type] app"
39
+ 2. Match to appropriate template
40
+ 3. Read ONLY that template's TEMPLATE.md
41
+ 4. Follow its tech stack and structure
@@ -1,55 +1,58 @@
1
- ---
2
- name: architecture
3
- description: Architectural decision-making framework. Requirements analysis, trade-off evaluation, ADR documentation. Use when making architecture decisions or analyzing system design.
4
- allowed-tools: Read, Glob, Grep
5
- ---
6
-
7
- # Architecture Decision Framework
8
-
9
- > "Requirements drive architecture. Trade-offs inform decisions. ADRs capture rationale."
10
-
11
- ## 🎯 Selective Reading Rule
12
-
13
- **Read ONLY files relevant to the request!** Check the content map, find what you need.
14
-
15
- | File | Description | When to Read |
16
- |------|-------------|--------------|
17
- | `context-discovery.md` | Questions to ask, project classification | Starting architecture design |
18
- | `trade-off-analysis.md` | ADR templates, trade-off framework | Documenting decisions |
19
- | `pattern-selection.md` | Decision trees, anti-patterns | Choosing patterns |
20
- | `examples.md` | MVP, SaaS, Enterprise examples | Reference implementations |
21
- | `patterns-reference.md` | Quick lookup for patterns | Pattern comparison |
22
-
23
- ---
24
-
25
- ## 🔗 Related Skills
26
-
27
- | Skill | Use For |
28
- |-------|---------|
29
- | `@[skills/database-design]` | Database schema design |
30
- | `@[skills/api-patterns]` | API design patterns |
31
- | `@[skills/deployment-procedures]` | Deployment architecture |
32
-
33
- ---
34
-
35
- ## Core Principle
36
-
37
- **"Simplicity is the ultimate sophistication."**
38
-
39
- - Start simple
40
- - Add complexity ONLY when proven necessary
41
- - You can always add patterns later
42
- - Removing complexity is MUCH harder than adding it
43
-
44
- ---
45
-
46
- ## Validation Checklist
47
-
48
- Before finalizing architecture:
49
-
50
- - [ ] Requirements clearly understood
51
- - [ ] Constraints identified
52
- - [ ] Each decision has trade-off analysis
53
- - [ ] Simpler alternatives considered
54
- - [ ] ADRs written for significant decisions
55
- - [ ] Team expertise matches chosen patterns
1
+ ---
2
+ name: architecture
3
+ description: Architectural decision-making framework. Requirements analysis, trade-off
4
+ evaluation, ADR documentation. Use when making architecture decisions or analyzing
5
+ system design.
6
+ allowed-tools: Read, Glob, Grep
7
+ version: '1.0'
8
+ ---
9
+
10
+ # Architecture Decision Framework
11
+
12
+ > "Requirements drive architecture. Trade-offs inform decisions. ADRs capture rationale."
13
+
14
+ ## 🎯 Selective Reading Rule
15
+
16
+ **Read ONLY files relevant to the request!** Check the content map, find what you need.
17
+
18
+ | File | Description | When to Read |
19
+ |------|-------------|--------------|
20
+ | `context-discovery.md` | Questions to ask, project classification | Starting architecture design |
21
+ | `trade-off-analysis.md` | ADR templates, trade-off framework | Documenting decisions |
22
+ | `pattern-selection.md` | Decision trees, anti-patterns | Choosing patterns |
23
+ | `examples.md` | MVP, SaaS, Enterprise examples | Reference implementations |
24
+ | `patterns-reference.md` | Quick lookup for patterns | Pattern comparison |
25
+
26
+ ---
27
+
28
+ ## 🔗 Related Skills
29
+
30
+ | Skill | Use For |
31
+ |-------|---------|
32
+ | `@[skills/database-design]` | Database schema design |
33
+ | `@[skills/api-patterns]` | API design patterns |
34
+ | `@[skills/deployment-procedures]` | Deployment architecture |
35
+
36
+ ---
37
+
38
+ ## Core Principle
39
+
40
+ **"Simplicity is the ultimate sophistication."**
41
+
42
+ - Start simple
43
+ - Add complexity ONLY when proven necessary
44
+ - You can always add patterns later
45
+ - Removing complexity is MUCH harder than adding it
46
+
47
+ ---
48
+
49
+ ## Validation Checklist
50
+
51
+ Before finalizing architecture:
52
+
53
+ - [ ] Requirements clearly understood
54
+ - [ ] Constraints identified
55
+ - [ ] Each decision has trade-off analysis
56
+ - [ ] Simpler alternatives considered
57
+ - [ ] ADRs written for significant decisions
58
+ - [ ] Team expertise matches chosen patterns
@@ -1,199 +1,201 @@
1
- ---
2
- name: bash-linux
3
- description: Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.
4
- allowed-tools: Read, Write, Edit, Glob, Grep, Bash
5
- ---
6
-
7
- # Bash Linux Patterns
8
-
9
- > Essential patterns for Bash on Linux/macOS.
10
-
11
- ---
12
-
13
- ## 1. Operator Syntax
14
-
15
- ### Chaining Commands
16
-
17
- | Operator | Meaning | Example |
18
- |----------|---------|---------|
19
- | `;` | Run sequentially | `cmd1; cmd2` |
20
- | `&&` | Run if previous succeeded | `npm install && npm run dev` |
21
- | `\|\|` | Run if previous failed | `npm test \|\| echo "Tests failed"` |
22
- | `\|` | Pipe output | `ls \| grep ".js"` |
23
-
24
- ---
25
-
26
- ## 2. File Operations
27
-
28
- ### Essential Commands
29
-
30
- | Task | Command |
31
- |------|---------|
32
- | List all | `ls -la` |
33
- | Find files | `find . -name "*.js" -type f` |
34
- | File content | `cat file.txt` |
35
- | First N lines | `head -n 20 file.txt` |
36
- | Last N lines | `tail -n 20 file.txt` |
37
- | Follow log | `tail -f log.txt` |
38
- | Search in files | `grep -r "pattern" --include="*.js"` |
39
- | File size | `du -sh *` |
40
- | Disk usage | `df -h` |
41
-
42
- ---
43
-
44
- ## 3. Process Management
45
-
46
- | Task | Command |
47
- |------|---------|
48
- | List processes | `ps aux` |
49
- | Find by name | `ps aux \| grep node` |
50
- | Kill by PID | `kill -9 <PID>` |
51
- | Find port user | `lsof -i :3000` |
52
- | Kill port | `kill -9 $(lsof -t -i :3000)` |
53
- | Background | `npm run dev &` |
54
- | Jobs | `jobs -l` |
55
- | Bring to front | `fg %1` |
56
-
57
- ---
58
-
59
- ## 4. Text Processing
60
-
61
- ### Core Tools
62
-
63
- | Tool | Purpose | Example |
64
- |------|---------|---------|
65
- | `grep` | Search | `grep -rn "TODO" src/` |
66
- | `sed` | Replace | `sed -i 's/old/new/g' file.txt` |
67
- | `awk` | Extract columns | `awk '{print $1}' file.txt` |
68
- | `cut` | Cut fields | `cut -d',' -f1 data.csv` |
69
- | `sort` | Sort lines | `sort -u file.txt` |
70
- | `uniq` | Unique lines | `sort file.txt \| uniq -c` |
71
- | `wc` | Count | `wc -l file.txt` |
72
-
73
- ---
74
-
75
- ## 5. Environment Variables
76
-
77
- | Task | Command |
78
- |------|---------|
79
- | View all | `env` or `printenv` |
80
- | View one | `echo $PATH` |
81
- | Set temporary | `export VAR="value"` |
82
- | Set in script | `VAR="value" command` |
83
- | Add to PATH | `export PATH="$PATH:/new/path"` |
84
-
85
- ---
86
-
87
- ## 6. Network
88
-
89
- | Task | Command |
90
- |------|---------|
91
- | Download | `curl -O https://example.com/file` |
92
- | API request | `curl -X GET https://api.example.com` |
93
- | POST JSON | `curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' URL` |
94
- | Check port | `nc -zv localhost 3000` |
95
- | Network info | `ifconfig` or `ip addr` |
96
-
97
- ---
98
-
99
- ## 7. Script Template
100
-
101
- ```bash
102
- #!/bin/bash
103
- set -euo pipefail # Exit on error, undefined var, pipe fail
104
-
105
- # Colors (optional)
106
- RED='\033[0;31m'
107
- GREEN='\033[0;32m'
108
- NC='\033[0m'
109
-
110
- # Script directory
111
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
112
-
113
- # Functions
114
- log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
115
- log_error() { echo -e "${RED}[ERROR]${NC} $1" >&2; }
116
-
117
- # Main
118
- main() {
119
- log_info "Starting..."
120
- # Your logic here
121
- log_info "Done!"
122
- }
123
-
124
- main "$@"
125
- ```
126
-
127
- ---
128
-
129
- ## 8. Common Patterns
130
-
131
- ### Check if command exists
132
-
133
- ```bash
134
- if command -v node &> /dev/null; then
135
- echo "Node is installed"
136
- fi
137
- ```
138
-
139
- ### Default variable value
140
-
141
- ```bash
142
- NAME=${1:-"default_value"}
143
- ```
144
-
145
- ### Read file line by line
146
-
147
- ```bash
148
- while IFS= read -r line; do
149
- echo "$line"
150
- done < file.txt
151
- ```
152
-
153
- ### Loop over files
154
-
155
- ```bash
156
- for file in *.js; do
157
- echo "Processing $file"
158
- done
159
- ```
160
-
161
- ---
162
-
163
- ## 9. Differences from PowerShell
164
-
165
- | Task | PowerShell | Bash |
166
- |------|------------|------|
167
- | List files | `Get-ChildItem` | `ls -la` |
168
- | Find files | `Get-ChildItem -Recurse` | `find . -type f` |
169
- | Environment | `$env:VAR` | `$VAR` |
170
- | String concat | `"$a$b"` | `"$a$b"` (same) |
171
- | Null check | `if ($x)` | `if [ -n "$x" ]` |
172
- | Pipeline | Object-based | Text-based |
173
-
174
- ---
175
-
176
- ## 10. Error Handling
177
-
178
- ### Set options
179
-
180
- ```bash
181
- set -e # Exit on error
182
- set -u # Exit on undefined variable
183
- set -o pipefail # Exit on pipe failure
184
- set -x # Debug: print commands
185
- ```
186
-
187
- ### Trap for cleanup
188
-
189
- ```bash
190
- cleanup() {
191
- echo "Cleaning up..."
192
- rm -f /tmp/tempfile
193
- }
194
- trap cleanup EXIT
195
- ```
196
-
197
- ---
198
-
199
- > **Remember:** Bash is text-based. Use `&&` for success chains, `set -e` for safety, and quote your variables!
1
+ ---
2
+ name: bash-linux
3
+ description: Bash/Linux terminal patterns. Critical commands, piping, error handling,
4
+ scripting. Use when working on macOS or Linux systems.
5
+ allowed-tools: Read, Write, Edit, Glob, Grep, Bash
6
+ version: '1.0'
7
+ ---
8
+
9
+ # Bash Linux Patterns
10
+
11
+ > Essential patterns for Bash on Linux/macOS.
12
+
13
+ ---
14
+
15
+ ## 1. Operator Syntax
16
+
17
+ ### Chaining Commands
18
+
19
+ | Operator | Meaning | Example |
20
+ |----------|---------|---------|
21
+ | `;` | Run sequentially | `cmd1; cmd2` |
22
+ | `&&` | Run if previous succeeded | `npm install && npm run dev` |
23
+ | `\|\|` | Run if previous failed | `npm test \|\| echo "Tests failed"` |
24
+ | `\|` | Pipe output | `ls \| grep ".js"` |
25
+
26
+ ---
27
+
28
+ ## 2. File Operations
29
+
30
+ ### Essential Commands
31
+
32
+ | Task | Command |
33
+ |------|---------|
34
+ | List all | `ls -la` |
35
+ | Find files | `find . -name "*.js" -type f` |
36
+ | File content | `cat file.txt` |
37
+ | First N lines | `head -n 20 file.txt` |
38
+ | Last N lines | `tail -n 20 file.txt` |
39
+ | Follow log | `tail -f log.txt` |
40
+ | Search in files | `grep -r "pattern" --include="*.js"` |
41
+ | File size | `du -sh *` |
42
+ | Disk usage | `df -h` |
43
+
44
+ ---
45
+
46
+ ## 3. Process Management
47
+
48
+ | Task | Command |
49
+ |------|---------|
50
+ | List processes | `ps aux` |
51
+ | Find by name | `ps aux \| grep node` |
52
+ | Kill by PID | `kill -9 <PID>` |
53
+ | Find port user | `lsof -i :3000` |
54
+ | Kill port | `kill -9 $(lsof -t -i :3000)` |
55
+ | Background | `npm run dev &` |
56
+ | Jobs | `jobs -l` |
57
+ | Bring to front | `fg %1` |
58
+
59
+ ---
60
+
61
+ ## 4. Text Processing
62
+
63
+ ### Core Tools
64
+
65
+ | Tool | Purpose | Example |
66
+ |------|---------|---------|
67
+ | `grep` | Search | `grep -rn "TODO" src/` |
68
+ | `sed` | Replace | `sed -i 's/old/new/g' file.txt` |
69
+ | `awk` | Extract columns | `awk '{print $1}' file.txt` |
70
+ | `cut` | Cut fields | `cut -d',' -f1 data.csv` |
71
+ | `sort` | Sort lines | `sort -u file.txt` |
72
+ | `uniq` | Unique lines | `sort file.txt \| uniq -c` |
73
+ | `wc` | Count | `wc -l file.txt` |
74
+
75
+ ---
76
+
77
+ ## 5. Environment Variables
78
+
79
+ | Task | Command |
80
+ |------|---------|
81
+ | View all | `env` or `printenv` |
82
+ | View one | `echo $PATH` |
83
+ | Set temporary | `export VAR="value"` |
84
+ | Set in script | `VAR="value" command` |
85
+ | Add to PATH | `export PATH="$PATH:/new/path"` |
86
+
87
+ ---
88
+
89
+ ## 6. Network
90
+
91
+ | Task | Command |
92
+ |------|---------|
93
+ | Download | `curl -O https://example.com/file` |
94
+ | API request | `curl -X GET https://api.example.com` |
95
+ | POST JSON | `curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' URL` |
96
+ | Check port | `nc -zv localhost 3000` |
97
+ | Network info | `ifconfig` or `ip addr` |
98
+
99
+ ---
100
+
101
+ ## 7. Script Template
102
+
103
+ ```bash
104
+ #!/bin/bash
105
+ set -euo pipefail # Exit on error, undefined var, pipe fail
106
+
107
+ # Colors (optional)
108
+ RED='\033[0;31m'
109
+ GREEN='\033[0;32m'
110
+ NC='\033[0m'
111
+
112
+ # Script directory
113
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
114
+
115
+ # Functions
116
+ log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
117
+ log_error() { echo -e "${RED}[ERROR]${NC} $1" >&2; }
118
+
119
+ # Main
120
+ main() {
121
+ log_info "Starting..."
122
+ # Your logic here
123
+ log_info "Done!"
124
+ }
125
+
126
+ main "$@"
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 8. Common Patterns
132
+
133
+ ### Check if command exists
134
+
135
+ ```bash
136
+ if command -v node &> /dev/null; then
137
+ echo "Node is installed"
138
+ fi
139
+ ```
140
+
141
+ ### Default variable value
142
+
143
+ ```bash
144
+ NAME=${1:-"default_value"}
145
+ ```
146
+
147
+ ### Read file line by line
148
+
149
+ ```bash
150
+ while IFS= read -r line; do
151
+ echo "$line"
152
+ done < file.txt
153
+ ```
154
+
155
+ ### Loop over files
156
+
157
+ ```bash
158
+ for file in *.js; do
159
+ echo "Processing $file"
160
+ done
161
+ ```
162
+
163
+ ---
164
+
165
+ ## 9. Differences from PowerShell
166
+
167
+ | Task | PowerShell | Bash |
168
+ |------|------------|------|
169
+ | List files | `Get-ChildItem` | `ls -la` |
170
+ | Find files | `Get-ChildItem -Recurse` | `find . -type f` |
171
+ | Environment | `$env:VAR` | `$VAR` |
172
+ | String concat | `"$a$b"` | `"$a$b"` (same) |
173
+ | Null check | `if ($x)` | `if [ -n "$x" ]` |
174
+ | Pipeline | Object-based | Text-based |
175
+
176
+ ---
177
+
178
+ ## 10. Error Handling
179
+
180
+ ### Set options
181
+
182
+ ```bash
183
+ set -e # Exit on error
184
+ set -u # Exit on undefined variable
185
+ set -o pipefail # Exit on pipe failure
186
+ set -x # Debug: print commands
187
+ ```
188
+
189
+ ### Trap for cleanup
190
+
191
+ ```bash
192
+ cleanup() {
193
+ echo "Cleaning up..."
194
+ rm -f /tmp/tempfile
195
+ }
196
+ trap cleanup EXIT
197
+ ```
198
+
199
+ ---
200
+
201
+ > **Remember:** Bash is text-based. Use `&&` for success chains, `set -e` for safety, and quote your variables!