home / skills / avvale / aurora-front / aurora-sheets-sync

aurora-sheets-sync skill

/.claude/skills/aurora-sheets-sync

This skill synchronizes Aurora YAML schemas with Google Sheets in both directions, enabling push and pull operations and streamlined configuration.

npx playbooks add skill avvale/aurora-front --skill aurora-sheets-sync

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
5.2 KB
---
name: aurora-sheets-sync
description: >
  Bidirectional sync between Aurora YAML schemas and Google Sheets.
  Trigger: When syncing schemas to/from spreadsheets, push/pull commands, google sheets sync.
license: MIT
metadata:
  author: aurora
  version: "2.0"
  auto_invoke: "sync schemas, google sheets, push schemas, pull schemas, spreadsheet sync"
allowed-tools: Read, Edit, Write, Glob, Grep, Bash
---

## When to Use

- User wants to sync YAML schemas to Google Sheets (`push`)
- User wants to sync Google Sheets to YAML schemas (`pull`)
- User mentions "sincronizar", "spreadsheet", "google sheets", "exportar schemas"
- Troubleshooting sync issues or configuration problems

---

## Critical Patterns

### 1. Spreadsheet Structure

| Sheet | Purpose |
|-------|---------|
| `DATA` | Dropdown values, validations (don't modify) |
| `TEMPLATE` | Template duplicated for new modules |
| `MODULES` | Index with hyperlinks to module sheets |
| `{module-name}` | One sheet per module (e.g., `business-partner`) |

### 2. Module Sheet Format

- **Row 1**: Headers (read dynamically)
- **Row 2+**: Properties (one per row)
- **Booleans**: `✓` (CHAR 9989) = true, empty = false

### 3. Pull is Idempotent

**Rule**: If no content changes in spreadsheet, YAML files must NOT be modified.

```typescript
// Content comparison before writing
if (normalizeYamlForComparison(existing) === normalizeYamlForComparison(new)) {
  // Skip write - preserves original formatting
}
```

### 4. Preserve Fields Not in Spreadsheet

Fields in YAML without spreadsheet columns are preserved on pull:
- `relationship.singularName`, `relationship.aggregateName`, `relationship.modulePath`
- `relationship.key`, `relationship.field`, `relationship.avoidConstraint`
- `webComponent`

### 5. Field Mappings

| Sheet Column | YAML Field | Notes |
|--------------|------------|-------|
| `relationship` | `relationship.type` | `1:1`, `N:1`, `1:N`, `N:N` |
| `master` | `relationship.modulePath` | Module name only |
| `subtype` | `arrayOptions.type` | When `type=array` |
| `values` | Multiple | `enumOptions`, `decimals`, or `arrayOptions.enumOptions` |
| `hasAuth` | `hasOAuth` | Header mapping |

### 6. Array Format in YAML

**Inline format** `[A, B, C]`:
- `enumOptions`
- `decimals`
- `defaultValue` (when array)

**Multi-line format** (for readability):
- `excludedOperations`
- `excludedFiles`

### 7. Nullable and DefaultValue Rules

- **nullable**: If not checked (✓), defaults to `false` (never undefined)
- **defaultValue**: Wrapped in array `[value]` when `type=array`
- **description**: Format preserved even when field is renamed (matched by content)

---

## Commands

```bash
# Navigate to tool directory
cd scripts/aurora-sheets-sync

# Install dependencies (first time)
npm install

# Push: YAML → Google Sheets
npx ts-node src/index.ts push --bc business-partner-portal
npx ts-node src/index.ts push --all
npx ts-node src/index.ts push --bc iam --dry-run

# Pull: Google Sheets → YAML
npx ts-node src/index.ts pull --bc business-partner-portal
npx ts-node src/index.ts pull --bc iam --no-backup
npx ts-node src/index.ts pull --all --dry-run

# Validate connection
npx ts-node src/index.ts validate --bc business-partner-portal

# List configured bounded contexts
npx ts-node src/index.ts list
```

---

## Configuration

### aurora-sheets.config.json

```json
{
  "credentialsPath": "./scripts/aurora-sheets-sync/credentials/service-account.json",
  "boundedContexts": {
    "business-partner-portal": {
      "spreadsheetId": "1ABC123xyz...",
      "description": "Business Partner Portal"
    }
  },
  "backupsPath": "backups/aurora-schemas",
  "cliterPath": "cliter"
}
```

### Google Cloud Setup (Quick Reference)

1. Create project in [Google Cloud Console](https://console.cloud.google.com/)
2. Enable **Google Sheets API** (APIs & Services → Library)
3. Create **Service Account** (APIs & Services → Credentials)
4. Download JSON key → save to `credentials/service-account.json`
5. Share spreadsheet with service account email (Editor role)

---

## Troubleshooting

| Error | Solution |
|-------|----------|
| `The caller does not have permission` | Share spreadsheet with service account email |
| `Google Sheets API has not been enabled` | Enable API in Google Cloud Console |
| `Could not load credentials` | Check `credentialsPath` in config |
| `Skipped: X (empty or invalid)` | Sheet missing headers or `name`/`type` columns |
| Pull shows "(no changes)" | Idempotent - content unchanged, file preserved |

---

## Key Files

```
scripts/aurora-sheets-sync/
├── src/
│   ├── index.ts                    # CLI entry point
│   ├── sync/
│   │   ├── yaml-to-sheet.ts        # Push logic
│   │   └── sheet-to-yaml.ts        # Pull logic (idempotent)
│   └── transformers/
│       └── property-transformer.ts  # YAML ↔ Row conversion
├── credentials/
│   └── service-account.json        # Google credentials (gitignored)
├── CONTEXT.md                      # Technical documentation
└── README.md                       # User guide
```

---

## Resources

- **Technical Context**: See [CONTEXT.md](../../../scripts/aurora-sheets-sync/CONTEXT.md)
- **User Guide**: See [README.md](../../../scripts/aurora-sheets-sync/README.md)

Overview

This skill provides bidirectional synchronization between Aurora YAML schemas and Google Sheets. It lets you push YAML schemas into structured spreadsheets and pull spreadsheet rows back into YAML while preserving untouched fields and formatting. The tool emphasizes idempotent pulls so files are only rewritten when content actually changes.

How this skill works

Push converts YAML schema modules into one sheet per module plus dedicated DATA, TEMPLATE, and MODULES index sheets, writing validation values and headers. Pull reads module sheets, converts rows to YAML properties, preserves fields not represented in the sheet, and skips writing files when normalized content matches existing YAML. Authentication uses a Google service account configured in aurora-sheets.config.json.

When to use it

  • Export YAML schemas into a Google Sheet for review, editing, or collaboration (push).
  • Import schema changes made in a spreadsheet back into YAML files (pull).
  • Validate connectivity or troubleshoot sync configuration with the validate command.
  • Automate bulk sync across all bounded contexts with push --all or pull --all.
  • Recover or audit schema edits without risking accidental file rewrites (dry-run).

Best practices

  • Do not modify the DATA sheet any further than adding dropdown values; it drives validations.
  • Keep one sheet per module and use the TEMPLATE sheet to create new modules consistently.
  • Share the spreadsheet with the service account email and ensure the Sheets API is enabled.
  • Use dry-run or no-backup flags to preview changes before committing to the repository.
  • Respect boolean encoding: use ✓ (CHAR 9989) for true and leave empty for false.

Example use cases

  • A product manager edits enum values in a sheet and triggers pull to update YAML configs.
  • A team exports all schemas to a sheet for a data-model review session (push --all).
  • Ops validates the service account and spreadsheet access using the validate command.
  • A developer performs a dry-run pull to confirm no unintended YAML changes before merging.
  • Migrate module definitions by duplicating TEMPLATE and pushing new modules into the repo.

FAQ

What happens if I edit fields in YAML that are not represented in the sheet?

Fields not present as columns in the sheet are preserved on pull, so your additional YAML fields remain intact.

Why did a pull report (no changes) even after I edited the sheet?

The tool normalizes content before comparing. If normalized content matches existing YAML, the file is not rewritten to preserve formatting and avoid unnecessary commits.