claude-code-templates 1.14.13 → 1.14.15

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 (68) hide show
  1. package/README.md +7 -7
  2. package/package.json +1 -2
  3. package/src/health-check.js +310 -0
  4. package/src/index.js +1 -1
  5. package/templates/common/.claude/commands/git-workflow.md +0 -239
  6. package/templates/common/.claude/commands/project-setup.md +0 -316
  7. package/templates/common/.mcp.json +0 -41
  8. package/templates/common/CLAUDE.md +0 -109
  9. package/templates/common/README.md +0 -96
  10. package/templates/go/.mcp.json +0 -78
  11. package/templates/go/README.md +0 -25
  12. package/templates/javascript-typescript/.claude/commands/api-endpoint.md +0 -51
  13. package/templates/javascript-typescript/.claude/commands/debug.md +0 -52
  14. package/templates/javascript-typescript/.claude/commands/lint.md +0 -48
  15. package/templates/javascript-typescript/.claude/commands/npm-scripts.md +0 -48
  16. package/templates/javascript-typescript/.claude/commands/refactor.md +0 -55
  17. package/templates/javascript-typescript/.claude/commands/test.md +0 -61
  18. package/templates/javascript-typescript/.claude/commands/typescript-migrate.md +0 -51
  19. package/templates/javascript-typescript/.claude/settings.json +0 -142
  20. package/templates/javascript-typescript/.mcp.json +0 -80
  21. package/templates/javascript-typescript/CLAUDE.md +0 -185
  22. package/templates/javascript-typescript/README.md +0 -259
  23. package/templates/javascript-typescript/examples/angular-app/.claude/commands/components.md +0 -63
  24. package/templates/javascript-typescript/examples/angular-app/.claude/commands/services.md +0 -62
  25. package/templates/javascript-typescript/examples/node-api/.claude/commands/api-endpoint.md +0 -46
  26. package/templates/javascript-typescript/examples/node-api/.claude/commands/database.md +0 -56
  27. package/templates/javascript-typescript/examples/node-api/.claude/commands/middleware.md +0 -61
  28. package/templates/javascript-typescript/examples/node-api/.claude/commands/route.md +0 -57
  29. package/templates/javascript-typescript/examples/node-api/CLAUDE.md +0 -102
  30. package/templates/javascript-typescript/examples/react-app/.claude/commands/component.md +0 -29
  31. package/templates/javascript-typescript/examples/react-app/.claude/commands/hooks.md +0 -44
  32. package/templates/javascript-typescript/examples/react-app/.claude/commands/state-management.md +0 -45
  33. package/templates/javascript-typescript/examples/react-app/CLAUDE.md +0 -81
  34. package/templates/javascript-typescript/examples/react-app/agents/react-performance-optimization.md +0 -530
  35. package/templates/javascript-typescript/examples/react-app/agents/react-state-management.md +0 -295
  36. package/templates/javascript-typescript/examples/vue-app/.claude/commands/components.md +0 -46
  37. package/templates/javascript-typescript/examples/vue-app/.claude/commands/composables.md +0 -51
  38. package/templates/python/.claude/commands/lint.md +0 -111
  39. package/templates/python/.claude/commands/test.md +0 -73
  40. package/templates/python/.claude/settings.json +0 -153
  41. package/templates/python/.mcp.json +0 -78
  42. package/templates/python/CLAUDE.md +0 -276
  43. package/templates/python/examples/django-app/.claude/commands/admin.md +0 -264
  44. package/templates/python/examples/django-app/.claude/commands/django-model.md +0 -124
  45. package/templates/python/examples/django-app/.claude/commands/views.md +0 -222
  46. package/templates/python/examples/django-app/CLAUDE.md +0 -313
  47. package/templates/python/examples/fastapi-app/.claude/commands/api-endpoints.md +0 -513
  48. package/templates/python/examples/fastapi-app/.claude/commands/auth.md +0 -775
  49. package/templates/python/examples/fastapi-app/.claude/commands/database.md +0 -657
  50. package/templates/python/examples/fastapi-app/.claude/commands/deployment.md +0 -160
  51. package/templates/python/examples/fastapi-app/.claude/commands/testing.md +0 -927
  52. package/templates/python/examples/fastapi-app/CLAUDE.md +0 -229
  53. package/templates/python/examples/flask-app/.claude/commands/app-factory.md +0 -384
  54. package/templates/python/examples/flask-app/.claude/commands/blueprint.md +0 -243
  55. package/templates/python/examples/flask-app/.claude/commands/database.md +0 -410
  56. package/templates/python/examples/flask-app/.claude/commands/deployment.md +0 -620
  57. package/templates/python/examples/flask-app/.claude/commands/flask-route.md +0 -217
  58. package/templates/python/examples/flask-app/.claude/commands/testing.md +0 -559
  59. package/templates/python/examples/flask-app/CLAUDE.md +0 -391
  60. package/templates/ruby/.claude/commands/model.md +0 -360
  61. package/templates/ruby/.claude/commands/test.md +0 -480
  62. package/templates/ruby/.claude/settings.json +0 -146
  63. package/templates/ruby/.mcp.json +0 -83
  64. package/templates/ruby/CLAUDE.md +0 -284
  65. package/templates/ruby/examples/rails-app/.claude/commands/authentication.md +0 -490
  66. package/templates/ruby/examples/rails-app/CLAUDE.md +0 -376
  67. package/templates/rust/.mcp.json +0 -78
  68. package/templates/rust/README.md +0 -26
package/README.md CHANGED
@@ -51,14 +51,14 @@ npx claude-code-templates@latest --health-check
51
51
 
52
52
  ## 📖 Documentation
53
53
 
54
- **[📚 Complete Documentation](https://aitmpl.com/docu/)** - Comprehensive guides, examples, and API reference
54
+ **[📚 Complete Documentation](https://docs.aitmpl.com/)** - Comprehensive guides, examples, and API reference
55
55
 
56
56
  Quick links:
57
- - [Getting Started](https://aitmpl.com/docu/docs/intro) - Installation and first steps
58
- - [Project Setup](https://aitmpl.com/docu/docs/project-setup/interactive-setup) - Configure your projects
59
- - [Analytics Dashboard](https://aitmpl.com/docu/docs/analytics/overview) - Real-time monitoring
60
- - [Individual Components](https://aitmpl.com/docu/docs/components/overview) - Agents, Commands, MCPs
61
- - [CLI Options](https://aitmpl.com/docu/docs/cli-options) - All available commands
57
+ - [Getting Started](https://docs.aitmpl.com/docs/intro) - Installation and first steps
58
+ - [Project Setup](https://docs.aitmpl.com/docs/project-setup/interactive-setup) - Configure your projects
59
+ - [Analytics Dashboard](https://docs.aitmpl.com/docs/analytics/overview) - Real-time monitoring
60
+ - [Individual Components](https://docs.aitmpl.com/docs/components/overview) - Agents, Commands, MCPs
61
+ - [CLI Options](https://docs.aitmpl.com/docs/cli-options) - All available commands
62
62
 
63
63
  ## 🤝 Contributing
64
64
 
@@ -71,7 +71,7 @@ MIT License - see the [LICENSE](LICENSE) file for details.
71
71
  ## 🔗 Links
72
72
 
73
73
  - **🌐 Browse Components**: [aitmpl.com](https://aitmpl.com)
74
- - **📚 Documentation**: [aitmpl.com/docu](https://aitmpl.com/docu)
74
+ - **📚 Documentation**: [docs.aitmpl.com](https://docs.aitmpl.com)
75
75
  - **🐛 Issues**: [GitHub Issues](https://github.com/davila7/claude-code-templates/issues)
76
76
  - **💬 Discussions**: [GitHub Discussions](https://github.com/davila7/claude-code-templates/discussions)
77
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-templates",
3
- "version": "1.14.13",
3
+ "version": "1.14.15",
4
4
  "description": "CLI tool to setup Claude Code configurations with framework-specific commands, automation hooks and MCP Servers for your projects",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -85,7 +85,6 @@
85
85
  "files": [
86
86
  "bin/",
87
87
  "src/",
88
- "templates/",
89
88
  "README.md"
90
89
  ],
91
90
  "devDependencies": {
@@ -16,7 +16,9 @@ class HealthChecker {
16
16
  system: [],
17
17
  claudeCode: [],
18
18
  project: [],
19
+ agents: [],
19
20
  commands: [],
21
+ mcps: [],
20
22
  hooks: []
21
23
  };
22
24
  this.totalChecks = 0;
@@ -42,6 +44,14 @@ class HealthChecker {
42
44
  await this.checkProjectSetupWithSpinner();
43
45
  await this.sleep(3000);
44
46
 
47
+ // Agents check
48
+ await this.checkAgentsWithSpinner();
49
+ await this.sleep(3000);
50
+
51
+ // MCP servers check
52
+ await this.checkMCPServersWithSpinner();
53
+ await this.sleep(3000);
54
+
45
55
  // Custom commands check
46
56
  await this.checkCustomCommandsWithSpinner();
47
57
  await this.sleep(3000);
@@ -165,6 +175,54 @@ class HealthChecker {
165
175
  localSettingsSpinner.succeed(`${this.getStatusIcon(localSettingsInfo.status)} Local Settings │ ${localSettingsInfo.message}`);
166
176
  }
167
177
 
178
+ /**
179
+ * Check agents with spinner and immediate results
180
+ */
181
+ async checkAgentsWithSpinner() {
182
+ console.log(chalk.cyan('\n┌──────────┐'));
183
+ console.log(chalk.cyan('│ AGENTS │'));
184
+ console.log(chalk.cyan('└──────────┘'));
185
+
186
+ // Project agents
187
+ const projectSpinner = ora('Scanning Project Agents...').start();
188
+ const projectAgents = this.checkProjectAgents();
189
+ this.addResult('agents', 'Project Agents', projectAgents.status, projectAgents.message);
190
+ projectSpinner.succeed(`${this.getStatusIcon(projectAgents.status)} Project Agents │ ${projectAgents.message}`);
191
+
192
+ // Personal agents
193
+ const personalSpinner = ora('Scanning Personal Agents...').start();
194
+ const personalAgents = this.checkPersonalAgents();
195
+ this.addResult('agents', 'Personal Agents', personalAgents.status, personalAgents.message);
196
+ personalSpinner.succeed(`${this.getStatusIcon(personalAgents.status)} Personal Agents │ ${personalAgents.message}`);
197
+
198
+ // Agent syntax validation
199
+ const syntaxSpinner = ora('Validating Agent Syntax...').start();
200
+ const syntaxInfo = this.checkAgentSyntax();
201
+ this.addResult('agents', 'Agent Syntax', syntaxInfo.status, syntaxInfo.message);
202
+ syntaxSpinner.succeed(`${this.getStatusIcon(syntaxInfo.status)} Agent Syntax │ ${syntaxInfo.message}`);
203
+ }
204
+
205
+ /**
206
+ * Check MCP servers with spinner and immediate results
207
+ */
208
+ async checkMCPServersWithSpinner() {
209
+ console.log(chalk.cyan('\n┌──────────────┐'));
210
+ console.log(chalk.cyan('│ MCP SERVERS │'));
211
+ console.log(chalk.cyan('└──────────────┘'));
212
+
213
+ // Project MCP configuration
214
+ const projectMCPSpinner = ora('Scanning Project MCP Configuration...').start();
215
+ const projectMCP = this.checkProjectMCPConfiguration();
216
+ this.addResult('mcps', 'Project MCP Config', projectMCP.status, projectMCP.message);
217
+ projectMCPSpinner.succeed(`${this.getStatusIcon(projectMCP.status)} Project MCP Config │ ${projectMCP.message}`);
218
+
219
+ // MCP configuration validation
220
+ const mcpValidationSpinner = ora('Validating MCP Configuration...').start();
221
+ const mcpValidation = this.checkMCPConfigurationSyntax();
222
+ this.addResult('mcps', 'MCP Config Syntax', mcpValidation.status, mcpValidation.message);
223
+ mcpValidationSpinner.succeed(`${this.getStatusIcon(mcpValidation.status)} MCP Config Syntax │ ${mcpValidation.message}`);
224
+ }
225
+
168
226
  /**
169
227
  * Check custom commands with spinner and immediate results
170
228
  */
@@ -552,6 +610,123 @@ class HealthChecker {
552
610
  }
553
611
  }
554
612
 
613
+ checkProjectMCPConfiguration() {
614
+ const currentDir = process.cwd();
615
+ const mcpConfigPath = path.join(currentDir, '.mcp.json');
616
+
617
+ if (fs.existsSync(mcpConfigPath)) {
618
+ try {
619
+ const mcpConfig = JSON.parse(fs.readFileSync(mcpConfigPath, 'utf8'));
620
+
621
+ if (mcpConfig.mcpServers && typeof mcpConfig.mcpServers === 'object') {
622
+ const serverCount = Object.keys(mcpConfig.mcpServers).length;
623
+ return {
624
+ status: 'pass',
625
+ message: `${serverCount} MCP servers configured in .mcp.json`
626
+ };
627
+ } else {
628
+ return {
629
+ status: 'warn',
630
+ message: 'No mcpServers found in .mcp.json'
631
+ };
632
+ }
633
+ } catch (error) {
634
+ return {
635
+ status: 'fail',
636
+ message: 'Invalid JSON syntax in .mcp.json'
637
+ };
638
+ }
639
+ } else {
640
+ return {
641
+ status: 'warn',
642
+ message: 'No project MCP configuration found (.mcp.json)'
643
+ };
644
+ }
645
+ }
646
+
647
+ checkMCPConfigurationSyntax() {
648
+ const configPaths = [
649
+ path.join(process.cwd(), '.mcp.json')
650
+ ];
651
+
652
+ let totalServers = 0;
653
+ let validServers = 0;
654
+ let invalidServers = 0;
655
+ const issues = [];
656
+
657
+ for (const configPath of configPaths) {
658
+ if (fs.existsSync(configPath)) {
659
+ try {
660
+ const mcpConfig = JSON.parse(fs.readFileSync(configPath, 'utf8'));
661
+
662
+ if (mcpConfig.mcpServers && typeof mcpConfig.mcpServers === 'object') {
663
+ const servers = mcpConfig.mcpServers;
664
+
665
+ for (const [serverName, serverConfig] of Object.entries(servers)) {
666
+ totalServers++;
667
+
668
+ // Validate server configuration structure
669
+ if (!serverConfig || typeof serverConfig !== 'object') {
670
+ invalidServers++;
671
+ issues.push(`Invalid server config for ${serverName} in ${path.basename(configPath)}`);
672
+ continue;
673
+ }
674
+
675
+ // Check required fields
676
+ if (!serverConfig.command) {
677
+ invalidServers++;
678
+ issues.push(`Missing command for ${serverName} in ${path.basename(configPath)}`);
679
+ continue;
680
+ }
681
+
682
+ // Optional: Check if args is array when present
683
+ if (serverConfig.args && !Array.isArray(serverConfig.args)) {
684
+ invalidServers++;
685
+ issues.push(`Invalid args format for ${serverName} in ${path.basename(configPath)} (should be array)`);
686
+ continue;
687
+ }
688
+
689
+ // Optional: Check if env is object when present
690
+ if (serverConfig.env && typeof serverConfig.env !== 'object') {
691
+ invalidServers++;
692
+ issues.push(`Invalid env format for ${serverName} in ${path.basename(configPath)} (should be object)`);
693
+ continue;
694
+ }
695
+
696
+ validServers++;
697
+ }
698
+ }
699
+ } catch (error) {
700
+ // JSON parsing error already handled in other checks
701
+ }
702
+ }
703
+ }
704
+
705
+ if (totalServers === 0) {
706
+ return {
707
+ status: 'warn',
708
+ message: 'No MCP servers configured'
709
+ };
710
+ }
711
+
712
+ if (invalidServers === 0) {
713
+ return {
714
+ status: 'pass',
715
+ message: `All ${totalServers} MCP server configurations are valid`
716
+ };
717
+ } else if (validServers > 0) {
718
+ return {
719
+ status: 'warn',
720
+ message: `${validServers}/${totalServers} MCP servers valid, ${invalidServers} issues found`
721
+ };
722
+ } else {
723
+ return {
724
+ status: 'fail',
725
+ message: `All ${totalServers} MCP server configurations have issues`
726
+ };
727
+ }
728
+ }
729
+
555
730
  checkProjectCommands() {
556
731
  const currentDir = process.cwd();
557
732
  const commandsDir = path.join(currentDir, '.claude', 'commands');
@@ -625,6 +800,129 @@ class HealthChecker {
625
800
  }
626
801
  }
627
802
 
803
+ checkProjectAgents() {
804
+ const currentDir = process.cwd();
805
+ const agentsDir = path.join(currentDir, '.claude', 'agents');
806
+
807
+ if (fs.existsSync(agentsDir)) {
808
+ const agents = this.countAgentsRecursively(agentsDir);
809
+ return {
810
+ status: 'pass',
811
+ message: `${agents} agents found in .claude/agents/`
812
+ };
813
+ } else {
814
+ return {
815
+ status: 'warn',
816
+ message: 'No project agents directory found'
817
+ };
818
+ }
819
+ }
820
+
821
+ checkPersonalAgents() {
822
+ const homeDir = os.homedir();
823
+ const agentsDir = path.join(homeDir, '.claude', 'agents');
824
+
825
+ if (fs.existsSync(agentsDir)) {
826
+ const agents = this.countAgentsRecursively(agentsDir);
827
+ return {
828
+ status: 'pass',
829
+ message: `${agents} agents found in ~/.claude/agents/`
830
+ };
831
+ } else {
832
+ return {
833
+ status: 'warn',
834
+ message: 'No personal agents directory found'
835
+ };
836
+ }
837
+ }
838
+
839
+ countAgentsRecursively(dir) {
840
+ let count = 0;
841
+ try {
842
+ const items = fs.readdirSync(dir);
843
+ for (const item of items) {
844
+ const itemPath = path.join(dir, item);
845
+ const stat = fs.statSync(itemPath);
846
+ if (stat.isDirectory()) {
847
+ count += this.countAgentsRecursively(itemPath);
848
+ } else if (item.endsWith('.md')) {
849
+ count++;
850
+ }
851
+ }
852
+ } catch (error) {
853
+ // Handle permission or access errors
854
+ }
855
+ return count;
856
+ }
857
+
858
+ checkAgentSyntax() {
859
+ const currentDir = process.cwd();
860
+ const agentsDir = path.join(currentDir, '.claude', 'agents');
861
+
862
+ if (!fs.existsSync(agentsDir)) {
863
+ return {
864
+ status: 'warn',
865
+ message: 'No agents to validate'
866
+ };
867
+ }
868
+
869
+ const agents = this.getAgentFilesRecursively(agentsDir);
870
+ let issuesFound = 0;
871
+ let agentsChecked = 0;
872
+
873
+ for (const agentPath of agents) {
874
+ try {
875
+ const content = fs.readFileSync(agentPath, 'utf8');
876
+ agentsChecked++;
877
+
878
+ // Check for frontmatter (agent metadata)
879
+ if (!content.includes('---') || !content.includes('name:') || !content.includes('description:')) {
880
+ issuesFound++;
881
+ }
882
+ } catch (error) {
883
+ issuesFound++;
884
+ }
885
+ }
886
+
887
+ if (agentsChecked === 0) {
888
+ return {
889
+ status: 'warn',
890
+ message: 'No agents to validate'
891
+ };
892
+ }
893
+
894
+ if (issuesFound === 0) {
895
+ return {
896
+ status: 'pass',
897
+ message: `All ${agentsChecked} agents have proper syntax`
898
+ };
899
+ } else {
900
+ return {
901
+ status: 'warn',
902
+ message: `${issuesFound}/${agentsChecked} agents missing proper frontmatter`
903
+ };
904
+ }
905
+ }
906
+
907
+ getAgentFilesRecursively(dir) {
908
+ let files = [];
909
+ try {
910
+ const items = fs.readdirSync(dir);
911
+ for (const item of items) {
912
+ const itemPath = path.join(dir, item);
913
+ const stat = fs.statSync(itemPath);
914
+ if (stat.isDirectory()) {
915
+ files = files.concat(this.getAgentFilesRecursively(itemPath));
916
+ } else if (item.endsWith('.md')) {
917
+ files.push(itemPath);
918
+ }
919
+ }
920
+ } catch (error) {
921
+ // Handle permission or access errors
922
+ }
923
+ return files;
924
+ }
925
+
628
926
  checkUserHooks() {
629
927
  const homeDir = os.homedir();
630
928
  const settingsPath = path.join(homeDir, '.claude', 'settings.json');
@@ -1041,7 +1339,9 @@ class HealthChecker {
1041
1339
  ...this.results.system,
1042
1340
  ...this.results.claudeCode,
1043
1341
  ...this.results.project,
1342
+ ...this.results.agents,
1044
1343
  ...this.results.commands,
1344
+ ...this.results.mcps,
1045
1345
  ...this.results.hooks
1046
1346
  ];
1047
1347
 
@@ -1052,6 +1352,16 @@ class HealthChecker {
1052
1352
  recommendations.push('Consider switching to Zsh for better autocompletion and features');
1053
1353
  } else if (result.check === 'Command Syntax' && result.message.includes('$ARGUMENTS')) {
1054
1354
  recommendations.push('Add $ARGUMENTS placeholder to command files for proper parameter handling');
1355
+ } else if (result.check === 'Agent Syntax' && result.message.includes('frontmatter')) {
1356
+ recommendations.push('Add proper frontmatter (name, description) to agent files');
1357
+ } else if (result.check === 'Project Agents' && result.message.includes('No project agents directory')) {
1358
+ recommendations.push('Create .claude/agents/ directory to organize your custom agents');
1359
+ } else if (result.check === 'Project MCP Config' && result.message.includes('No project MCP configuration')) {
1360
+ recommendations.push('Create .mcp.json file to configure MCP servers for your project');
1361
+ } else if (result.check === 'MCP Config Syntax' && result.message.includes('Invalid JSON')) {
1362
+ recommendations.push('Fix JSON syntax errors in MCP configuration files');
1363
+ } else if (result.check === 'MCP Config Syntax' && result.message.includes('Missing command')) {
1364
+ recommendations.push('Add missing command fields to MCP server configurations');
1055
1365
  } else if (result.check === 'Local Hooks' && result.message.includes('Invalid JSON')) {
1056
1366
  recommendations.push('Fix JSON syntax error in .claude/settings.local.json');
1057
1367
  }
package/src/index.js CHANGED
@@ -271,7 +271,7 @@ async function createClaudeConfig(options = {}) {
271
271
  console.log(chalk.white(' 3. Start using Claude Code with: claude'));
272
272
  console.log('');
273
273
  console.log(chalk.blue('🌐 View all available templates at: https://aitmpl.com/'));
274
- console.log(chalk.blue('📖 Read the complete documentation at: https://aitmpl.com/docu/'));
274
+ console.log(chalk.blue('📖 Read the complete documentation at: https://docs.aitmpl.com/'));
275
275
 
276
276
  if (config.language !== 'common') {
277
277
  console.log(chalk.yellow(`💡 Language-specific features for ${config.language} have been configured`));
@@ -1,239 +0,0 @@
1
- # Git Workflow Helper
2
-
3
- Manage Git workflows with best practices and common operations.
4
-
5
- ## Purpose
6
-
7
- This command helps you perform common Git operations following best practices for collaborative development.
8
-
9
- ## Usage
10
-
11
- ```
12
- /git-workflow
13
- ```
14
-
15
- ## What this command does
16
-
17
- 1. **Guides through Git operations** with proper workflow
18
- 2. **Suggests best practices** for commits and branches
19
- 3. **Helps with conflict resolution** and merging
20
- 4. **Provides templates** for commit messages
21
- 5. **Manages branching strategies** (Git Flow, GitHub Flow)
22
-
23
- ## Common Workflows
24
-
25
- ### Feature Development
26
- ```bash
27
- # Create and switch to feature branch
28
- git checkout -b feature/user-authentication
29
-
30
- # Work on your feature
31
- # ... make changes ...
32
-
33
- # Stage and commit changes
34
- git add .
35
- git commit -m "feat: add user authentication system
36
-
37
- - Implement login/logout functionality
38
- - Add password validation
39
- - Create user session management
40
- - Add authentication middleware"
41
-
42
- # Push feature branch
43
- git push -u origin feature/user-authentication
44
-
45
- # Create pull request (via GitHub/GitLab interface)
46
- ```
47
-
48
- ### Hotfix Workflow
49
- ```bash
50
- # Create hotfix branch from main
51
- git checkout main
52
- git checkout -b hotfix/security-patch
53
-
54
- # Fix the issue
55
- # ... make changes ...
56
-
57
- # Commit the fix
58
- git commit -m "fix: resolve security vulnerability in auth module
59
-
60
- - Patch XSS vulnerability in login form
61
- - Update input validation
62
- - Add CSRF protection"
63
-
64
- # Push and create urgent PR
65
- git push -u origin hotfix/security-patch
66
- ```
67
-
68
- ### Sync with Remote
69
- ```bash
70
- # Update main branch
71
- git checkout main
72
- git pull origin main
73
-
74
- # Update feature branch with latest main
75
- git checkout feature/your-feature
76
- git rebase main
77
- # OR
78
- git merge main
79
- ```
80
-
81
- ## Commit Message Conventions
82
-
83
- ### Conventional Commits Format
84
- ```
85
- <type>[optional scope]: <description>
86
-
87
- [optional body]
88
-
89
- [optional footer(s)]
90
- ```
91
-
92
- ### Common Types
93
- - **feat**: New feature
94
- - **fix**: Bug fix
95
- - **docs**: Documentation changes
96
- - **style**: Code style changes (formatting, etc.)
97
- - **refactor**: Code refactoring
98
- - **test**: Adding or updating tests
99
- - **chore**: Maintenance tasks
100
-
101
- ### Examples
102
- ```bash
103
- # Feature
104
- git commit -m "feat(auth): add OAuth2 integration"
105
-
106
- # Bug fix
107
- git commit -m "fix(api): handle null response in user endpoint"
108
-
109
- # Documentation
110
- git commit -m "docs: update API documentation for v2.0"
111
-
112
- # Breaking change
113
- git commit -m "feat!: change API response format
114
-
115
- BREAKING CHANGE: API responses now use 'data' wrapper"
116
- ```
117
-
118
- ## Branch Management
119
-
120
- ### Git Flow Strategy
121
- ```bash
122
- # Main branches
123
- main # Production-ready code
124
- develop # Integration branch
125
-
126
- # Supporting branches
127
- feature/* # New features
128
- release/* # Release preparation
129
- hotfix/* # Quick fixes to production
130
- ```
131
-
132
- ### GitHub Flow (Simplified)
133
- ```bash
134
- # Only main branch + feature branches
135
- main # Production-ready code
136
- feature/* # All new work
137
- ```
138
-
139
- ## Conflict Resolution
140
-
141
- ### When Conflicts Occur
142
- ```bash
143
- # Start merge/rebase
144
- git merge feature-branch
145
- # OR
146
- git rebase main
147
-
148
- # If conflicts occur, Git will list conflicted files
149
- # Edit each file to resolve conflicts
150
-
151
- # Mark conflicts as resolved
152
- git add conflicted-file.js
153
-
154
- # Continue the merge/rebase
155
- git merge --continue
156
- # OR
157
- git rebase --continue
158
- ```
159
-
160
- ### Conflict Markers
161
- ```javascript
162
- <<<<<<< HEAD
163
- // Your current branch code
164
- const user = getCurrentUser();
165
- =======
166
- // Incoming branch code
167
- const user = getAuthenticatedUser();
168
- >>>>>>> feature-branch
169
- ```
170
-
171
- ## Useful Git Commands
172
-
173
- ### Status and Information
174
- ```bash
175
- git status # Check working directory status
176
- git log --oneline # View commit history
177
- git branch -a # List all branches
178
- git remote -v # List remote repositories
179
- ```
180
-
181
- ### Undoing Changes
182
- ```bash
183
- git checkout -- file.js # Discard changes to file
184
- git reset HEAD file.js # Unstage file
185
- git reset --soft HEAD~1 # Undo last commit (keep changes)
186
- git reset --hard HEAD~1 # Undo last commit (discard changes)
187
- ```
188
-
189
- ### Stashing Work
190
- ```bash
191
- git stash # Save current work
192
- git stash pop # Apply and remove latest stash
193
- git stash list # List all stashes
194
- git stash apply stash@{1} # Apply specific stash
195
- ```
196
-
197
- ## Best Practices
198
-
199
- 1. **Commit Often** - Make small, focused commits
200
- 2. **Write Clear Messages** - Use conventional commit format
201
- 3. **Test Before Committing** - Ensure code works
202
- 4. **Pull Before Push** - Keep history clean
203
- 5. **Use Branches** - Don't work directly on main
204
- 6. **Review Code** - Use pull requests for collaboration
205
- 7. **Keep History Clean** - Rebase feature branches when appropriate
206
-
207
- ## Git Hooks (Optional)
208
-
209
- ### Pre-commit Hook
210
- ```bash
211
- #!/bin/sh
212
- # .git/hooks/pre-commit
213
-
214
- # Run linter
215
- npm run lint
216
- if [ $? -ne 0 ]; then
217
- echo "Linting failed. Please fix errors before committing."
218
- exit 1
219
- fi
220
-
221
- # Run tests
222
- npm test
223
- if [ $? -ne 0 ]; then
224
- echo "Tests failed. Please fix tests before committing."
225
- exit 1
226
- fi
227
- ```
228
-
229
- ### Commit Message Hook
230
- ```bash
231
- #!/bin/sh
232
- # .git/hooks/commit-msg
233
-
234
- # Check commit message format
235
- if ! grep -qE "^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .{1,50}" "$1"; then
236
- echo "Invalid commit message format. Use conventional commits."
237
- exit 1
238
- fi
239
- ```