crm-import
$
npx mdskill add aAAaqwq/AGI-Super-Team/crm-importValidate and import CRM records with automated approval workflow
- Processes CSV files to add people, companies, or leads to master database
- Integrates with Git for commits, Telegram for notifications, and CRM APIs
- Executes schema checks, deduplication, and business rule validation before import
- Delivers status via Telegram with review instructions and commit hashes
SKILL.md
.github/skills/crm-importView on GitHub ↗
---
name: crm-import
description: Import data from staging to master CRM with validation
---
# CRM Import
> Import new data from staging to master CRM database with validation and approval.
## When to use
- "import CRM data from X"
- "add new people/companies/leads from file Y"
- "validate staging data"
- A file appeared in `$CRM_PATH/_staging/incoming/`
## Input
- CSV file with new records
- Table type (auto-detect or explicitly specified)
## How to execute
### Step 1: Run the agent
```bash
cd $AGENTS_PATH/crm-import
# Auto-detect table type
python3 crm-import_agent.py sales/crm/_staging/incoming/new_people.csv
# Or specify explicitly
python3 crm-import_agent.py data.csv --table companies
```
**Modes:**
- `--dry-run` -- validation without git commit
- `--validate-only` -- schema validation only
- `--show-duplicates` -- show potential duplicates
### Step 2: The agent will perform
1. Schema validation (required fields, ID format, enums)
2. Deduplication check (exact + fuzzy matching)
3. Foreign key validation
4. Business rules check
5. ID generation (if missing)
6. Git branch creation + commit
7. Telegram notification
### Step 3: You will receive a Telegram message
```
CRM Import Ready for Review
Table: people
New records: 5
Branch: crm-import-people-new_people-2026-02-12
Commit: a1b2c3d4
Next steps:
1. Review changes: git diff main..crm-import-people-new_people-2026-02-12
2. Approve: gh pr create (then merge)
3. Reject: git branch -D crm-import-people-new_people-2026-02-12
```
### Step 4: Review changes
```bash
cd $PROJECT_ROOT
git diff main..crm-import-people-new_people-2026-02-12
```
### Step 5: Approve or Reject
**Approve:**
```bash
gh pr create --base main --head crm-import-people-new_people-2026-02-12 \
--title "Import new people records" \
--body "Importing 5 new people from staging"
# Merge PR
gh pr merge --merge
```
**Reject:**
```bash
git branch -D crm-import-people-new_people-2026-02-12
```
## Output
- Git branch with new records
- Validation report (if there are issues)
- Telegram notification with summary
- Console log with details
## Validation Rules
### Critical (stops the import)
- Missing required fields
- Invalid ID format
- Invalid enum values
- Foreign key violations
### High (flagged for review)
- Potential duplicates (fuzzy match)
- Business rule violations (e.g., person without email AND phone)
### Info (log only)
- Auto-generated IDs
- Auto-set timestamps
- Skipped exact duplicates
## ID Generation
If ID is missing, the agent generates it automatically:
| Table | Format | Example |
|-------|--------|---------|
| companies | `comp-{slug}` | `comp-acme-corp` |
| people | `p-{company-slug}-{N}` | `p-acme-001` |
| clients | `cli-{company-slug}-{N}` | `cli-acme-001` |
| partners | `ptnr-{company-slug}-{N}` | `ptnr-acme-001` |
| leads | `lead-{company-slug}-{N}` | `lead-acme-001` |
| deals | `deal-{company-slug}-{N}` | `deal-acme-001` |
| products | `prod-{slug}` | `prod-labeling` |
| activities | `act-{N}` | `act-042` |
## Deduplication
**Exact match (skip):**
- Primary key match
- Email match (people)
- Website match (companies)
- LinkedIn URL match
**Fuzzy match (review):**
- People: similar name + same company
- Companies: similar name (ignoring Inc/Ltd/etc)
## Examples
### Example 1: Import new people
```bash
# Create staging file
cat > sales/crm/_staging/incoming/new_people.csv << EOF
person_id,first_name,last_name,email,company_id,role,created_date,last_updated
,John,Smith,john@example.com,comp-acme,Engineer,,
,Jane,Doe,jane@example.com,comp-acme,Manager,,
EOF
# Import
python3 crm-import_agent.py sales/crm/_staging/incoming/new_people.csv
# Result:
# - ID: p-acme-001, p-acme-002
# - Branch: crm-import-people-new_people-2026-02-12
# - Telegram notification
```
### Example 2: Dry-run before import
```bash
# Verify without commit
python3 crm-import_agent.py data.csv --dry-run
# If OK -> run
python3 crm-import_agent.py data.csv
```
### Example 3: Show duplicates
```bash
python3 crm-import_agent.py data.csv --show-duplicates
```
## Rollback
If you need to revert:
```bash
# Find merge commit
git log --oneline --grep="Import.*records"
# Revert
git revert <commit-sha>
```
## Staging Directory
```
sales/crm/_staging/
├── incoming/ # New files for import
├── review/ # Duplicate review reports
└── archive/ # Processed files
```
## Errors
### "Cannot auto-detect table type"
-> Add `--table people`
### "Foreign key violation"
-> Import the parent record first (e.g., company before people)
### "Critical schema issues"
-> Fix required fields, ID format, enum values in the CSV
### "Git commit failed"
-> Check `git status`, the working directory may be dirty
## Related skills
- `change-review` -- called automatically by the agent
- `git-workflow` -- for PR creation and merge
## Dependencies
- Python 3.8+
- pandas, pyyaml
- git, gh CLI
- tg-tools (Telegram)
## Limitations
- CSV only (no Google Sheets support yet)
- Insert only (no updating existing records)
- One table at a time
- Synchronous processing (for <1000 records)
## Future improvements
- Google Sheets integration
- Bulk update mode
- Multi-table import (denormalized -> normalized)
- Auto-scheduling (watch directory)
- ML fuzzy matching
More from aAAaqwq/AGI-Super-Team
- a-fund-monitor监控 A 股基金实时估值与盘后净值,自动判断交易日并生成提醒或分析。
- account-executive>
- add-leadAdd company/person/relationship to CRM
- adsComprehensive ad account analysis across all major platforms (Google, Meta
- ads-agentAI-агент для управления Facebook рекламой. Вызывай для анализа, оптимизации, создания кампаний и отчётов.
- afrexai-compliance-auditRun internal compliance audits against major governance and security
- afrexai-personal-financeComplete personal finance system — budgeting, debt payoff, investing, tax optimization, net worth tracking, and financial independence planning. Use when managing money, building wealth, paying off debt, planning retirement, or optimizing taxes. Zero dependencies.
- after-salesUse when managing post-purchase experience, building customer loyalty, or increasing repeat purchases
- agent-contactsAI agent contacts — add, list, remove MCP contacts. Use when someone gives an agent URL, or when you need to view/remove contacts.
- agent-model-switcher批量查看和切换子 agent 的模型配置,用于统一调整多 agent 的 provider/model 设置。