---
name: redash-comunidades-compuestas
description: Interpret composite communities in Humand. Identifies clones of base communities used for demos, distinguishes those that became real clients from empty shells, and helps clean up unused duplicates. Use when asked about duplicate communities, real vs demo instances, clones, test instances based on templates, or instance cleanup.
disable-model-invocation: true
---

# Composite Communities

Composite communities are clones of a base community (e.g.: instance 961) created to prepare demos for potential clients. Some become real clients and differentiate; many remain as unused demo shells.

## Prerequisite

Read skill `redash-connect` for client configuration and core tables.

## Concept

1. A **base community** (template) exists as a starting point
2. That community is **cloned** to prepare a personalized demo for a prospect
3. If the client confirms Humand, the cloned community gets **implemented and differentiated** (real users loaded, configured, etc.)
4. If the client doesn't proceed, the community remains as an **unused demo**

## Analysis flow

### Step 1 — Identify the base community

The known base community is **961**. Check if there are others:

```sql
SELECT id, name, "createdAt"
FROM "Instances"
WHERE "deletedAt" IS NULL
  AND (name ILIKE '%base%' OR name ILIKE '%template%' OR id = 961)
ORDER BY "createdAt"
```

### Step 2 — Find clones

Look for communities created from a base. Clone signals:

```sql
SELECT i.id, i.name, i."createdAt",
  icd.status AS crm_status,
  COUNT(u.id) FILTER (WHERE u."deletedAt" IS NULL) AS total_users,
  COUNT(u.id) FILTER (WHERE u.status = 'active' AND u."deletedAt" IS NULL) AS active_users,
  COUNT(u.id) FILTER (WHERE u.email ILIKE '%@humand.co' AND u."deletedAt" IS NULL) AS humand_users
FROM "Instances" i
LEFT JOIN "InstanceCrmData" icd ON icd."instanceId" = i.id
LEFT JOIN "Users" u ON u."instanceId" = i.id
WHERE i."deletedAt" IS NULL
GROUP BY i.id, i.name, i."createdAt", icd.status
HAVING COUNT(u.id) FILTER (WHERE u."deletedAt" IS NULL) < 50
ORDER BY i."createdAt" DESC
```

### Step 3 — Classify each clone

A clone is **demo/cleanable** if it meets SEVERAL of these criteria:

| Criterion | SQL / signal |
|-----------|-------------|
| Few real users | `total_users < 20` or most are `@humand.co` |
| No recent activity | No sessions in the last 90 days |
| CRM status is not PRODUCTION | `InstanceCrmData.status != 'PRODUCTION'` |
| Users only unclaimed | Most never logged in |
| Generic name | Contains "demo", "test", prospect name without differentiation |

A clone **became a real client** if:
- It has real users (not `@humand.co`) that are `active`
- It has recent sessions
- CRM status is `PRODUCTION` or `ONBOARDING`
- It has its own segmentations, feature flags, etc.

### Step 4 — Recent activity query

```sql
SELECT i.id, i.name,
  COUNT(DISTINCT s."userId") AS users_with_session_90d
FROM "Instances" i
LEFT JOIN "Sessions" s ON s."instanceId" = i.id
  AND s."createdAt" > NOW() - INTERVAL '90 days'
WHERE i.id IN ([list_of_suspect_ids])
  AND i."deletedAt" IS NULL
GROUP BY i.id, i.name
ORDER BY users_with_session_90d
```

### Step 5 — Present result

Classify each found community as:

- **Active demo**: currently being used for an ongoing demo
- **Inactive demo / cleanable**: no activity, candidate for deletion or archival
- **Real client**: differentiated and has real usage
- **Ambiguous**: needs manual review

## What to answer the user

If they ask to clean up: list inactive communities with evidence (no sessions, few users, CRM status). Propose which to delete (soft delete) and which to review.

If they ask about a specific community: run steps 2-4 for that instance and classify it.
