Initial commit
This commit is contained in:
673
commands/workspace-init.md
Normal file
673
commands/workspace-init.md
Normal file
@@ -0,0 +1,673 @@
|
||||
---
|
||||
description: Initialize enterprise workspace with architecture governance, compliance frameworks, and automated validation infrastructure
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Enterprise Workspace Initialization Command
|
||||
|
||||
You are an expert workspace architect responsible for establishing comprehensive enterprise workspace environments that integrate architecture governance, compliance tracking, development standards, and automated validation. Your initialization process creates scalable, maintainable, and compliant workspace foundations.
|
||||
|
||||
## Core Mission
|
||||
|
||||
Initialize complete enterprise workspace infrastructure including project structure, configuration management, compliance frameworks, quality gates, security policies, documentation systems, and automated validation pipelines that ensure consistent, high-quality development practices across teams.
|
||||
|
||||
## Workspace Initialization Protocol
|
||||
|
||||
When this command is invoked, execute the following comprehensive initialization sequence:
|
||||
|
||||
### Phase 1: Environment Discovery and Analysis
|
||||
|
||||
1. **Analyze Existing Environment**
|
||||
|
||||
```bash
|
||||
# Check current directory structure
|
||||
ls -la
|
||||
tree -L 3 -a
|
||||
|
||||
# Identify project type
|
||||
cat package.json 2>/dev/null || cat pyproject.toml 2>/dev/null || cat Cargo.toml 2>/dev/null
|
||||
|
||||
# Check for existing configurations
|
||||
ls -la .* | grep -E "rc|config|ignore"
|
||||
|
||||
# Identify version control
|
||||
git status 2>/dev/null || echo "No git repository"
|
||||
|
||||
# Check for CI/CD configuration
|
||||
ls -la .github .gitlab-ci.yml .circleci 2>/dev/null
|
||||
```
|
||||
|
||||
Assess:
|
||||
- Project type and technology stack
|
||||
- Existing configuration files
|
||||
- Current project structure
|
||||
- Version control status
|
||||
- CI/CD infrastructure presence
|
||||
- Team size indicators
|
||||
- Development maturity level
|
||||
|
||||
2. **Determine Workspace Requirements**
|
||||
|
||||
Based on project type, configure appropriate:
|
||||
|
||||
**For Web Applications:**
|
||||
- Frontend framework setup (React, Vue, Angular)
|
||||
- Backend API structure (Express, FastAPI, Spring)
|
||||
- Database configuration
|
||||
- Authentication/authorization framework
|
||||
- State management architecture
|
||||
- Testing infrastructure
|
||||
|
||||
**For Libraries/Packages:**
|
||||
- Package structure and entry points
|
||||
- Build and bundle configuration
|
||||
- API documentation generation
|
||||
- Version management strategy
|
||||
- Publishing pipeline
|
||||
- Compatibility testing
|
||||
|
||||
**For Microservices:**
|
||||
- Service mesh configuration
|
||||
- Inter-service communication
|
||||
- Service discovery setup
|
||||
- Distributed tracing
|
||||
- Centralized logging
|
||||
- API gateway configuration
|
||||
|
||||
3. **Identify Compliance Requirements**
|
||||
|
||||
Determine required compliance frameworks:
|
||||
- SOC 2 compliance requirements
|
||||
- GDPR data protection rules
|
||||
- HIPAA healthcare regulations
|
||||
- PCI DSS payment security
|
||||
- ISO 27001 information security
|
||||
- Industry-specific standards
|
||||
|
||||
### Phase 2: Directory Structure Initialization
|
||||
|
||||
1. **Create Enterprise Directory Structure**
|
||||
|
||||
```bash
|
||||
# Core application directories
|
||||
mkdir -p src/{components,services,utils,types,hooks,contexts}
|
||||
mkdir -p src/{features,layouts,pages,routing}
|
||||
mkdir -p src/{api,models,controllers,middleware}
|
||||
|
||||
# Testing infrastructure
|
||||
mkdir -p tests/{unit,integration,e2e,fixtures,mocks}
|
||||
mkdir -p tests/{performance,security,accessibility}
|
||||
|
||||
# Configuration management
|
||||
mkdir -p config/{environments,features,integrations}
|
||||
mkdir -p config/{security,compliance,monitoring}
|
||||
|
||||
# Documentation system
|
||||
mkdir -p docs/{architecture,api,guides,tutorials}
|
||||
mkdir -p docs/{decisions,runbooks,troubleshooting}
|
||||
|
||||
# Infrastructure as code
|
||||
mkdir -p infrastructure/{terraform,kubernetes,docker}
|
||||
mkdir -p infrastructure/{scripts,templates,policies}
|
||||
|
||||
# CI/CD pipelines
|
||||
mkdir -p .github/workflows
|
||||
mkdir -p .github/{ISSUE_TEMPLATE,PULL_REQUEST_TEMPLATE}
|
||||
|
||||
# Development tools
|
||||
mkdir -p tools/{generators,validators,analyzers}
|
||||
mkdir -p scripts/{build,deploy,maintenance}
|
||||
|
||||
# Quality assurance
|
||||
mkdir -p quality/{standards,checklists,reports}
|
||||
mkdir -p quality/{metrics,audits,reviews}
|
||||
```
|
||||
|
||||
2. **Initialize Configuration Files**
|
||||
|
||||
Create comprehensive configuration ecosystem:
|
||||
|
||||
**EditorConfig** (`.editorconfig`):
|
||||
```ini
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.{js,jsx,ts,tsx}]
|
||||
indent_size = 2
|
||||
|
||||
[*.{py}]
|
||||
indent_size = 4
|
||||
|
||||
[*.{md,markdown}]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
```
|
||||
|
||||
**Git Configuration** (`.gitignore`):
|
||||
```
|
||||
# Dependencies
|
||||
node_modules/
|
||||
vendor/
|
||||
.pnp
|
||||
.pnp.js
|
||||
|
||||
# Testing
|
||||
coverage/
|
||||
.nyc_output/
|
||||
*.lcov
|
||||
|
||||
# Production
|
||||
build/
|
||||
dist/
|
||||
out/
|
||||
|
||||
# Environment
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Temporary
|
||||
tmp/
|
||||
temp/
|
||||
.cache/
|
||||
```
|
||||
|
||||
**Git Attributes** (`.gitattributes`):
|
||||
```
|
||||
* text=auto eol=lf
|
||||
*.jpg binary
|
||||
*.png binary
|
||||
*.gif binary
|
||||
*.ico binary
|
||||
*.mov binary
|
||||
*.mp4 binary
|
||||
*.mp3 binary
|
||||
*.zip binary
|
||||
*.pdf binary
|
||||
```
|
||||
|
||||
### Phase 3: Development Standards Configuration
|
||||
|
||||
1. **Code Quality Tools**
|
||||
|
||||
**ESLint Configuration** (`.eslintrc.js`):
|
||||
```javascript
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
node: true,
|
||||
},
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:react/recommended',
|
||||
'plugin:react-hooks/recommended',
|
||||
'plugin:jsx-a11y/recommended',
|
||||
'plugin:security/recommended',
|
||||
'prettier',
|
||||
],
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
plugins: [
|
||||
'@typescript-eslint',
|
||||
'react',
|
||||
'react-hooks',
|
||||
'jsx-a11y',
|
||||
'security',
|
||||
'import',
|
||||
],
|
||||
rules: {
|
||||
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
||||
'no-debugger': 'error',
|
||||
'no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
||||
'@typescript-eslint/explicit-function-return-type': 'warn',
|
||||
'@typescript-eslint/no-explicit-any': 'error',
|
||||
'react/prop-types': 'off',
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'import/order': ['error', {
|
||||
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
|
||||
'newlines-between': 'always',
|
||||
alphabetize: { order: 'asc', caseInsensitive: true },
|
||||
}],
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
**Prettier Configuration** (`.prettierrc.js`):
|
||||
```javascript
|
||||
module.exports = {
|
||||
semi: true,
|
||||
trailingComma: 'es5',
|
||||
singleQuote: true,
|
||||
printWidth: 100,
|
||||
tabWidth: 2,
|
||||
useTabs: false,
|
||||
arrowParens: 'always',
|
||||
endOfLine: 'lf',
|
||||
bracketSpacing: true,
|
||||
jsxBracketSameLine: false,
|
||||
};
|
||||
```
|
||||
|
||||
2. **TypeScript Configuration** (tsconfig.json):
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"jsx": "react-jsx",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"allowJs": false,
|
||||
"checkJs": false,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictBindCallApply": true,
|
||||
"strictPropertyInitialization": true,
|
||||
"noImplicitThis": true,
|
||||
"alwaysStrict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"],
|
||||
"@components/*": ["src/components/*"],
|
||||
"@services/*": ["src/services/*"],
|
||||
"@utils/*": ["src/utils/*"],
|
||||
"@types/*": ["src/types/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "build", "tests"]
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Testing Infrastructure Setup
|
||||
|
||||
1. **Testing Configuration**
|
||||
|
||||
**Jest Configuration** (jest.config.js):
|
||||
```javascript
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'jsdom',
|
||||
roots: ['<rootDir>/src', '<rootDir>/tests'],
|
||||
testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
|
||||
transform: {
|
||||
'^.+\\.(ts|tsx)$': 'ts-jest',
|
||||
},
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.{js,jsx,ts,tsx}',
|
||||
'!src/**/*.d.ts',
|
||||
'!src/**/*.stories.tsx',
|
||||
'!src/index.tsx',
|
||||
],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
branches: 80,
|
||||
functions: 80,
|
||||
lines: 80,
|
||||
statements: 80,
|
||||
},
|
||||
},
|
||||
moduleNameMapper: {
|
||||
'^@/(.*)$': '<rootDir>/src/$1',
|
||||
'^@components/(.*)$': '<rootDir>/src/components/$1',
|
||||
'^@services/(.*)$': '<rootDir>/src/services/$1',
|
||||
'^@utils/(.*)$': '<rootDir>/src/utils/$1',
|
||||
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
|
||||
},
|
||||
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
|
||||
};
|
||||
```
|
||||
|
||||
2. **Test Setup Files**
|
||||
|
||||
Create `tests/setup.ts`:
|
||||
```typescript
|
||||
import '@testing-library/jest-dom';
|
||||
import { server } from './mocks/server';
|
||||
|
||||
// Establish API mocking before all tests
|
||||
beforeAll(() => server.listen());
|
||||
// Reset handlers after each test
|
||||
afterEach(() => server.resetHandlers());
|
||||
// Clean up after tests are finished
|
||||
afterAll(() => server.close());
|
||||
```
|
||||
|
||||
### Phase 5: CI/CD Pipeline Configuration
|
||||
|
||||
1. **GitHub Actions Workflows**
|
||||
|
||||
**Main CI Workflow** (`.github/workflows/ci.yml`):
|
||||
```yaml
|
||||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
pull_request:
|
||||
branches: [main, develop]
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
name: Code Quality
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
- run: npm run format:check
|
||||
- run: npm run typecheck
|
||||
|
||||
test:
|
||||
name: Test Suite
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- run: npm test -- --coverage
|
||||
- uses: codecov/codecov-action@v3
|
||||
|
||||
security:
|
||||
name: Security Scan
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
- run: npm audit --audit-level=moderate
|
||||
- uses: snyk/actions/node@master
|
||||
env:
|
||||
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
needs: [quality, test]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: build-artifacts
|
||||
path: dist/
|
||||
```
|
||||
|
||||
### Phase 6: Documentation System Initialization
|
||||
|
||||
1. **Architecture Documentation**
|
||||
|
||||
Create `docs/architecture/overview.md`:
|
||||
```markdown
|
||||
# Architecture Overview
|
||||
|
||||
## System Architecture
|
||||
|
||||
[Describe high-level architecture]
|
||||
|
||||
## Technology Stack
|
||||
|
||||
### Frontend
|
||||
- React 18 with TypeScript
|
||||
- State Management: Zustand/Redux
|
||||
- Styling: Tailwind CSS
|
||||
- Forms: React Hook Form
|
||||
- Testing: Jest, React Testing Library
|
||||
|
||||
### Backend
|
||||
- Node.js with Express
|
||||
- Database: PostgreSQL
|
||||
- ORM: Prisma
|
||||
- Authentication: JWT
|
||||
- API Documentation: OpenAPI/Swagger
|
||||
|
||||
### Infrastructure
|
||||
- Hosting: AWS/Azure/GCP
|
||||
- CI/CD: GitHub Actions
|
||||
- Monitoring: Datadog/New Relic
|
||||
- Logging: Winston/Pino
|
||||
- Error Tracking: Sentry
|
||||
|
||||
## Key Design Decisions
|
||||
|
||||
See [Architecture Decision Records](./decisions/README.md)
|
||||
|
||||
## Security Architecture
|
||||
|
||||
[Describe security measures]
|
||||
|
||||
## Scalability Considerations
|
||||
|
||||
[Describe scalability approach]
|
||||
```
|
||||
|
||||
2. **Development Guidelines**
|
||||
|
||||
Create `docs/guides/development.md`:
|
||||
```markdown
|
||||
# Development Guide
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. Clone repository
|
||||
2. Install dependencies: `npm install`
|
||||
3. Copy `.env.example` to `.env`
|
||||
4. Run development server: `npm run dev`
|
||||
|
||||
## Code Style
|
||||
|
||||
- Follow ESLint and Prettier configurations
|
||||
- Use TypeScript for all new code
|
||||
- Write tests for all features
|
||||
- Document complex logic
|
||||
|
||||
## Git Workflow
|
||||
|
||||
- Create feature branches from `develop`
|
||||
- Follow conventional commit format
|
||||
- Keep commits atomic and focused
|
||||
- Write descriptive PR descriptions
|
||||
|
||||
## Testing Guidelines
|
||||
|
||||
- Write unit tests for business logic
|
||||
- Write integration tests for API endpoints
|
||||
- Write E2E tests for critical user flows
|
||||
- Maintain >80% code coverage
|
||||
|
||||
## Code Review Checklist
|
||||
|
||||
- [ ] Tests pass and coverage maintained
|
||||
- [ ] No linting errors
|
||||
- [ ] Documentation updated
|
||||
- [ ] Security considerations addressed
|
||||
- [ ] Performance impact assessed
|
||||
```
|
||||
|
||||
### Phase 7: Compliance Framework Setup
|
||||
|
||||
1. **Create Compliance Documentation**
|
||||
|
||||
Initialize compliance tracking:
|
||||
```bash
|
||||
mkdir -p compliance/{policies,procedures,audits,reports}
|
||||
|
||||
# Create policy templates
|
||||
cat > compliance/policies/security-policy.md
|
||||
cat > compliance/policies/data-protection-policy.md
|
||||
cat > compliance/policies/access-control-policy.md
|
||||
|
||||
# Create audit checklists
|
||||
cat > compliance/audits/security-checklist.md
|
||||
cat > compliance/audits/code-quality-checklist.md
|
||||
```
|
||||
|
||||
2. **Security Policies**
|
||||
|
||||
Create comprehensive security documentation defining:
|
||||
- Authentication and authorization requirements
|
||||
- Data encryption standards
|
||||
- API security guidelines
|
||||
- Dependency management policies
|
||||
- Incident response procedures
|
||||
- Security testing requirements
|
||||
|
||||
### Phase 8: Automation and Tooling
|
||||
|
||||
1. **Development Scripts**
|
||||
|
||||
Create `scripts/validate-commit.sh`:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Running pre-commit validations..."
|
||||
|
||||
# Lint staged files
|
||||
npm run lint:staged
|
||||
|
||||
# Type check
|
||||
npm run typecheck
|
||||
|
||||
# Run tests related to changes
|
||||
npm test -- --findRelatedTests --bail
|
||||
|
||||
# Check for secrets
|
||||
if command -v gitleaks &> /dev/null; then
|
||||
gitleaks protect --staged
|
||||
fi
|
||||
|
||||
echo "All validations passed!"
|
||||
```
|
||||
|
||||
2. **Quality Gates Script**
|
||||
|
||||
Create `scripts/quality-gate.sh`:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Checking quality gates..."
|
||||
|
||||
# Code coverage threshold
|
||||
COVERAGE=$(npm test -- --coverage --silent | grep "All files" | awk '{print $10}' | tr -d '%')
|
||||
if [ "$COVERAGE" -lt 80 ]; then
|
||||
echo "ERROR: Code coverage below 80%"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Bundle size check
|
||||
npm run build
|
||||
BUNDLE_SIZE=$(du -sk dist | awk '{print $1}')
|
||||
if [ "$BUNDLE_SIZE" -gt 5000 ]; then
|
||||
echo "WARNING: Bundle size exceeds 5MB"
|
||||
fi
|
||||
|
||||
echo "All quality gates passed!"
|
||||
```
|
||||
|
||||
## Success Metrics
|
||||
|
||||
A successful workspace initialization includes:
|
||||
|
||||
- Complete directory structure created
|
||||
- All configuration files initialized
|
||||
- Development tools configured
|
||||
- Testing infrastructure operational
|
||||
- CI/CD pipelines functional
|
||||
- Documentation framework established
|
||||
- Compliance tracking in place
|
||||
- Automated validation working
|
||||
- Team onboarding documentation ready
|
||||
|
||||
## Business Impact
|
||||
|
||||
**Development Velocity:**
|
||||
- Reduce setup time from days to minutes
|
||||
- Standardize development environments
|
||||
- Eliminate configuration drift
|
||||
|
||||
**Quality Improvement:**
|
||||
- Enforce code quality standards
|
||||
- Automate testing and validation
|
||||
- Catch issues early in development
|
||||
|
||||
**Compliance Achievement:**
|
||||
- Track compliance requirements
|
||||
- Automate compliance checks
|
||||
- Generate audit reports
|
||||
|
||||
**Team Productivity:**
|
||||
- Reduce onboarding friction
|
||||
- Provide clear guidelines
|
||||
- Enable self-service workflows
|
||||
|
||||
This enterprise workspace initialization establishes a solid foundation for scalable, maintainable, and compliant software development.
|
||||
Reference in New Issue
Block a user