GitLab Stack Creator by rknall/claude-skills
npx skills add https://github.com/rknall/claude-skills --skill 'GitLab Stack Creator'为创建新的 GitLab 堆栈项目提供专家级协助,包括正确的结构、git 配置、验证脚本和全面的文档。
此技能应在以下情况触发:
此技能遵循 GitLab 堆栈管理模式:
仅当满足以下所有条件时,才认为堆栈创建完成:
:使用变通方法。如果直接方法无效,并询问用户下一步该怎么做。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
询问用户:
绝不假设 - 如果信息缺失,始终询问。
在创建任何内容之前:
创建标准目录结构:
project-name/
├── .git/ # Git 仓库
│ ├── hooks/ # Git 钩子(验证脚本)
│ └── config # Git 配置
├── config/ # 服务配置
│ ├── nginx/ # Nginx 配置(如需要)
│ ├── postgres/ # PostgreSQL 配置(如需要)
│ └── redis/ # Redis 配置(如需要)
├── secrets/ # Docker 密钥文件
│ └── .gitkeep # 在 git 中保留目录
├── _temporary/ # 临时文件(git 忽略)
├── scripts/ # 验证和实用脚本
│ ├── pre-commit # 提交前验证钩子
│ ├── validate-stack.sh # 完整堆栈验证
│ └── setup-hooks.sh # 钩子安装脚本
├── docs/ # 项目文档
│ ├── decisions/ # 架构决策记录
│ ├── setup.md # 设置说明
│ └── services.md # 服务文档
├── docker-compose.yml # 主 compose 文件
├── .env.example # 环境模板
├── .gitignore # Git 排除项
├── .dockerignore # Docker 排除项
├── CLAUDE.md # Claude Code 说明
└── README.md # 项目概述
操作:
mkdir -p config secrets _temporary scripts docs/decisionstouch secrets/.gitkeepchmod 700 secrets如果不存在 git 仓库:
git init 初始化git config init.defaultBranch main如果提供了远程仓库 URL:
git clone <url> <project-name>git remote add origin <url>git remote -v如果设置失败:停止并询问用户寻求指导。绝不尝试变通方法。
设置必需的 git 配置:
# 设置 main 为分支名称
git config init.defaultBranch main
# 设置仅快进合并策略
git config pull.ff only
git config merge.ff only
# 确保默认不进行变基
git config pull.rebase false
# 如果未全局设置,则设置用户信息
git config user.name "User Name"
git config user.email "user@example.com"
如果配置失败:请用户手动设置配置或提供正确的值。
生成全面的 .gitignore:
# 密钥 - 绝不提交
secrets/*
!secrets/.gitkeep
*.key
*.pem
*.crt
*.p12
*.pfx
# 环境文件
.env
.env.local
.env.*.local
# 临时文件
_temporary/
*.tmp
*.temp
.cache/
# Docker
.docker/
# IDE
.vscode/
.idea/
*.swp
*.swo
*~
# 操作系统
.DS_Store
Thumbs.db
*.log
# 备份文件
*.bak
*.backup
生成 .dockerignore:
.git
.gitignore
README.md
docs/
_temporary/
*.md
.env
.env.example
secrets/
.vscode/
.idea/
生成全面的验证脚本,该脚本:
模板:
#!/usr/bin/env bash
set -euo pipefail
echo "=== GitLab Stack Validation ==="
echo
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
ERRORS=0
echo "1. Validating stack structure..."
if ! claude-code-cli run stack-validator; then
echo -e "${RED}✗ Stack validation failed${NC}"
((ERRORS++))
else
echo -e "${GREEN}✓ Stack validation passed${NC}"
fi
echo
echo "2. Validating secrets configuration..."
if ! claude-code-cli run secrets-manager --validate; then
echo -e "${RED}✗ Secrets validation failed${NC}"
((ERRORS++))
else
echo -e "${GREEN}✓ Secrets validation passed${NC}"
fi
echo
echo "3. Validating Docker configuration..."
if ! claude-code-cli run docker-validation; then
echo -e "${RED}✗ Docker validation failed${NC}"
((ERRORS++))
else
echo -e "${GREEN}✓ Docker validation passed${NC}"
fi
echo
if [ $ERRORS -gt 0 ]; then
echo -e "${RED}Validation failed with $ERRORS error(s)${NC}"
exit 1
fi
echo -e "${GREEN}All validations passed!${NC}"
exit 0
使其可执行:chmod +x scripts/validate-stack.sh
生成提交前钩子:
#!/usr/bin/env bash
set -euo pipefail
echo "Running pre-commit validation..."
# Check for secrets in staged files
if git diff --cached --name-only | grep -qE "secrets/.*[^.gitkeep]|\.env$"; then
echo "ERROR: Attempting to commit secrets or .env file!"
echo "Secrets should never be committed to git."
exit 1
fi
# Check for root-owned files
if find . -user root -not -path "./.git/*" 2>/dev/null | grep -q .; then
echo "ERROR: Root-owned files detected!"
echo "All files should be owned by the user running Docker."
exit 1
fi
# Run quick validation (if available)
if [ -x "./scripts/validate-stack.sh" ]; then
echo "Running stack validation..."
if ! ./scripts/validate-stack.sh; then
echo "ERROR: Stack validation failed!"
echo "Fix issues before committing, or use 'git commit --no-verify' to skip."
exit 1
fi
fi
echo "Pre-commit validation passed!"
exit 0
使其可执行:chmod +x scripts/pre-commit
生成钩子安装脚本:
#!/usr/bin/env bash
set -euo pipefail
echo "Installing git hooks..."
# Check if .git directory exists
if [ ! -d ".git" ]; then
echo "ERROR: Not a git repository!"
exit 1
fi
# Install pre-commit hook
if [ -f "scripts/pre-commit" ]; then
cp scripts/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
echo "✓ Installed pre-commit hook"
else
echo "✗ scripts/pre-commit not found"
exit 1
fi
echo "Git hooks installed successfully!"
使其可执行:chmod +x scripts/setup-hooks.sh
创建脚本后:运行 ./scripts/setup-hooks.sh 以安装钩子。
根据用户需求生成初始的 docker-compose.yml:
重要提示:使用 docker-validation 技能确保 docker-compose.yml 遵循所有最佳实践。
基本模板结构:
services:
# Services will be added based on requirements
# Example: nginx service
nginx:
image: nginx:alpine
container_name: ${PROJECT_NAME:-project}_nginx
restart: unless-stopped
ports:
- "${NGINX_PORT:-80}:80"
volumes:
- ./config/nginx:/etc/nginx/conf.d:ro
networks:
- app-network
networks:
app-network:
driver: bridge
# Secrets will be defined here when needed
secrets: {}
# Volumes for persistent data
volumes: {}
操作:
生成环境模板:
# Project Configuration
PROJECT_NAME=myproject
# Service Ports
NGINX_PORT=80
# Add more as needed
# Database Configuration (if applicable)
# POSTGRES_PORT=5432
# REDIS_PORT=6379
# IMPORTANT: Copy this file to .env and configure for your environment
# .env is gitignored and should contain actual secrets
使用 config-generator 技能创建特定于服务的配置文件:
操作:
示例调用:
使用 secrets-manager 技能设置密钥:
操作:
示例调用:
生成设置文档:
# Setup Instructions
## Prerequisites
- Docker Engine 20.10+
- Docker Compose V2
- Git
## Initial Setup
1. Clone the repository:
```bash
git clone <repository-url>
cd <project-name>
复制环境模板:
cp .env.example .env
配置环境:
设置密钥:
docker secret create安装 git 钩子:
./scripts/setup-hooks.sh
验证堆栈:
./scripts/validate-stack.sh
启动服务:
docker compose up -d
部署前始终运行验证:
./scripts/validate-stack.sh
此检查包括:
记录所有服务:
# Services Documentation
## Service Overview
| Service | Port | Purpose | Configuration |
|---------|------|---------|---------------|
| nginx | 80 | Web server | ./config/nginx |
| ... | ... | ... | ... |
## Service Details
### Nginx
**Image**: nginx:alpine
**Purpose**: Web server and reverse proxy
**Configuration**: ./config/nginx/
**Secrets**: None
**Volumes**:
- ./config/nginx:/etc/nginx/conf.d:ro
### [Other Services]
Document each service similarly...
创建架构决策记录:
# 1. Stack Architecture
**Date**: YYYY-MM-DD
## Status
Accepted
## Context
This project uses GitLab Stack Management patterns to ensure:
- Consistent configuration management
- Secure secrets handling
- Proper file ownership
- Validated deployments
## Decision
We will follow these principles:
1. All configuration in docker-compose.yml and ./config
2. All secrets in ./secrets and Docker secrets
3. docker-entrypoint.sh only when necessary
4. No root-owned files
5. ./_temporary for transient files
6. Complete validation before deployment
## Consequences
**Positive**:
- Consistent structure across all stacks
- Automated validation prevents issues
- Secure by default
- Easy to maintain and update
**Negative**:
- Initial setup requires more steps
- Must follow strict patterns
- Validation gates can slow rapid iteration
## Compliance
- stack-validator: Ensures structure compliance
- secrets-manager: Ensures secure secrets
- docker-validation: Ensures Docker best practices
为项目生成 Claude Code 说明:
# CLAUDE.md
This file provides guidance to Claude Code when working with this stack project.
## Project Structure
This is a GitLab Stack project following strict patterns:
- Configuration: docker-compose.yml and ./config/
- Secrets: ./secrets/ and Docker secrets
- Temporary: ./_temporary/ (gitignored)
- Documentation: ./docs/
- Validation: ./scripts/
## Required Skills
This project uses these Claude Code skills:
- **stack-validator**: Validate entire stack structure
- **secrets-manager**: Manage Docker secrets securely
- **docker-validation**: Validate Docker configurations
- **config-generator**: Generate service configs
## Git Configuration
**Branch**: main
**Merge Strategy**: ff-only (fast-forward only)
**Hooks**: Pre-commit validation enabled
## Validation Requirements
BEFORE any git commit, ALL these must pass:
1. stack-validator reports NO issues
2. secrets-manager is satisfied
3. docker-validation is satisfied
4. No root-owned files exist
5. No secrets in .env or docker-compose.yml environment
## Making Changes
### Adding a Service
1. Update docker-compose.yml
2. Use config-generator to create configs
3. Use secrets-manager to handle secrets
4. Run ./scripts/validate-stack.sh
5. Fix ALL issues before committing
6. NEVER commit if validation fails
### Modifying Configuration
1. Edit configuration files
2. Validate with docker-validation
3. Run ./scripts/validate-stack.sh
4. Fix ALL issues before committing
### Working with Secrets
1. Use secrets-manager for ALL secret operations
2. NEVER put secrets in .env or docker-compose.yml
3. Use Docker secrets or ./secrets/ directory
4. Validate with secrets-manager before committing
## Commit Standards
**Pre-commit Hook**: Automatically validates before commit
**Skip Hook**: `git commit --no-verify` (emergency only)
**Commit Messages**: Use conventional commits format
Example:
feat: add Redis service with persistence fix: correct nginx proxy configuration docs: update setup instructions
## Important Rules
1. NEVER commit secrets to git
2. NEVER create root-owned files
3. NEVER skip validation without asking
4. NEVER use workarounds - ask user instead
5. ALWAYS run validation before committing
6. ALWAYS document decisions in ./docs/decisions/
7. ALWAYS use ff-only merge strategy
8. ALWAYS use main as branch name
## Troubleshooting
### Validation Fails
1. Review validation output
2. Use respective skill to investigate (stack-validator, secrets-manager, docker-validation)
3. Fix reported issues
4. Re-run validation
5. Ask user if stuck - NEVER use workarounds
### Git Conflicts
1. NEVER use rebase without explicit permission
2. Use ff-only merges
3. Ask user how to resolve conflicts
### Permission Issues
1. Check file ownership: `find . -user root`
2. Fix with: `sudo chown -R $USER:$USER .`
3. Validate with stack-validator
## Resources
- Stack Validator Documentation
- Secrets Manager Documentation
- Docker Validation Documentation
- Config Generator Documentation
生成项目 README:
# Project Name
Brief description of the project.
## Quick Start
```bash
# Clone repository
git clone <url>
cd <project-name>
# Copy environment template
cp .env.example .env
# Configure environment (edit .env)
nano .env
# Install git hooks
./scripts/setup-hooks.sh
# Validate stack
./scripts/validate-stack.sh
# Start services
docker compose up -d
.
├── config/ # Service configurations
├── secrets/ # Docker secrets (gitignored except .gitkeep)
├── _temporary/ # Temporary files (gitignored)
├── scripts/ # Validation and utility scripts
├── docs/ # Project documentation
└── docker-compose.yml
This project uses automated validation:
# Full validation
./scripts/validate-stack.sh
# Pre-commit validation (automatic)
git commit -m "message"
Validation checks:
Branch : main Merge Strategy : ff-only (fast-forward only) Pre-commit Hook : Enabled (validates before commit)
| Service | Port | Purpose |
|---|---|---|
| ... | ... | ... |
See Services Documentation for details.
./scripts/validate-stack.sh./scripts/validate-stack.shRun individual validators:
claude-code-cli run stack-validatorclaude-code-cli run secrets-manager --validateclaude-code-cli run docker-validationCheck for root-owned files:
find . -user root -not -path "./.git/*"
Fix ownership:
sudo chown -R $USER:$USER .
[Your License]
[Your Contact Info]
### 阶段 9:最终验证
#### 9.1 运行完整验证
执行完整的验证工作流程:
```bash
# 运行验证脚本
./scripts/validate-stack.sh
这必须检查:
手动验证:
仅当满足以下条件时,才将堆栈创建标记为完成:
如果任何验证失败:
一旦所有验证通过:
# 暂存所有文件
git add .
# 提交(提交前钩子将进行验证)
git commit -m "feat: initial stack setup
- Created directory structure
- Configured git with main branch and ff-only
- Set up validation scripts and hooks
- Generated docker-compose.yml
- Created service configurations
- Set up secrets management
- Added comprehensive documentation"
# 推送到远程(如果已配置)
git push -u origin main
如果由于提交前钩子导致提交失败:
创建堆栈时:
请勿:
请:
请勿:
请:
请勿:
请:
User: "Create a new stack for a web application with nginx"
Assistant: "I'll create a new web stack with nginx. Let me gather some information first."
**Questions**:
1. "What's the project name?"
User: "mywebapp"
2. "Do you have a remote git repository URL?"
User: "https://gitlab.com/user/mywebapp.git"
3. "What environment is this for?"
User: "production"
**Actions**:
1. Create directory structure
2. Initialize git and connect to remote
3. Configure git (main branch, ff-only)
4. Create docker-compose.yml with nginx
5. Use docker-validation to validate
6. Use config-generator to create nginx config
7. Create validation scripts
8. Install git hooks
9. Generate all documentation
10. Run full validation
11. Report status
**Completion**:
"Stack creation complete! All validations passed:
✓ stack-validator: NO issues
✓ secrets-manager: NO issues (no secrets needed)
✓ docker-validation: NO issues
Next steps:
1. Review generated files
2. Customize .env from .env.example
3. Run: docker compose up -d"
User: "Create a stack with nginx, PostgreSQL, and Redis"
Assistant: "I'll create a full application stack. Let me gather information."
**Questions**:
1. "Project name?" → "myapp"
2. "Remote repository?" → "Yes, https://gitlab.com/user/myapp.git"
3. "Environment?" → "production"
**Actions**:
1. Create directory structure with config/{nginx,postgres,redis}
2. Initialize git, connect remote, configure (main, ff-only)
3. Create docker-compose.yml with all three services
4. Validate with docker-validation
5. Use config-generator for each service:
- nginx production config
- PostgreSQL production config
- Redis production config
6. Use secrets-manager for:
- PostgreSQL password
- Redis password
- Create Docker secrets
7. Create validation scripts and install hooks
8. Generate all documentation
9. Run full validation (stack-validator, secrets-manager, docker-validation)
10. Initial commit
**Completion**:
"Stack creation complete! All validations passed:
✓ stack-validator: NO issues
✓ secrets-manager: All secrets properly configured
✓ docker-validation: NO issues
Services configured:
- nginx (port 80)
- PostgreSQL (port 5432, password in Docker secret)
- Redis (port 6379, password in Docker secret)
Next steps:
1. Review secrets in ./secrets/
2. Customize .env from .env.example
3. Run: docker compose up -d"
stack-creator 技能:
堆栈创建仅当所有三个验证器通过且无问题且所有文档就位时才完成。
每周安装次数
–
仓库
GitHub 星标数
33
首次出现时间
–
安全审计
Expert assistance for creating new GitLab stack projects with proper structure, git configuration, validation scripts, and comprehensive documentation.
This skill should be triggered when:
This skill follows the GitLab Stack Management patterns:
A stack creation is considered COMPLETE only when:
IMPORTANT : NEVER use workarounds. If the direct approach is not working, STOP and ask the user what to do instead.
Ask the user:
NEVER assume - always ask if information is missing.
Before creating anything:
Create the standard directory structure:
project-name/
├── .git/ # Git repository
│ ├── hooks/ # Git hooks (validation scripts)
│ └── config # Git configuration
├── config/ # Service configurations
│ ├── nginx/ # Nginx configs (if needed)
│ ├── postgres/ # PostgreSQL configs (if needed)
│ └── redis/ # Redis configs (if needed)
├── secrets/ # Docker secrets files
│ └── .gitkeep # Keep directory in git
├── _temporary/ # Temporary files (gitignored)
├── scripts/ # Validation and utility scripts
│ ├── pre-commit # Pre-commit validation hook
│ ├── validate-stack.sh # Full stack validation
│ └── setup-hooks.sh # Hook installation script
├── docs/ # Project documentation
│ ├── decisions/ # Architecture decision records
│ ├── setup.md # Setup instructions
│ └── services.md # Service documentation
├── docker-compose.yml # Main compose file
├── .env.example # Environment template
├── .gitignore # Git exclusions
├── .dockerignore # Docker exclusions
├── CLAUDE.md # Claude Code instructions
└── README.md # Project overview
Actions :
mkdir -p config secrets _temporary scripts docs/decisionstouch secrets/.gitkeepchmod 700 secretsIf NO git repository exists :
git initgit config init.defaultBranch mainIf remote repository URL provided :
git clone <url> <project-name>git remote add origin <url>git remote -vIf setup fails : STOP and ask user for guidance. NEVER attempt workarounds.
Set required git configuration:
# Set main as branch name
git config init.defaultBranch main
# Set ff-only merge strategy
git config pull.ff only
git config merge.ff only
# Ensure no rebase by default
git config pull.rebase false
# Set user info if not set globally
git config user.name "User Name"
git config user.email "user@example.com"
If configuration fails : Ask user to set configuration manually or provide correct values.
Generate comprehensive .gitignore:
# Secrets - NEVER commit
secrets/*
!secrets/.gitkeep
*.key
*.pem
*.crt
*.p12
*.pfx
# Environment files
.env
.env.local
.env.*.local
# Temporary files
_temporary/
*.tmp
*.temp
.cache/
# Docker
.docker/
# IDE
.vscode/
.idea/
*.swp
*.swo
*~
# OS
.DS_Store
Thumbs.db
*.log
# Backup files
*.bak
*.backup
Generate .dockerignore:
.git
.gitignore
README.md
docs/
_temporary/
*.md
.env
.env.example
secrets/
.vscode/
.idea/
Generate comprehensive validation script that:
Template :
#!/usr/bin/env bash
set -euo pipefail
echo "=== GitLab Stack Validation ==="
echo
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
ERRORS=0
echo "1. Validating stack structure..."
if ! claude-code-cli run stack-validator; then
echo -e "${RED}✗ Stack validation failed${NC}"
((ERRORS++))
else
echo -e "${GREEN}✓ Stack validation passed${NC}"
fi
echo
echo "2. Validating secrets configuration..."
if ! claude-code-cli run secrets-manager --validate; then
echo -e "${RED}✗ Secrets validation failed${NC}"
((ERRORS++))
else
echo -e "${GREEN}✓ Secrets validation passed${NC}"
fi
echo
echo "3. Validating Docker configuration..."
if ! claude-code-cli run docker-validation; then
echo -e "${RED}✗ Docker validation failed${NC}"
((ERRORS++))
else
echo -e "${GREEN}✓ Docker validation passed${NC}"
fi
echo
if [ $ERRORS -gt 0 ]; then
echo -e "${RED}Validation failed with $ERRORS error(s)${NC}"
exit 1
fi
echo -e "${GREEN}All validations passed!${NC}"
exit 0
Make executable: chmod +x scripts/validate-stack.sh
Generate pre-commit hook:
#!/usr/bin/env bash
set -euo pipefail
echo "Running pre-commit validation..."
# Check for secrets in staged files
if git diff --cached --name-only | grep -qE "secrets/.*[^.gitkeep]|\.env$"; then
echo "ERROR: Attempting to commit secrets or .env file!"
echo "Secrets should never be committed to git."
exit 1
fi
# Check for root-owned files
if find . -user root -not -path "./.git/*" 2>/dev/null | grep -q .; then
echo "ERROR: Root-owned files detected!"
echo "All files should be owned by the user running Docker."
exit 1
fi
# Run quick validation (if available)
if [ -x "./scripts/validate-stack.sh" ]; then
echo "Running stack validation..."
if ! ./scripts/validate-stack.sh; then
echo "ERROR: Stack validation failed!"
echo "Fix issues before committing, or use 'git commit --no-verify' to skip."
exit 1
fi
fi
echo "Pre-commit validation passed!"
exit 0
Make executable: chmod +x scripts/pre-commit
Generate hook installation script:
#!/usr/bin/env bash
set -euo pipefail
echo "Installing git hooks..."
# Check if .git directory exists
if [ ! -d ".git" ]; then
echo "ERROR: Not a git repository!"
exit 1
fi
# Install pre-commit hook
if [ -f "scripts/pre-commit" ]; then
cp scripts/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
echo "✓ Installed pre-commit hook"
else
echo "✗ scripts/pre-commit not found"
exit 1
fi
echo "Git hooks installed successfully!"
Make executable: chmod +x scripts/setup-hooks.sh
After creating scripts : Run ./scripts/setup-hooks.sh to install hooks.
Generate initial docker-compose.yml based on user requirements:
IMPORTANT : Use the docker-validation skill to ensure the docker-compose.yml follows all best practices.
Basic template structure:
services:
# Services will be added based on requirements
# Example: nginx service
nginx:
image: nginx:alpine
container_name: ${PROJECT_NAME:-project}_nginx
restart: unless-stopped
ports:
- "${NGINX_PORT:-80}:80"
volumes:
- ./config/nginx:/etc/nginx/conf.d:ro
networks:
- app-network
networks:
app-network:
driver: bridge
# Secrets will be defined here when needed
secrets: {}
# Volumes for persistent data
volumes: {}
Actions :
Generate environment template:
# Project Configuration
PROJECT_NAME=myproject
# Service Ports
NGINX_PORT=80
# Add more as needed
# Database Configuration (if applicable)
# POSTGRES_PORT=5432
# REDIS_PORT=6379
# IMPORTANT: Copy this file to .env and configure for your environment
# .env is gitignored and should contain actual secrets
Use the config-generator skill to create service-specific configuration files:
Actions :
Example invocation :
Use the secrets-manager skill to set up secrets:
Actions :
Example invocation :
Generate setup documentation:
# Setup Instructions
## Prerequisites
- Docker Engine 20.10+
- Docker Compose V2
- Git
## Initial Setup
1. Clone the repository:
```bash
git clone <repository-url>
cd <project-name>
2. Copy environment template:
cp .env.example .env
3. Configure environment:
* Edit .env with your settings
* NEVER commit .env to git
4. Set up secrets:
* Follow secrets/README.md for secret creation
* Use `docker secret create` for each secret
5. Install git hooks:
./scripts/setup-hooks.sh
6. Validate stack:
./scripts/validate-stack.sh
7. Start services:
docker compose up -d
Always run validation before deploying:
./scripts/validate-stack.sh
This checks:
Stack structure
Secrets configuration
Docker configuration
File ownership
Git exclusions
Document all services:
# Services Documentation
## Service Overview
| Service | Port | Purpose | Configuration |
|---------|------|---------|---------------|
| nginx | 80 | Web server | ./config/nginx |
| ... | ... | ... | ... |
## Service Details
### Nginx
**Image**: nginx:alpine
**Purpose**: Web server and reverse proxy
**Configuration**: ./config/nginx/
**Secrets**: None
**Volumes**:
- ./config/nginx:/etc/nginx/conf.d:ro
### [Other Services]
Document each service similarly...
Create architecture decision record:
# 1. Stack Architecture
**Date**: YYYY-MM-DD
## Status
Accepted
## Context
This project uses GitLab Stack Management patterns to ensure:
- Consistent configuration management
- Secure secrets handling
- Proper file ownership
- Validated deployments
## Decision
We will follow these principles:
1. All configuration in docker-compose.yml and ./config
2. All secrets in ./secrets and Docker secrets
3. docker-entrypoint.sh only when necessary
4. No root-owned files
5. ./_temporary for transient files
6. Complete validation before deployment
## Consequences
**Positive**:
- Consistent structure across all stacks
- Automated validation prevents issues
- Secure by default
- Easy to maintain and update
**Negative**:
- Initial setup requires more steps
- Must follow strict patterns
- Validation gates can slow rapid iteration
## Compliance
- stack-validator: Ensures structure compliance
- secrets-manager: Ensures secure secrets
- docker-validation: Ensures Docker best practices
Generate Claude Code instructions for the project:
# CLAUDE.md
This file provides guidance to Claude Code when working with this stack project.
## Project Structure
This is a GitLab Stack project following strict patterns:
- Configuration: docker-compose.yml and ./config/
- Secrets: ./secrets/ and Docker secrets
- Temporary: ./_temporary/ (gitignored)
- Documentation: ./docs/
- Validation: ./scripts/
## Required Skills
This project uses these Claude Code skills:
- **stack-validator**: Validate entire stack structure
- **secrets-manager**: Manage Docker secrets securely
- **docker-validation**: Validate Docker configurations
- **config-generator**: Generate service configs
## Git Configuration
**Branch**: main
**Merge Strategy**: ff-only (fast-forward only)
**Hooks**: Pre-commit validation enabled
## Validation Requirements
BEFORE any git commit, ALL these must pass:
1. stack-validator reports NO issues
2. secrets-manager is satisfied
3. docker-validation is satisfied
4. No root-owned files exist
5. No secrets in .env or docker-compose.yml environment
## Making Changes
### Adding a Service
1. Update docker-compose.yml
2. Use config-generator to create configs
3. Use secrets-manager to handle secrets
4. Run ./scripts/validate-stack.sh
5. Fix ALL issues before committing
6. NEVER commit if validation fails
### Modifying Configuration
1. Edit configuration files
2. Validate with docker-validation
3. Run ./scripts/validate-stack.sh
4. Fix ALL issues before committing
### Working with Secrets
1. Use secrets-manager for ALL secret operations
2. NEVER put secrets in .env or docker-compose.yml
3. Use Docker secrets or ./secrets/ directory
4. Validate with secrets-manager before committing
## Commit Standards
**Pre-commit Hook**: Automatically validates before commit
**Skip Hook**: `git commit --no-verify` (emergency only)
**Commit Messages**: Use conventional commits format
Example:
feat: add Redis service with persistence fix: correct nginx proxy configuration docs: update setup instructions
## Important Rules
1. NEVER commit secrets to git
2. NEVER create root-owned files
3. NEVER skip validation without asking
4. NEVER use workarounds - ask user instead
5. ALWAYS run validation before committing
6. ALWAYS document decisions in ./docs/decisions/
7. ALWAYS use ff-only merge strategy
8. ALWAYS use main as branch name
## Troubleshooting
### Validation Fails
1. Review validation output
2. Use respective skill to investigate (stack-validator, secrets-manager, docker-validation)
3. Fix reported issues
4. Re-run validation
5. Ask user if stuck - NEVER use workarounds
### Git Conflicts
1. NEVER use rebase without explicit permission
2. Use ff-only merges
3. Ask user how to resolve conflicts
### Permission Issues
1. Check file ownership: `find . -user root`
2. Fix with: `sudo chown -R $USER:$USER .`
3. Validate with stack-validator
## Resources
- Stack Validator Documentation
- Secrets Manager Documentation
- Docker Validation Documentation
- Config Generator Documentation
Generate project README:
# Project Name
Brief description of the project.
## Quick Start
```bash
# Clone repository
git clone <url>
cd <project-name>
# Copy environment template
cp .env.example .env
# Configure environment (edit .env)
nano .env
# Install git hooks
./scripts/setup-hooks.sh
# Validate stack
./scripts/validate-stack.sh
# Start services
docker compose up -d
.
├── config/ # Service configurations
├── secrets/ # Docker secrets (gitignored except .gitkeep)
├── _temporary/ # Temporary files (gitignored)
├── scripts/ # Validation and utility scripts
├── docs/ # Project documentation
└── docker-compose.yml
This project uses automated validation:
# Full validation
./scripts/validate-stack.sh
# Pre-commit validation (automatic)
git commit -m "message"
Validation checks:
Branch : main Merge Strategy : ff-only (fast-forward only) Pre-commit Hook : Enabled (validates before commit)
| Service | Port | Purpose |
|---|---|---|
| ... | ... | ... |
See Services Documentation for details.
./scripts/validate-stack.sh./scripts/validate-stack.shRun individual validators:
claude-code-cli run stack-validatorclaude-code-cli run secrets-manager --validateclaude-code-cli run docker-validationCheck for root-owned files:
find . -user root -not -path "./.git/*"
Fix ownership:
sudo chown -R $USER:$USER .
[Your License]
[Your Contact Info]
### Phase 9: Final Validation
#### 9.1 Run Complete Validation
Execute full validation workflow:
```bash
# Run validation script
./scripts/validate-stack.sh
This must check:
Manually verify:
ONLY mark stack creation as complete when:
If ANY validation fails:
Once all validation passes:
# Stage all files
git add .
# Commit (pre-commit hook will validate)
git commit -m "feat: initial stack setup
- Created directory structure
- Configured git with main branch and ff-only
- Set up validation scripts and hooks
- Generated docker-compose.yml
- Created service configurations
- Set up secrets management
- Added comprehensive documentation"
# Push to remote (if configured)
git push -u origin main
If commit fails due to pre-commit hook:
When creating a stack:
DO NOT :
DO :
DO NOT :
DO :
DO NOT :
DO :
User: "Create a new stack for a web application with nginx"
Assistant: "I'll create a new web stack with nginx. Let me gather some information first."
**Questions**:
1. "What's the project name?"
User: "mywebapp"
2. "Do you have a remote git repository URL?"
User: "https://gitlab.com/user/mywebapp.git"
3. "What environment is this for?"
User: "production"
**Actions**:
1. Create directory structure
2. Initialize git and connect to remote
3. Configure git (main branch, ff-only)
4. Create docker-compose.yml with nginx
5. Use docker-validation to validate
6. Use config-generator to create nginx config
7. Create validation scripts
8. Install git hooks
9. Generate all documentation
10. Run full validation
11. Report status
**Completion**:
"Stack creation complete! All validations passed:
✓ stack-validator: NO issues
✓ secrets-manager: NO issues (no secrets needed)
✓ docker-validation: NO issues
Next steps:
1. Review generated files
2. Customize .env from .env.example
3. Run: docker compose up -d"
User: "Create a stack with nginx, PostgreSQL, and Redis"
Assistant: "I'll create a full application stack. Let me gather information."
**Questions**:
1. "Project name?" → "myapp"
2. "Remote repository?" → "Yes, https://gitlab.com/user/myapp.git"
3. "Environment?" → "production"
**Actions**:
1. Create directory structure with config/{nginx,postgres,redis}
2. Initialize git, connect remote, configure (main, ff-only)
3. Create docker-compose.yml with all three services
4. Validate with docker-validation
5. Use config-generator for each service:
- nginx production config
- PostgreSQL production config
- Redis production config
6. Use secrets-manager for:
- PostgreSQL password
- Redis password
- Create Docker secrets
7. Create validation scripts and install hooks
8. Generate all documentation
9. Run full validation (stack-validator, secrets-manager, docker-validation)
10. Initial commit
**Completion**:
"Stack creation complete! All validations passed:
✓ stack-validator: NO issues
✓ secrets-manager: All secrets properly configured
✓ docker-validation: NO issues
Services configured:
- nginx (port 80)
- PostgreSQL (port 5432, password in Docker secret)
- Redis (port 6379, password in Docker secret)
Next steps:
1. Review secrets in ./secrets/
2. Customize .env from .env.example
3. Run: docker compose up -d"
The stack-creator skill:
Stack creation is complete ONLY when all three validators pass with NO issues and all documentation is in place.
Weekly Installs
–
Repository
GitHub Stars
33
First Seen
–
Security Audits
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
147,400 周安装