AI & data

Automate your work with AI: 10 real workflows

David Morales VegaFebruary 20, 202611 min read

Originally published on Bemorex Learn, our learning platform. · Leer en español

Why automate with AI?

As developers, a significant part of our day goes to repetitive tasks: writing commits, reviewing PRs, documenting code, updating changelogs. AI can handle these tasks, freeing you for the creative work that truly matters.

These are 10 proven workflows you can implement today.

Workflow 1: Intelligent commit messages

Instead of writing commit messages by hand, let AI analyze your diff and generate messages following Conventional Commits.

How it works

The prepare-commit-msg hook runs automatically before each commit. It reads the diff of staged files, sends it to the Claude API, and writes the suggested message.

Setup

  1. Copy the script to the .git/hooks/ directory
  2. Make it executable: chmod +x .git/hooks/prepare-commit-msg
  3. Configure your API key as an environment variable

Workflow 2: Automatic function documentation

Every time you save a file, a script generates or updates TSDoc documentation:

import { readFileSync, writeFileSync } from 'fs';

interface DocResult {
  content: Array<{ text: string }>;
}

async function generateDocs(filePath: string): Promise<string> {
  const code = readFileSync(filePath, 'utf-8');

  const response = await fetch('https://api.anthropic.com/v1/messages', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.ANTHROPIC_API_KEY ?? '',
      'anthropic-version': '2023-06-01'
    },
    body: JSON.stringify({
      model: 'claude-haiku-3-5-20241022',
      max_tokens: 2048,
      system: 'Add TSDoc to every function and class that lacks it. Return ONLY the complete code with the added documentation. Do not change any logic.',
      messages: [{ role: 'user', content: code }]
    })
  });

  const data: DocResult = await response.json();
  return data.content[0].text;
}

Workflow 3: Automatic PR reviewer

Integrate an AI review into your CI/CD pipeline to get instant feedback on every PR.

Implementation with GitHub Actions

name: AI Code Review
on: [pull_request]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Get diff
        run: git diff origin/main...HEAD > diff.txt
      - name: AI Review
        run: node scripts/ai-review.js
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

Workflow 4: Unit test generator

Automatically generate tests for new or modified functions:

async function generateTests(sourceCode: string, framework: string): Promise<string> {
  const response = await fetch('https://api.anthropic.com/v1/messages', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.ANTHROPIC_API_KEY ?? '',
      'anthropic-version': '2023-06-01'
    },
    body: JSON.stringify({
      model: 'claude-sonnet-4-20250514',
      max_tokens: 2048,
      system: `Generate unit tests using ${framework}. Include:
- Tests for the happy path
- Edge case tests
- Tests for expected errors
Use describe/it with descriptive names in English.`,
      messages: [{ role: 'user', content: sourceCode }]
    })
  });

  const data = await response.json();
  return data.content[0].text;
}

Workflow 5: Automatic changelog

Generate readable changelogs from Git history:

#!/bin/bash
# Generate a changelog between two tags
COMMITS=$(git log v1.0.0..v1.1.0 --pretty=format:"%s" --no-merges)

curl -s https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d "{
    \"model\": \"claude-haiku-3-5-20241022\",
    \"max_tokens\": 1024,
    \"messages\": [{
      \"role\": \"user\",
      \"content\": \"Generate a changelog grouped by: Features, Fixes, Breaking Changes, Other. Commits:\n$COMMITS\"
    }]
  }" | jq -r '.content[0].text'

Workflow 6: i18n translator

Translate internationalization files while maintaining keys and JSON format:

async function translateI18n(
  sourceJson: Record<string, string>,
  targetLang: string
): Promise<Record<string, string>> {
  const response = await fetch('https://api.anthropic.com/v1/messages', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.ANTHROPIC_API_KEY ?? '',
      'anthropic-version': '2023-06-01'
    },
    body: JSON.stringify({
      model: 'claude-sonnet-4-20250514',
      max_tokens: 4096,
      system: `Translate the values of this JSON into ${targetLang}. Keep the keys exactly the same. Respond ONLY with the translated JSON, no markdown.`,
      messages: [{
        role: 'user',
        content: JSON.stringify(sourceJson, null, 2)
      }]
    })
  });

  const data = await response.json();
  return JSON.parse(data.content[0].text);
}

Workflow 7: Error log analysis

Automatically analyze error logs and suggest solutions:

# Pipe logs to AI for analysis
tail -100 /var/log/app/error.log | curl -s https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d @- <<EOF
{
  "model": "claude-sonnet-4-20250514",
  "max_tokens": 1024,
  "messages": [{
    "role": "user",
    "content": "Analyze these error logs. Identify: 1) Probable root cause, 2) Error pattern, 3) Suggested fix.\n\n$(cat)"
  }]
}
EOF

Workflow 8: Code migration

Automate migrations between framework versions:

# Migrate Angular components from v16 to v19+
find src -name "*.ts" -exec grep -l "NgModule" {} \; | while read file; do
  echo "Migrating: $file"
  # Send to the API to migrate to standalone
done

Workflow 9: Database seed generator

Generate realistic test data for your database:

async function generateSeeds(schema: string, count: number): Promise<string> {
  const response = await fetch('https://api.anthropic.com/v1/messages', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.ANTHROPIC_API_KEY ?? '',
      'anthropic-version': '2023-06-01'
    },
    body: JSON.stringify({
      model: 'claude-sonnet-4-20250514',
      max_tokens: 4096,
      messages: [{
        role: 'user',
        content: `Given this SQL schema:\n${schema}\n\nGenerate ${count} realistic INSERT records with English data. Include variety and edge cases.`
      }]
    })
  });

  const data = await response.json();
  return data.content[0].text;
}

Workflow 10: Dependency summary

Before updating dependencies, get a summary of breaking changes:

#!/bin/bash
# Analyze breaking changes before npm update
OUTDATED=$(npm outdated --json 2>/dev/null)

curl -s https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d "{
    \"model\": \"claude-sonnet-4-20250514\",
    \"max_tokens\": 2048,
    \"messages\": [{
      \"role\": \"user\",
      \"content\": \"These are my outdated dependencies. For each one with a major version change, list the most important breaking changes and the estimated migration effort:\n$OUTDATED\"
    }]
  }" | jq -r '.content[0].text'

Tips for implementing these workflows

  1. Start with one: Do not try to implement all 10 at once
  2. Use the right model: Haiku for simple and fast tasks, Sonnet for complex analysis
  3. Cache results: Do not call the API for the same input twice
  4. Always review: These workflows assist, they do not replace your judgment
  5. Control costs: Set monthly usage limits in the Anthropic console

Conclusion

Automation with AI is not about replacing the developer but about eliminating mechanical tasks that consume time. Each of these workflows saves between 5 and 30 minutes daily. Multiplied across a team and over weeks, the impact is significant.

Choose the workflows that best fit your workflow and start automating today.

Code examples

Bash

#!/bin/bash
# Workflow 1: Generate commit messages with AI
# Save as .git/hooks/prepare-commit-msg

DIFF=$(git diff --cached --stat)
DETAILED=$(git diff --cached -- . ':!package-lock.json' ':!bun.lockb')

PROMPT="Generate a commit message following Conventional Commits.
Use the format: type(scope): short description

Changes:
$DIFF

Detailed diff (first 2000 chars):
${DETAILED:0:2000}"

RESPONSE=$(curl -s https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d "{
    \"model\": \"claude-haiku-3-5-20241022\",
    \"max_tokens\": 100,
    \"messages\": [{
      \"role\": \"user\",
      \"content\": \"$PROMPT\"
    }]
  }" | jq -r '.content[0].text')

echo "$RESPONSE" > "$1"

JavaScript

// Workflow 3: Automated PR reviewer (GitHub Actions)
async function reviewPR(diff, context) {
  const response = await fetch('https://api.anthropic.com/v1/messages', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.ANTHROPIC_API_KEY,
      'anthropic-version': '2023-06-01'
    },
    body: JSON.stringify({
      model: 'claude-sonnet-4-20250514',
      max_tokens: 2048,
      system: `You are a senior code reviewer.
Analyze the diff and report:
1. Potential bugs (CRITICAL)
2. Security issues (HIGH)
3. Performance improvements (MEDIUM)
4. Style suggestions (LOW)

Format: markdown table with columns:
Severity | File | Line | Description | Suggestion`,
      messages: [{
        role: 'user',
        content: `PR: ${context.title}\n\nDiff:\n${diff}`
      }]
    })
  });

  const data = await response.json();
  return data.content[0].text;
}

Keep reading

Want to build something like this?

Tell us what you need: we look at it together and propose a way forward in writing, in English or Spanish.

[email protected]