11---
22name : code-review
3- description : Automated PR review using comprehensive checklist tailored for Contentstack CLI plugins
3+ description : Automated PR review using comprehensive checklist tailored for modularized Contentstack CLI
44---
55
66# Code Review Command
@@ -10,24 +10,24 @@ description: Automated PR review using comprehensive checklist tailored for Cont
1010### Scope-Based Reviews
1111- ` /code-review ` - Review all current changes with full checklist
1212- ` /code-review --scope typescript ` - Focus on TypeScript configuration and patterns
13- - ` /code-review --scope testing ` - Focus on Mocha/Chai/Sinon test patterns
14- - ` /code-review --scope contentstack ` - Focus on API integration and CLI patterns
13+ - ` /code-review --scope testing ` - Focus on Mocha/Chai test patterns
1514- ` /code-review --scope oclif ` - Focus on command structure and OCLIF patterns
15+ - ` /code-review --scope packages ` - Focus on package structure and organization
1616
1717### Severity Filtering
1818- ` /code-review --severity critical ` - Show only critical issues (security, breaking changes)
1919- ` /code-review --severity high ` - Show high and critical issues
2020- ` /code-review --severity all ` - Show all issues including suggestions
2121
2222### Package-Aware Reviews
23- - ` /code-review --package contentstack-import ` - Review changes in specific package
24- - ` /code-review --package-type plugin ` - Review plugin packages only
25- - ` /code-review --package-type library ` - Review library packages (e.g., variants )
23+ - ` /code-review --package contentstack-config ` - Review changes in specific package
24+ - ` /code-review --package-type plugin ` - Review plugin packages only (auth, config)
25+ - ` /code-review --package-type library ` - Review library packages (command, utilities, dev-dependencies )
2626
2727### File Type Focus
2828- ` /code-review --files commands ` - Review command files only
2929- ` /code-review --files tests ` - Review test files only
30- - ` /code-review --files modules ` - Review import/export modules
30+ - ` /code-review --files utils ` - Review utility files
3131
3232## Comprehensive Review Checklist
3333
@@ -36,87 +36,119 @@ description: Automated PR review using comprehensive checklist tailored for Cont
3636- ** pnpm workspace** : Correct ` package.json ` workspace configuration
3737- ** Build artifacts** : No ` lib/ ` directories committed to version control
3838- ** Dependencies** : Proper use of shared utilities (` @contentstack/cli-command ` , ` @contentstack/cli-utilities ` )
39+ - ** Scripts** : Consistent build, test, and lint scripts across packages
3940
40- ### TypeScript Standards (Repository-Specific)
41- - ** Configuration compliance** : Follows package-specific TypeScript config
41+ ### Package-Specific Structure
42+ - ** Plugin packages** (auth, config): Have ` oclif.commands ` configuration
43+ - ** Library packages** (command, utilities, dev-dependencies): Proper exports in package.json
44+ - ** Main package** (contentstack): Aggregates plugins correctly
45+ - ** Dependency versions** : Using beta versions appropriately (~ version ranges)
46+
47+ ### TypeScript Standards
48+ - ** Configuration compliance** : Follows package TypeScript config (` strict: false ` , ` target: es2017 ` )
4249- ** Naming conventions** : kebab-case files, PascalCase classes, camelCase functions
43- - ** Type safety** : Appropriate use of strict mode vs relaxed settings per package
4450- ** Import patterns** : ES modules with proper default/named exports
45- - ** Migration strategy ** : Proper use of ` @ts-ignore ` during gradual migration
51+ - ** Type safety ** : No unnecessary ` any ` types in production code
4652
47- ### OCLIF Command Patterns (Actual Implementation)
48- - ** Base class usage** : Extends ` @contentstack/cli-command ` (not ` @oclif/core ` )
49- - ** Command structure** : Proper ` static description ` , ` examples ` , ` flags `
50- - ** Topic organization** : Uses ` cm ` topic structure (` cm:stacks:import ` )
53+ ### OCLIF Command Patterns
54+ - ** Base class usage** : Extends ` @contentstack/cli-command ` Command
55+ - ** Command structure** : Proper ` static description ` , ` static examples` , ` static flags`
56+ - ** Topic organization** : Uses ` cm ` topic structure (` cm:config:set ` , ` cm:auth:login ` )
5157- ** Error handling** : Uses ` handleAndLogError ` from utilities
52- - ** Validation ** : Early flag validation and user-friendly error messages
58+ - ** Flag validation ** : Early validation and user-friendly error messages
5359- ** Service delegation** : Commands orchestrate, services implement business logic
5460
55- ### Testing Excellence (Mocha/Chai/Sinon Stack)
56- - ** Framework compliance** : Uses Mocha + Chai + Sinon (not Jest)
57- - ** File patterns** : Follows ` *.test.ts ` naming (or ` *.test.js ` for bootstrap)
58- - ** Directory structure** : Proper placement in ` test/unit/ ` , ` test/lib/ ` , etc.
59- - ** Mock patterns** : Proper Sinon stubbing of SDK methods
60- - ** Coverage configuration** : Correct nyc setup (watch for ` inlcude ` typo)
61- - ** Test isolation** : Proper ` beforeEach ` /` afterEach ` with ` sinon.restore() `
61+ ### Testing Excellence (Mocha/Chai Stack)
62+ - ** Framework compliance** : Uses Mocha + Chai (not Jest)
63+ - ** File patterns** : Follows ` *.test.ts ` naming convention
64+ - ** Directory structure** : Proper placement in ` test/unit/ `
65+ - ** Test organization** : Arrange-Act-Assert pattern consistently used
66+ - ** Isolation** : Proper setup/teardown with beforeEach/afterEach
6267- ** No real API calls** : All external dependencies properly mocked
6368
64- ### Contentstack API Integration (Real Patterns)
65- - ** SDK usage** : Proper ` managementSDKClient ` and fluent API chaining
66- - ** Authentication** : Correct ` configHandler ` and token alias handling
67- - ** Rate limiting compliance** :
68- - Batch spacing (minimum 1 second between batches)
69- - 429 retry handling with exponential backoff
70- - Pagination throttling for variants
71- - ** Error handling** : Proper ` handleAndLogError ` usage and user-friendly messages
72- - ** Configuration** : Proper regional endpoint and management token handling
73-
74- ### Import/Export Module Architecture
75- - ** BaseClass extension** : Proper inheritance from import/export BaseClass
76- - ** Batch processing** : Correct use of ` makeConcurrentCall ` and ` logMsgAndWaitIfRequired `
77- - ** Module organization** : Proper entity-specific module structure
78- - ** Configuration handling** : Proper ` ModuleClassParams ` usage
79- - ** Progress feedback** : Appropriate user feedback during long operations
69+ ### Error Handling Standards
70+ - ** Consistent patterns** : Use ` handleAndLogError ` from utilities
71+ - ** User-friendly messages** : Clear error descriptions for end users
72+ - ** Logging** : Proper use of ` log.debug ` for diagnostic information
73+ - ** Status messages** : Use ` cliux ` for user feedback (success, error, info)
74+
75+ ### Build and Compilation
76+ - ** TypeScript compilation** : Clean compilation with no errors
77+ - ** OCLIF manifest** : Generated for command discovery
78+ - ** README generation** : Commands documented in package README
79+ - ** Source maps** : Properly configured for debugging
80+ - ** No build artifacts in commit** : ` .gitignore ` excludes ` lib/ ` directories
81+
82+ ### Testing Coverage
83+ - ** Test structure** : Tests in ` test/unit/ ` with descriptive names
84+ - ** Command testing** : Uses @oclif/test for command validation
85+ - ** Error scenarios** : Tests for both success and failure paths
86+ - ** Mocking** : All dependencies properly mocked
87+
88+ ### Package.json Compliance
89+ - ** Correct metadata** : name, description, version, author
90+ - ** Script definitions** : build, compile, test, lint scripts present
91+ - ** Dependencies** : Correct versions of shared packages
92+ - ** Main/types** : Properly configured for library packages
93+ - ** OCLIF config** : Present for plugin packages
8094
8195### Security and Best Practices
82- - ** Token security ** : No API keys or tokens logged or committed
96+ - ** No secrets ** : No API keys or tokens in code or tests
8397- ** Input validation** : Proper validation of user inputs and flags
84- - ** Error exposure** : No sensitive information in error messages
85- - ** File permissions** : Proper handling of file system operations
86- - ** Process management** : Appropriate use of ` process.exit(1) ` for critical failures
87-
88- ### Performance Considerations
89- - ** Concurrent processing** : Proper use of ` Promise.allSettled ` for batch operations
90- - ** Memory management** : Appropriate handling of large datasets
91- - ** Rate limiting** : Compliance with Contentstack API limits (10 req/sec)
92- - ** Batch sizing** : Appropriate batch sizes for different operations
93- - ** Progress tracking** : Efficient progress reporting without performance impact
94-
95- ### Package-Specific Patterns
96- - ** Plugin vs Library** : Correct ` oclif.commands ` configuration for plugin packages
97- - ** Command compilation** : Proper build pipeline (` tsc ` → ` lib/commands ` → ` oclif manifest ` )
98- - ** Dependency management** : Correct use of shared vs package-specific dependencies
99- - ** Test variations** : Handles different test patterns per package (JS vs TS, different structures)
98+ - ** Process management** : Appropriate use of error codes
99+ - ** File operations** : Safe handling of file system operations
100+
101+ ### Code Quality
102+ - ** Naming consistency** : Follow established conventions
103+ - ** Comments** : Only for non-obvious logic (no "narration" comments)
104+ - ** Error messages** : Clear, actionable messages for users
105+ - ** Module organization** : Proper separation of concerns
100106
101107## Review Execution
102108
103109### Automated Checks
104- 1 . ** Lint compliance** : ESLint and TypeScript compiler checks
105- 2 . ** Test coverage ** : nyc coverage thresholds (where enforced)
106- 3 . ** Build verification ** : Successful compilation to ` lib/ ` directories
107- 4 . ** Dependency audit ** : No security vulnerabilities in dependencies
110+ 1 . ** Lint compliance** : ESLint checks for code style
111+ 2 . ** TypeScript compiler ** : Successful compilation to ` lib/ ` directories
112+ 3 . ** Test execution ** : All tests pass successfully
113+ 4 . ** Build verification ** : Build scripts complete without errors
108114
109115### Manual Review Focus Areas
110- 1 . ** API integration patterns ** : Verify proper SDK usage and error handling
111- 2 . ** Rate limiting implementation ** : Check for proper throttling mechanisms
112- 3 . ** Test quality** : Verify comprehensive mocking and error scenario coverage
113- 4 . ** Command usability ** : Ensure clear help text and examples
114- 5 . ** Monorepo consistency ** : Check for consistent patterns across packages
116+ 1 . ** Command usability ** : Clear help text and realistic examples
117+ 2 . ** Error handling ** : Appropriate error messages and recovery options
118+ 3 . ** Test quality** : Comprehensive test coverage for critical paths
119+ 4 . ** Monorepo consistency ** : Consistent patterns across all packages
120+ 5 . ** Flag design ** : Intuitive flag names and combinations
115121
116122### Common Issues to Flag
117- - ** Coverage config typos** : ` "inlcude" ` instead of ` "include" ` in ` .nycrc.json `
118- - ** Inconsistent TypeScript** : Mixed strict mode usage without migration plan
119- - ** Real API calls in tests** : Any unmocked external dependencies
120- - ** Missing rate limiting** : API calls without proper throttling
121- - ** Build artifacts committed** : Any ` lib/ ` directories in version control
122- - ** Inconsistent error handling** : Not using utilities error handling patterns
123+ - ** Inconsistent TypeScript settings** : Mixed strict mode without reason
124+ - ** Real API calls in tests** : Unmocked external dependencies
125+ - ** Missing error handling** : Commands that fail silently
126+ - ** Poor test organization** : Tests without clear Arrange-Act-Assert
127+ - ** Build artifacts committed** : ` lib/ ` directories in version control
128+ - ** Unclear error messages** : Non-actionable error descriptions
129+ - ** Inconsistent flag naming** : Similar flags with different names
130+ - ** Missing command examples** : Examples not showing actual usage
131+
132+ ## Repository-Specific Checklist
133+
134+ ### For Modularized CLI
135+ - [ ] Command properly extends ` @contentstack/cli-command ` Command
136+ - [ ] Flags defined with proper types from ` @contentstack/cli-utilities `
137+ - [ ] Error handling uses ` handleAndLogError ` utility
138+ - [ ] User feedback uses ` cliux ` utilities
139+ - [ ] Tests use Mocha + Chai pattern with mocked dependencies
140+ - [ ] Package.json has correct scripts (build, compile, test, lint)
141+ - [ ] TypeScript compiles with no errors
142+ - [ ] Tests pass: ` pnpm test `
143+ - [ ] No ` .only ` or ` .skip ` in test files
144+ - [ ] Build succeeds: ` pnpm run build `
145+ - [ ] OCLIF manifest generated successfully
146+
147+ ### Before Merge
148+ - [ ] All review items addressed
149+ - [ ] No build artifacts in commit
150+ - [ ] Tests added for new functionality
151+ - [ ] Documentation updated if needed
152+ - [ ] No console.log() statements (use log.debug instead)
153+ - [ ] Error messages are user-friendly
154+ - [ ] No secrets or credentials in code
0 commit comments