Chapter 6

Core skills: Tools and efficiency

Learn workflow design methods, how to write automation scripts, and the architectural design of toolchain integration, and improve development efficiency through a systematic approach.

Workflow design

Workflow design is the key to improving efficiency. Through systematic analysis and optimization, identify bottlenecks, automate repetitive tasks, and improve overall efficiency.

Workflow analysis

Identify repetitive tasks

  • Record work logs: Record a week’s work content and identify recurring patterns
  • Time analysis: tally the time spent on each task and find time black holes
  • Automation candidates: Identify repetitive tasks that can be automated
  • Tool evaluation: evaluating the costs and benefits of automation tools

Identify bottlenecks

  • Process mapping: Draw a complete workflow diagram
  • Time measurement: Measure the time of each step
  • Bottleneck identification: Identify the most time-consuming part
  • Optimization Plan: Design optimization plans (parallelization, caching, algorithm optimization)

Workflow analysis example

Development workflow

1. Create a branch (2 minutes)

2. Write code (2 hours)

3. Run tests (5 minutes)

4. Submit code (2 minutes)

5. Create a PR (3 minutes)

6. Waiting for review (30 minutes–2 hours) ← bottleneck

7. Fix issues (30 minutes)

8. Merge code (1 minute)

Optimization Plan: use AI tools for code review to reduce waiting time

Workflow optimization

Automation

  • • Automate repetitive tasks
  • • Use scripts and tools
  • • Reduce manual intervention
  • • Improve consistency

Parallelization

  • • Identify tasks that can be parallelized
  • • Use parallel tools
  • • Reduce waiting time
  • • Improve throughput

Cache

  • • Cache repeated computations
  • • Cache API responses
  • • Reduce repetitive work
  • • Improve response speed

Practical case study: optimizing the development workflow

Before optimization

  • • Manually create branches and commit code
  • • Run tests manually
  • • Manually create a PR
  • • Wait for manual code review
  • • Manual deployment
  • Total time: about 4-6 hours (including waiting time)

After optimization

  • • Use a Git alias to quickly create branches
  • • CI/CD automatically runs tests
  • • Use GitHub CLI to automatically create PRs
  • • Use AI tools to perform code reviews
  • • Automated deployment to the test environment
  • Total time: about 2-3 hours (50% less)

Efficiency improvement analysis

  • Time savings: save 2-3 hours on each development cycle
  • Quality Improvement: AI review is more comprehensive, reducing bugs
  • Consistency: Automation ensures process consistency
  • ROI: invest 1 day in automation, save 20+ hours per month

Automation scripts

Automation scripts are a direct way to improve efficiency. By writing scripts to automate repetitive tasks, you free up time to focus on creative work.

Script types

Build script

  • • Compile code
  • • Package the app
  • • Generate resources
  • • Optimize code
npm run build

Deployment script

  • • Environment setup
  • • File upload
  • • Service restart
  • • Health check
./deploy.sh production

Test script

  • • Run tests
  • • Generate reports
  • • Code coverage
  • • Performance testing
npm test -- --coverage

Script design principles

Maintainability

  • Clear naming: use meaningful variable names and function names
  • Well-commented: explain complex logic and design decisions
  • Modularization: Split scripts into reusable functions
  • Configurable: Use configuration files to avoid hard-coding

Scalability

  • Parameterization: Use command-line arguments or a config file
  • Plugin-based: supports plugin extension functionality
  • Version Control: use version control to manage scripts
  • Backward compatibility: maintain API compatibility

Error Handling

  • Error Checking: Check command execution results
  • Error message: Provide clear error messages
  • Rollback mechanism: able to roll back in case of failure
  • Logging: record the execution process and errors

Practical case study: CI/CD automation script

GitHub Actions workflow

name: CI/CD Pipeline

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm install
      - run: npm run lint
      - run: npm test
      - run: npm run build

  deploy:
    needs: test
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v3
      - name: Deploy to production
        run: |
          ./scripts/deploy.sh production

Deployment script example

#!/bin/bash
# deploy.sh - automated deployment script

set -e  # exit immediately on error

ENV=${1:-staging}
echo "Deploying to $ENV..."

# check environment variable
if [ -z "$DEPLOY_KEY" ]; then
  echo "Error: DEPLOY_KEY not set"
  exit 1
fi

# build application
echo "Building application..."
npm run build

# upload files
echo "Uploading files..."
rsync -avz --delete dist/ user@server:/var/www/app/

# restart service
echo "Restarting service..."
ssh user@server "sudo systemctl restart app"

# health check
echo "Health check..."
sleep 5
if curl -f http://server/health; then
  echo "Deployment successful!"
else
  echo "Deployment failed!"
  exit 1
fi

Toolchain integration

Toolchain integration connects multiple tools to form a complete workflow, enabling data transfer and event triggering to improve overall efficiency.

Integrated architecture

Data transfer between tools

Git → GitHub → CI/CD → Testing tools → Deployment tools → Monitoring tools

Data flows through the toolchain, with each tool handling part of the data, ultimately completing the entire process.

Event-driven mechanism

  • Git Push → Trigger CI/CD
  • PR creation → Trigger code review
  • Test passed → Trigger deployment
  • Deployment completed → trigger notification

Integration mode

API integration

  • • Call via REST API
  • • Standardized interfaces
  • • Easy to implement
  • • Suitable for: real-time interaction

Webhook integration

  • • Event-driven
  • • Asynchronous processing
  • • Decoupled design
  • • Suitable for: event notifications

File integration

  • • Through file exchange
  • • Simple and direct
  • • Suitable for batch processing
  • • Suitable for: data import/export

Efficiency improvement: quantitative methods

ROI analysis

Input

  • • Toolchain integration development time: 20 hours
  • • Tool subscription fee: $100/month
  • • Maintenance time: 2 hours/month

Revenue

  • • Time saved per deployment: 30 minutes
  • • Monthly deployments: 20
  • • Time saved per month: 10 hours
  • • Reduce error rate by 50%

ROI: 10 hours/month × $50/hour = $500/month, investment $100/month, net gain $400/month

Efficiency metrics

  • Time savings: time difference before and after automating measurements
  • Error rate: calculate the error rate before and after automation
  • Throughput: number of tasks completed per unit time
  • satisfaction: Team satisfaction with the toolchain

Practical case: complete toolchain integration solution

Toolchain composition

Cursor (development) →
GitHub (version control) →
GitHub Actions (CI/CD) →
Continue.dev (code review) →
Vercel (deployment) →
Sentry (monitoring) →
Slack (notifications)

Integration process

  1. 1. Develop code in Cursor
  2. 2. Submit code to GitHub
  3. 3. GitHub Actions automatically triggers CI/CD
  4. 4. Continue.dev automatically performs code reviews
  5. 5. Automatically deploy to Vercel after tests pass
  6. 6. Monitor application errors with Sentry
  7. 7. Notify Slack when deployment is complete

Improved efficiency

  • Deployment time: reduced from 30 minutes to 5 minutes (83% reduction)
  • Error rate: Reduced from 10% to 2% (80% reduction)
  • Response time: Problem discovery time reduced from 1 hour to 5 minutes
  • Team satisfaction: improved from 6/10 to 9/10

Learning outcomes

After completing this chapter, you will:

  • 1Master workflow design methods, identify repetitive tasks and bottlenecks, and design optimization solutions
  • 2Able to write automation scripts and understand script design principles (maintainability, scalability, error handling)
  • 3Understand the architecture design of toolchain integration, and be able to design data flows and event triggering mechanisms between tools
  • 4Master quantitative methods for efficiency improvement, and be able to conduct ROI analysis and measure efficiency metrics
  • 5Has the ability to systematically improve efficiency and can continuously optimize workflows and toolchains