Przejdź do głównej zawartości

Przepływy automatyzacji: potoki rozwoju oparte na AI

Możliwości AI Cursor wykraczają daleko poza interaktywne kodowanie. Ten przewodnik pokazuje, jak budować zaawansowane przepływy automatyzacji wykorzystujące AI do ciągłego rozwoju, testowania i konserwacji.

graph TB subgraph "Wyzwalacze" Git[Haki Git] Schedule[Zadania Cron] Watch[Obserwatory plików] API[Webhooki API] end subgraph "Automatyzacja Cursor" Agent[Agent w tle] CLI[Cursor CLI] SDK[Cursor SDK] MCP[Serwery MCP] end subgraph "Akcje" Code[Generowanie kodu] Test[Tworzenie testów] Review[Przegląd kodu] Fix[Naprawy błędów] Docs[Dokumentacja] end Git --> Agent Schedule --> CLI Watch --> SDK API --> MCP Agent --> Code Agent --> Test CLI --> Review SDK --> Fix MCP --> Docs style Agent fill:#f9f,stroke:#333,stroke-width:2px style MCP fill:#bbf,stroke:#333,stroke-width:2px
~/.cursor/mcp.json
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "your-github-token"
}
},
"gitlab": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-gitlab"],
"env": {
"GITLAB_TOKEN": "your-gitlab-token",
"GITLAB_URL": "https://gitlab.com"
}
},
"jenkins": {
"command": "npx",
"args": ["-y", "jenkins-mcp-server"],
"env": {
"JENKINS_URL": "https://jenkins.company.com",
"JENKINS_USER": "your-username",
"JENKINS_TOKEN": "your-api-token"
}
},
"terraform": {
"command": "npx",
"args": ["-y", "terraform-mcp"],
"env": {
"TF_WORKSPACE": "production"
}
},
"kubernetes": {
"command": "npx",
"args": ["-y", "kubernetes-mcp-server"],
"env": {
"KUBECONFIG": "~/.kube/config"
}
}
}
}
"Używając GitHub MCP, zautomatyzuj nasze CI/CD:
1. Uzyskaj status uruchomienia przepływu pracy dla głównej gałęzi
2. Wyzwól przepływ pracy wdrożenia, jeśli testy przeszły
3. Stwórz wydanie z dziennikiem zmian
4. Zaktualizuj problem śledzenia wdrożenia"
// Zaawansowana orkiestracja przepływu pracy
"Używając GitHub MCP:
- Sprawdź, czy kontrole PR #123 przeszły
- Jeśli tak, automatycznie połącz ze squash
- Wyzwól wdrożenie produkcyjne
- Monitoruj status wdrożenia
- Cofnij, jeśli kontrole zdrowia nie powiodą się"
// Orkiestracja Terraform + Kubernetes
"Koordynuj wdrożenie infrastruktury:
1. Używając Terraform MCP:
- Zaplanuj zmiany infrastruktury
- Pokaż mi, co zostanie utworzone/zmodyfikowane
- Zastosuj zmiany po zatwierdzeniu
2. Używając Kubernetes MCP:
- Wdróż nową wersję aplikacji
- Monitoruj zdrowie podów
- Skaluj na podstawie obciążenia
- Zaktualizuj reguły ingress"
// Kompletny przykład automatyzacji
"Zautomatyzuj pełne wdrożenie:
1. GitHub MCP: Uzyskaj najnowszy tag wydania
2. Jenkins MCP: Zbuduj obraz Docker
3. Terraform MCP: Zaktualizuj infrastrukturę
4. Kubernetes MCP: Wdróż nową wersję
5. Slack MCP: Powiadom zespół o wdrożeniu"
// Automatyczne zarządzanie problemami
"Używając Linear MCP i GitHub MCP razem:
- Gdy PR zostanie połączone z main
- Znajdź powiązane problemy Linear
- Przenieś problemy do statusu 'Done'
- Dodaj datę wdrożenia
- Połącz z URL produkcyjnym"
// Automatyzacja bezpieczeństwa
"Automatyzacja skanowania bezpieczeństwa:
1. GitHub MCP: Uzyskaj zmienione pliki
2. Uruchom skanowanie bezpieczeństwa na zmianach
3. Jeśli znaleziono luki:
- Stwórz problem GitHub
- Przypisz do zespołu bezpieczeństwa
- Zablokuj wdrożenie
- Zaproponuj naprawy"

Agenty w tle to pracownicy AI działający w chmurze, działający w izolowanych maszynach wirtualnych Ubuntu, pozwalający:

  • Wykonywać wiele zadań rozwojowych równolegle
  • Pracować na różnych gałęziach jednocześnie
  • Automatyzować powtarzalne przepływy pracy
  • Utrzymywać produktywność, podczas gdy agenty obsługują rutynowe zadania

Stwórz .cursor/environment.json w swoim repozytorium:

{
"snapshot": "POPULATED_FROM_SETTINGS",
"install": "npm ci",
"start": "sudo service docker start",
"terminals": [
{
"name": "Dev Server",
"command": "npm run dev"
},
{
"name": "Test Runner",
"command": "npm run test:watch"
}
],
"secrets": {
"DATABASE_URL": "${DATABASE_URL}",
"API_KEY": "${API_KEY}"
}
}

Dla złożonych środowisk użyj niestandardowego Dockerfile:

# .cursor/Dockerfile
FROM ubuntu:22.04
# Zależności systemowe
RUN apt-get update && apt-get install -y \
build-essential \
python3.11 \
python3-pip \
nodejs \
npm \
postgresql-client \
redis-tools
# Środowisko Python
RUN pip3 install --upgrade pip
RUN pip3 install pytest black flake8 mypy
# Środowisko Node
RUN npm install -g typescript@latest \
@nestjs/cli \
nx \
pnpm
# Niestandardowe narzędzia projektowe
COPY requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt
WORKDIR /workspace

Uruchom wielu agentów do pracy nad różnymi funkcjami jednocześnie:

Uruchamianie wielu agentów przez Slack:

# W Slack uruchom wielu agentów do równoległego rozwoju
@Cursor [branch=feature/auth] implement OAuth 2.0 authentication:
- Set up Passport.js with Google/GitHub strategies
- Create login/logout endpoints
- Add session management with Redis
- Implement role-based access control
- Write integration tests
- Update API documentation
@Cursor [branch=feature/payments] add Stripe payment integration:
- Create payment endpoints for subscriptions
- Implement webhook handlers
- Add payment method management
- Create billing dashboard components
- Add comprehensive error handling
- Write unit and integration tests
@Cursor [branch=feature/notifications] build email notification system:
- Set up SendGrid integration
- Create email templates (welcome, password reset, etc.)
- Implement queue system with Bull
- Add user preferences for notifications
- Create unsubscribe mechanism
- Test with different email providers

Monitorowanie przez panel webowy:

  • Przejdź do cursor.com/agents
  • Zobacz wszystkich trzech agentów pracujących równolegle
  • Śledź indywidualny postęp
  • Przejmij dowolnego agenta w razie potrzeby

2. Automatyczne segregowanie i rozwiązywanie błędów

Dział zatytułowany „2. Automatyczne segregowanie i rozwiązywanie błędów”

Przepływ pracy automatycznego rozwiązywania błędów:

  1. Skonfiguruj integrację GitHub do Slack:
.github/workflows/auto-fix-bugs.yml
name: Auto Fix Bugs
on:
issues:
types: [labeled]
jobs:
trigger-fix:
if: github.event.label.name == 'auto-fix'
runs-on: ubuntu-latest
steps:
- name: Send to Slack for Cursor
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: 'cursor-bug-fixes'
slack-message: |
@Cursor fix bug from ${{ github.event.issue.html_url }}
Issue: ${{ github.event.issue.title }}
Description: ${{ github.event.issue.body }}
- Reproduce the issue
- Identify root cause
- Implement fix following patterns
- Add regression tests
- Create PR linked to issue
  1. Ręczne przypisywanie błędów w Slack:
# Bezpośrednio w Slack
@Cursor [repo=myorg/myrepo] fix bug #456
- Check issue description for details
- Follow our bug fix checklist
- Ensure all tests pass
- Link PR to original issue

Przepływ pracy ciągłego testowania i dokumentacji:

  1. GitHub Action do żądania testowania:
.github/workflows/request-tests.yml
name: Request Test Generation
on:
push:
branches: [main, develop]
jobs:
request-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.ts
**/*.js
**/*.tsx
**/*.jsx
- name: Request Tests via Slack
if: steps.changed-files.outputs.any_changed == 'true'
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: 'cursor-testing'
slack-message: |
@Cursor generate tests for recently changed files:
${{ steps.changed-files.outputs.all_changed_files }}
- Write comprehensive unit tests
- Add integration tests where needed
- Cover edge cases
- Achieve >90% coverage
  1. Ręczne żądanie aktualizacji dokumentacji:
# W Slack
@Cursor update documentation based on recent changes
- Check recent commits for new features
- Update API documentation
- Regenerate TypeScript definitions
- Update README if needed
- Add entries to CHANGELOG.md

Jak działają agenty w tle w Slack:

  1. Podstawowa konfiguracja:

    • Dodaj bota Cursor do swojego obszaru roboczego Slack
    • Zaproś @Cursor do odpowiednich kanałów
    • Skonfiguruj ustawienia zespołu za pomocą @Cursor settings
  2. Wyzwalanie agentów:

    # Podstawowe żądanie implementacji
    @Cursor implement the user profile feature
    - Add avatar upload
    - Include bio and social links
    - Make it responsive
    - Write tests
    # Z konkretnymi opcjami
    @Cursor [repo=company/app] [branch=feature/profile] implement user profile
    # Wiele zadań
    @Cursor task 1: Fix the login bug reported in #support
    @Cursor task 2: Add dark mode to settings page
    @Cursor task 3: Update API documentation
  3. Monitorowanie postępu:

    • Bot Cursor publikuje aktualizacje w wątku
    • Każdy agent otrzymuje unikalny URL śledzenia
    • Kliknij URL, aby zobaczyć szczegółowy postęp
    • Link PR publikowany po zakończeniu
  4. Powiadomienia zespołu:

    • Skonfiguruj powiadomienia na poziomie kanału
    • Skonfiguruj, które zdarzenia zgłaszać
    • Używaj wątków, aby organizować dyskusje

Automatyczna cotygodniowa konserwacja przez Slack:

.github/workflows/scheduled-maintenance.yml
name: Weekly Maintenance
on:
schedule:
- cron: '0 2 * * 0' # Niedziela 2:00
jobs:
trigger-maintenance:
runs-on: ubuntu-latest
steps:
- name: Request Dependency Updates
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: 'cursor-maintenance'
slack-message: |
@Cursor update all dependencies
- Check for minor version updates
- Run security audit
- Update lock files
- Run test suite
- Update CHANGELOG.md
- name: Request Code Quality Check
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: 'cursor-maintenance'
slack-message: |
@Cursor improve code quality
- Fix ESLint warnings
- Remove unused imports
- Update deprecated APIs
- Improve TypeScript types
- Add missing JSDoc comments
- name: Request Test Coverage
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: 'cursor-maintenance'
slack-message: |
@Cursor improve test coverage to 95%
- Identify untested code
- Add missing unit tests
- Add integration tests
- Update test descriptions

Ręczne wyzwalanie konserwacji:

# Wyzwól zadania konserwacji ręcznie w Slack
@Cursor perform weekly maintenance
- Update dependencies
- Fix linting issues
- Improve test coverage
- Update documentation
- Clean up technical debt

Orkiestracja wielu agentów przez Slack:

# Faza 1: Uruchom równoległych agentów implementacji
@Cursor [branch=feature/shop-backend] implement backend API for online shop
- Create REST endpoints for products, cart, checkout
- Add database models
- Implement business logic
- Add validation and error handling
@Cursor [branch=feature/shop-frontend] build frontend for online shop
- Create React components for product listing
- Implement shopping cart state management
- Add API integration
- Ensure responsive design
@Cursor [branch=feature/shop-tests] create tests for online shop
- Unit tests for all components
- Integration tests for API
- E2E tests for checkout flow
- Performance tests
# Faza 2: Po zakończeniu przez agentów, integruj
@Cursor [branch=feature/shop-integration] integrate shop components
- Merge backend and frontend branches
- Resolve any conflicts
- Run full integration tests
- Create unified PR

Monitorowanie projektów wielu agentów:

  1. Panel webowy (cursor.com/agents):

    • Zobacz wszystkich agentów w projekcie
    • Zobacz zależności między zadaniami
    • Śledź ogólny postęp
    • Eksportuj raporty statusu
  2. Organizacja wątków Slack:

    • Każda faza we własnym wątku
    • Aktualizacje statusu publikowane automatycznie
    • Linki do indywidualnego postępu agenta
    • Finalne linki PR po zakończeniu

Najlepsze praktyki zarządzania kosztami agentów w tle:

  1. Ocena złożoności zadania:

    • Proste zadania (< $2): Użyj lokalnego trybu Agent w IDE
    • Średnie zadania ($2-8): Użyj agentów w tle z konkretnymi instrukcjami
    • Złożone zadania ($8-15): Podziel na mniejsze podzadania
  2. Strategia wsadowa:

    # Zamiast jednego złożonego żądania:
    @Cursor implement complete e-commerce platform
    # Podziel na mniejsze, skoncentrowane zadania:
    @Cursor implement product catalog API
    @Cursor create shopping cart functionality
    @Cursor add payment processing
    @Cursor build admin dashboard
  3. Zarządzanie budżetem:

    • Ustaw limity wydatków w ustawieniach Cursor
    • Monitoruj użycie na cursor.com/agents
    • Używaj konkretnych, szczegółowych promptów, aby zmniejszyć iteracje
    • Buforuj konfigurację środowiska z migawkami
  4. Efektywna konfiguracja środowiska:

    {
    "snapshot": "cached-node-18",
    "install": "npm ci --prefer-offline",
    "cache": {
    "node_modules": true,
    "build": true
    }
    }
  5. Panel monitorowania kosztów:

    • Śledź dzienne/tygodniowe/miesięczne wydatki
    • Identyfikuj drogie zadania
    • Optymalizuj często używane przepływy pracy
    • Skonfiguruj alerty dla progów budżetowych
.git/hooks/pre-commit
#!/bin/bash
echo "Uruchamiam kontrole przed zatwierdzeniem Cursor AI..."
# 1. Kontrola jakości kodu
cursor lint --ai-enhanced --fix
# 2. Skanowanie bezpieczeństwa
cursor security scan --staged
# 3. Generuj brakujące testy
cursor agent run --task generate-tests --target staged
# 4. Zaktualizuj dokumentację
cursor docs update --auto
# 5. Sprawdź zapachy kodu
cursor analyze --smells --complexity
if [ $? -ne 0 ]; then
echo "Kontrole przed zatwierdzeniem nie powiodły się. Proszę przejrzeć i naprawić problemy."
exit 1
fi
echo "Kontrole przed zatwierdzeniem zakończone sukcesem!"
#!/bin/bash
# post-merge-automation.sh
# Uzyskaj listę połączonych plików
MERGED_FILES=$(git diff --name-only HEAD~1 HEAD)
# 1. Zaktualizuj dokumentację
echo "Aktualizuję dokumentację..."
cursor README.md docs/
# W trybie Agent (Ctrl+I), użyj:
# "Update all documentation based on @Git changes in the recent merge"
# "Include architecture diagrams if structural changes were made"
# 2. Sprawdź zmiany API i wygeneruj testy
if echo "$MERGED_FILES" | grep -q "api/"; then
echo "Wykryto zmiany API, generuję testy integracyjne..."
cursor tests/integration/
# Prompt agenta: "Generate integration tests for the API endpoints modified in @Recent Changes"
fi
# 3. Zaktualizuj dokumentację zależności
cursor package.json docs/dependencies.md
# Prompt agenta: "Update dependency graph documentation based on @Files package.json changes"
# 4. Wygeneruj podsumowanie i powiadom
echo "Automatyzacja po połączeniu ukończona"
# Użyj agenta do stworzenia podsumowania: "Summarize the impact of @Recent Changes for the team"
.github/workflows/ai-code-review.yml
name: Przegląd kodu AI
on:
pull_request:
types: [opened, synchronize]
jobs:
ai-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Przegląd Cursor AI
id: review
run: |
cursor review \
--base ${{ github.base_ref }} \
--head ${{ github.head_ref }} \
--output review.md
- name: Opublikuj komentarz przeglądu
uses: actions/github-script@v6
with:
script: |
const review = fs.readFileSync('review.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: review
});
continuous-test-generation.ts
class ContinuousTestGenerator {
async generateTestsForChanges(changes: FileChange[]) {
const testPlan = await this.createTestPlan(changes);
for (const item of testPlan) {
switch (item.type) {
case 'unit':
await this.generateUnitTests(item);
break;
case 'integration':
await this.generateIntegrationTests(item);
break;
case 'e2e':
await this.generateE2ETests(item);
break;
}
}
// Uruchom wygenerowane testy
const results = await this.runGeneratedTests();
// Dopracuj na podstawie rezultatów
if (results.failures.length > 0) {
await this.refineFailingTests(results.failures);
}
}
# Generuj testy jednostkowe używając agenta Cursor
generateUnitTests() {
local TARGET_FILE=$1
# Otwórz plik w Cursor
cursor "$TARGET_FILE"
# Użyj trybu Agent (Ctrl+I) z tym kompleksowym promptem:
cat << 'EOF'
Generate comprehensive Jest unit tests for @Files following AAA pattern:
- Arrange-Act-Assert structure
- Target 90% statement coverage
- Include edge cases and error scenarios
- Mock external dependencies appropriately
- Use descriptive test names
- Group related tests in describe blocks
Reference @Code to understand all functions and their parameters.
Check @Definitions for type information.
EOF
}
}
scheduled-refactoring.ts
export class ScheduledRefactoring {
async performWeeklyMaintenance() {
const tasks = [
this.removeDeadCode(),
this.updateDeprecatedPatterns(),
this.optimizeImports(),
this.consolidateDuplicates(),
this.improveNaming()
];
const results = await Promise.allSettled(tasks);
// Stwórz PR podsumowania
if (this.hasChanges(results)) {
await this.createMaintenancePR(results);
}
}
# Usuń martwy kod używając Cursor
removeDeadCode() {
echo "Analizuję bazę kodu pod kątem martwego kodu..."
# Użyj agenta Cursor do znalezienia martwego kodu
cursor .
# Prompty agenta do wykrywania martwego kodu:
# "Find unused functions in @Codebase"
# "Identify unreachable code in @Files"
# "Look for unused imports across the project"
# Dla każdego zidentyfikowanego martwego kodu:
# 1. Przejrzyj z: "Verify this code is truly unused by checking @Code references"
# 2. Usuń z: "Remove this unused code and update any related tests"
}
# Zaktualizuj przestarzałe wzorce
updateDeprecatedPatterns() {
# Stwórz plik wzorców
cat > .cursor/deprecated-patterns.md << 'EOF'
# Deprecated Patterns to Update
1. Old: `findOne()` → New: `findFirst()`
2. Old: `callback pattern` → New: `async/await`
3. Old: `require()` → New: `import`
EOF
# Otwórz w Cursor do aktualizacji wzorców
cursor .cursor/deprecated-patterns.md
# Use Agent with prompts like:
# "Find all occurrences of findOne() in @Codebase and suggest updates to findFirst()"
# "Update callback patterns to async/await in @Files"
# "Modernize require statements to ES6 imports across the project"
}
}
auto-documentation.ts
class AutoDocumentation {
async generateComprehensiveDocs() {
// Dokumentacja API
await this.generateApiDocs();
// Diagramy architektury
await this.generateArchitectureDiagrams();
// Przewodniki konfiguracji
await this.updateSetupGuides();
// Przykłady kodu
await this.generateCodeExamples();
}
# Generuj dokumentację API używając Cursor
generateApiDocs() {
# Znajdź wszystkie punkty końcowe API
API_FILES=$(find . -path "*/api/*" -name "*.ts" -o -name "*.js")
for endpoint_file in $API_FILES; do
cursor "$endpoint_file"
# Use Agent mode (Ctrl+I) with these prompts:
# "Generate OpenAPI documentation for the endpoints in @Files"
# "Include request/response examples and error codes"
# "Add authentication requirements and rate limiting info"
# "Create a Postman collection from these endpoints"
done
}
# Generuj diagramy architektury
generateArchitectureDiagrams() {
# Stwórz szablon do analizy architektury
cat > architecture-prompt.md << 'EOF'
Analyze the codebase architecture and create:
1. System overview diagram showing main components
2. Data flow diagram showing how data moves through the system
3. Deployment diagram showing infrastructure setup
4. Sequence diagrams for key user flows
Use @Codebase to understand the project structure
Use @Files in src/ to analyze component relationships
Reference @Docs for existing architecture notes
EOF
cursor architecture-prompt.md docs/architecture/
await this.saveDiagrams(diagrams);
}
}
webhook-automation.ts
export class WebhookAutomation {
async handleWebhook(event: WebhookEvent) {
switch (event.type) {
case 'issue.created':
await this.handleNewIssue(event);
break;
case 'deployment.failed':
await this.handleFailedDeployment(event);
break;
case 'security.vulnerability':
await this.handleSecurityAlert(event);
break;
case 'performance.degradation':
await this.handlePerformanceIssue(event);
break;
}
}
# Obsługuj nowe problemy GitHub za pomocą Cursor
handleNewIssue() {
local ISSUE_NUMBER=$1
local ISSUE_TITLE=$2
local ISSUE_BODY=$3
# Stwórz plik analizy problemu
cat > "issue-${ISSUE_NUMBER}.md" << EOF
# Problem #${ISSUE_NUMBER}: ${ISSUE_TITLE}
## Opis:
${ISSUE_BODY}
## Zadania analizy:
1. Zidentyfikuj główną przyczynę
2. Określ, czy można automatycznie naprawić
3. Zaproponuj podejście implementacyjne
EOF
# Otwórz w Cursor do analizy
cursor "issue-${ISSUE_NUMBER}.md"
# Use Agent mode (Ctrl+I) with prompts:
# "Analyze this issue and determine if it can be fixed automatically"
# "Search @Codebase for related code that might be causing this issue"
# "Check @Recent Changes that might have introduced this problem"
# Jeśli naprawa jest możliwa, stwórz gałąź i implementuj
echo "Tworzę gałąź naprawy..."
git checkout -b "fix/issue-${ISSUE_NUMBER}"
# Use Agent to implement fix:
# "Implement a fix for the issue described based on your analysis"
# "Add tests to prevent this issue from recurring"
# "Update documentation if needed"
}
}
monitoring-automation.ts
class MonitoringAutomation {
private monitors = new Map<string, Monitor>();
async initialize() {
// Monitor jakości kodu
this.monitors.set('quality', new QualityMonitor({
threshold: { complexity: 10, duplication: 5 },
action: this.handleQualityIssue.bind(this)
}));
// Monitor wydajności
this.monitors.set('performance', new PerformanceMonitor({
threshold: { responseTime: 200, cpu: 80 },
action: this.handlePerformanceIssue.bind(this)
}));
// Monitor bezpieczeństwa
this.monitors.set('security', new SecurityMonitor({
scanInterval: '1h',
action: this.handleSecurityIssue.bind(this)
}));
}
# Obsługuj problemy jakości kodu za pomocą Cursor
handleQualityIssue() {
local ISSUE_FILE=$1
local ISSUE_TYPE=$2
# Otwórz problematyczny plik w Cursor
cursor "$ISSUE_FILE"
# Use Agent mode (Ctrl+I) based on issue type:
case $ISSUE_TYPE in
"complexity")
# "Refactor @Files to reduce complexity. Break down large functions."
;;
"duplication")
# "Find and eliminate duplicate code in @Files. Extract common logic."
;;
"performance")
# "Optimize performance bottlenecks in @Files. Focus on loops and queries."
;;
esac
}
}
#!/bin/bash
# scaffold-microservice.sh
# Scaffold microservice with Cursor
scaffoldMicroservice() {
SERVICE_NAME=$1
LANGUAGE=$2
FRAMEWORK=$3
# Stwórz strukturę serwisu
mkdir -p "services/$SERVICE_NAME"/{src,tests,docs,config}
cd "services/$SERVICE_NAME"
# Stwórz instrukcje szkieletowania
cat > .cursor/scaffold-instructions.md << EOF
# Scaffold $SERVICE_NAME Microservice
## Configuration:
- Language: $LANGUAGE
- Framework: $FRAMEWORK
- Service: $SERVICE_NAME
## Generate these files:
### 1. Project Structure
Create standard microservice structure with:
- src/ - Source code
- tests/ - Test files
- docs/ - Documentation
- config/ - Configuration files
### 2. Core Files
- Package/dependency file (package.json, requirements.txt, etc.)
- Main application entry point
- Configuration management
- Health check endpoint
- Example CRUD endpoints
### 3. Testing Setup
- Test framework configuration
- Example unit tests
- Example integration tests
### 4. CI/CD
- Dockerfile
- docker-compose.yml
- GitHub Actions workflow
### 5. Documentation
- README.md with setup instructions
- API documentation template
- Architecture decision records
EOF
# Open in Cursor for scaffolding
cursor .cursor/scaffold-instructions.md
# Use Agent mode (Ctrl+I) with prompts:
# "Create the complete microservice structure as described"
# "Use @Docs to follow our organization's microservice patterns"
# "Reference @Cursor Rules for coding standards and best practices"
# "Include proper error handling and logging throughout"
}
batch-operations.sh
#!/bin/bash
# Perform batch updates across files
performBatchUpdate() {
local PATTERN=$1
local TRANSFORMATION=$2
# Znajdź wszystkie pasujące pliki
FILES=$(find . -name "$PATTERN" -type f)
# Stwórz instrukcje transformacji
cat > batch-transform.md << EOF
# Batch Transformation Instructions
## Pattern: $PATTERN
## Transformation: $TRANSFORMATION
### For each file:
1. Apply the transformation consistently
2. Preserve existing logic and behavior
3. Update related tests if they exist
4. Maintain code style and formatting
### Validation:
- Ensure no syntax errors
- Verify logic is preserved
- Check that tests still pass
EOF
# Process files in batches using Cursor
echo "$FILES" | xargs -n 10 | while read -r batch; do
echo "Processing batch: $batch"
# Stwórz punkt kontrolny, zatwierdzając obecny stan
git add -A && git commit -m "Checkpoint before batch transformation"
# Open files in Cursor
cursor $batch batch-transform.md
# Use Agent mode (Ctrl+I) with prompts:
# "Apply the transformation described to all @Files"
# "Ensure consistency across all files"
# "Update any related test files"
# Waliduj po transformacji
echo "Validating transformations..."
npm test || yarn test || make test
if [ $? -ne 0 ]; then
echo "Validation failed, rolling back..."
git reset --hard HEAD~1
fi
done
}
# Example transformations
# performBatchUpdate "*.js" "Convert CommonJS to ES6 modules"
# performBatchUpdate "*.test.ts" "Update to new testing framework syntax"
# performBatchUpdate "*Controller.ts" "Add proper error handling to all endpoints"
// Using GitHub MCP for advanced automation
"Implement smart PR automation:
1. Monitor all open PRs
2. For each PR:
- Check if reviews are approved
- Verify CI/CD status
- Check for merge conflicts
- Auto-merge if all conditions met
- Update related issues"
// Automated release management
"Create automated release process:
1. Using GitHub MCP:
- Generate changelog from commits
- Create release draft
- Upload build artifacts
- Tag release version
- Trigger deployment workflow"
"Using Kubernetes MCP for deployment automation:
1. Check cluster health
2. Perform rolling update:
- Update deployment image
- Monitor rollout status
- Check pod health
- Verify service endpoints
3. If issues detected:
- Pause rollout
- Collect logs
- Rollback if necessary
- Alert team via Slack MCP"
// Complex automation workflow
class MCPOrchestrator {
async deployWithFullAutomation(version: string) {
// Phase 1: Build and Test
await this.runWithMCP('GitHub MCP: Create release branch');
await this.runWithMCP('Jenkins MCP: Run full test suite');
// Phase 2: Infrastructure
await this.runWithMCP('Terraform MCP: Update infrastructure');
await this.runWithMCP('Kubernetes MCP: Prepare cluster');
// Phase 3: Deploy
await this.runWithMCP('Deploy application version');
await this.runWithMCP('Run health checks');
// Phase 4: Monitor
await this.runWithMCP('Sentry MCP: Check for errors');
await this.runWithMCP('Grafana MCP: Monitor metrics');
// Phase 5: Notify
await this.runWithMCP('Slack MCP: Send deployment summary');
await this.runWithMCP('Linear MCP: Update task status');
}
}
jira-automation.sh
#!/bin/bash
# Sync Jira tickets with development workflow
syncWithJira() {
# Get current sprint tickets using Jira CLI
TICKETS=$(jira list --query "sprint = activeSprint()" --json)
# Process each ticket
echo "$TICKETS" | jq -r '.[] | @base64' | while read -r ticket_data; do
# Decode ticket data
TICKET=$(echo "$ticket_data" | base64 -d)
TICKET_KEY=$(echo "$TICKET" | jq -r '.key')
TICKET_TYPE=$(echo "$TICKET" | jq -r '.fields.issuetype.name')
TICKET_SUMMARY=$(echo "$TICKET" | jq -r '.fields.summary')
# Create feature branch if needed
if ! git branch -r | grep -q "feature/$TICKET_KEY"; then
git checkout -b "feature/$TICKET_KEY"
fi
# Generate boilerplate for stories
if [ "$TICKET_TYPE" = "Story" ]; then
generateStoryBoilerplate "$TICKET_KEY" "$TICKET"
fi
done
}
# Generate story implementation with Cursor
generateStoryBoilerplate() {
local TICKET_KEY=$1
local TICKET_JSON=$2
# Extract ticket details
DESCRIPTION=$(echo "$TICKET_JSON" | jq -r '.fields.description')
ACCEPTANCE_CRITERIA=$(echo "$TICKET_JSON" | jq -r '.fields.customfield_10100')
# Create requirements file
cat > ".cursor/tickets/${TICKET_KEY}-requirements.md" << EOF
# $TICKET_KEY Implementation
## Description
$DESCRIPTION
## Acceptance Criteria
$ACCEPTANCE_CRITERIA
## Implementation Tasks
1. Analyze requirements and create technical design
2. Implement core functionality with tests
3. Add integration tests
4. Update documentation
5. Create PR with detailed description
EOF
# Open in Cursor for implementation
cursor ".cursor/tickets/${TICKET_KEY}-requirements.md" src/
# Use Agent mode (Ctrl+I) with prompts:
# "Analyze the requirements in this ticket and suggest implementation approach"
# "Create the necessary files and folder structure for this feature"
# "Implement the feature following TDD - write tests first"
# "Reference @Docs for our coding patterns and @Cursor Rules for standards"
# Update documentation
cursor docs/features/
# "Update the feature documentation to include $TICKET_KEY implementation"
}
# Example usage:
# ./jira-automation.sh
# This will sync all active sprint tickets and help implement them
parallel-automation.ts
class ParallelAutomation {
private workers: Worker[] = [];
async executeParallel(tasks: AutomationTask[]) {
// Initialize worker pool
const numWorkers = os.cpus().length;
for (let i = 0; i < numWorkers; i++) {
this.workers.push(new Worker('./automation-worker.js'));
}
// Distribute tasks
const taskQueue = [...tasks];
const results = [];
await Promise.all(
this.workers.map(async (worker) => {
while (taskQueue.length > 0) {
const task = taskQueue.shift();
const result = await this.executeTask(worker, task);
results.push(result);
}
})
);
return results;
}
}

Zacznij od małego

Rozpocznij od prostych automatyzacji i stopniowo zwiększaj złożoność

Monitoruj wszystko

Śledź wskaźniki sukcesu automatyzacji i wpływ na wydajność

Eleganckie niepowodzenia

Zawsze uwzględnij mechanizmy wycofania i obsługę błędów

Nadzór ludzki

Zachowaj przegląd ludzki dla krytycznych automatyzacji

Inteligentne łączenie MCP

Kombinuj wiele serwerów MCP dla złożonych przepływów pracy

Obsługuj awarie MCP

Zawsze miej plany awaryjne, gdy serwery MCP są niedostępne

Zabezpiecz poświadczenia MCP

Używaj zmiennych środowiskowych i zarządzania sekretami dla tokenów MCP

Loguj operacje MCP

Śledź wszystkie operacje MCP dla audytu i debugowania

// Single command orchestrates everything
"Deploy version 2.1.0 to production:
- GitHub MCP: Create release
- Jenkins MCP: Build and test
- Terraform MCP: Update infra
- K8s MCP: Deploy application
- Slack MCP: Notify team"
// Time: 2 minutes setup
// Maintenance: Minimal
// Flexibility: High
  1. Określ jasne cele

    • Jaki proces ręczny zastępujesz?
    • Jakie są kryteria sukcesu?
    • Jak będziesz mierzyć wpływ?
  2. Implementuj stopniowo

    • Zacznij od operacji tylko do odczytu
    • Dodaj operacje zapisu z zabezpieczeniami
    • Włącz pełną automatyzację z monitorowaniem
  3. Monitoruj i iteruj

    • Śledź wskaźniki sukcesu/niepowodzenia
    • Mierz oszczędności czasu
    • Zbieraj opinie zespołu
    • Ciągle ulepszaj
  4. Dokumentuj wszystko

    • Jak działa automatyzacja
    • Jak rozwiązywać problemy
    • Jak modyfikować lub rozszerzać
  1. Zidentyfikuj możliwości automatyzacji - Wylistuj powtarzalne zadania w swoim przepływie pracy
  2. Stwórz pierwszą automatyzację - Zacznij od prostego, niskoryzykownego zadania
  3. Zmierz wpływ - Śledź zaoszczędzony czas i poprawę jakości
  4. Skaluj stopniowo - Rozwijaj pokrycie automatyzacji na podstawie sukcesu

Pamiętaj: celem automatyzacji nie jest zastąpienie deweloperów, ale wzmocnienie ich możliwości. Skup się na automatyzacji monotonnych zadań, aby ludzie mogli skupić się na kreatywności.