# Managing & Consolidating Activities

As you use the Zipwire CLI, you'll accumulate activities. Over time, these can become sprawling, inconsistent, or redundant. This guide covers how to organize and consolidate them.

## Why Activity Management Matters

After months of tracking time, you might have:

* **Duplicates**: "Frontend Development" and "Frontend > Development"
* **Typos**: "Meeetings" instead of "Meetings"
* **Inconsistent naming**: "Bug Fixes", "Bug Fixing", "Bug Fix"
* **Too many activities**: Staffing agencies often prefer fewer, broader categories
* **Historical cruft**: Old client names or abandoned projects

The good news: the CLI lets you consolidate and rename activities **without losing any data**. All your journal entries automatically update.

## Finding Activities

### List All Activities

```bash
# View all activities
zw activity list

# View in hierarchical format
zw activity list --style hierarchical

# View as flat list (default)
zw activity list --style flat
```

### Search for Activities

```bash
# Search by name
zw activity search "meeting"

# Search by project
zw activity search "ABC Corp"

# Search by activity
zw activity search "bug"
```

### See Recently Used

```bash
# Most recently used activities
zw activity recent

# Last 2 weeks
zw activity recent --period 2w

# Last 30 days
zw activity recent --period 30d
```

## Consolidating Activities

### Basic Rename

Rename a single activity:

```bash
zw activity rename --from "Old Activity Name" --to "New Activity Name"
```

Example:

```bash
zw activity rename --from "Meeetings" --to "Meetings"
```

### Merging Multiple Activities

Merge several activities into one. This is useful when you have duplicates or variations:

```bash
zw activity rename \
  --from "Frontend Development" \
  --from "Frontend > Development" \
  --from "FE Dev" \
  --to "Client A > Frontend > Development"
```

This command:

1. Takes all entries from the three source activities
2. Moves them to the target activity
3. Removes the old activities
4. Updates all journal entries automatically

### Using Activity Keys

For programmatic use (scripts, agents), you can use activity keys instead of names:

```bash
# Get activity keys from list
zw activity list --format structured

# Merge using keys
zw activity rename \
  --from "abe_jnla_ac71x94j8smyi0fu" \
  --from "abe_jnla_bc82y05k9t" \
  --to "abe_jnla_cd93z16l0u"
```

### Important: Quoting Activity Names

Activity names with spaces or the `>` character **must be quoted**:

```bash
# ❌ Wrong - shell will interpret the >
zw activity rename --from Client > Development --to Client > Dev

# ✅ Correct - quoted names
zw activity rename --from "Client > Development" --to "Client > Dev"
```

## What Happens During Consolidation

When you merge activities, the CLI:

1. **Consolidates** all journal entries from source activities to the target
2. **Updates** every affected journal entry automatically
3. **Removes** the old activities once merged
4. **Reports** what was changed:
   * Number of entries updated
   * Activities removed
   * Breakdown per source activity

Example output:

```
↓ Activity consolidation complete

▦ Target Activity
• Client A > Development > Features

▦ Merged Activities
• 45 entries from "Client A > Dev > Features"
• 12 entries from "Frontend Features"

✓ 57 total entries updated
✓ 2 activities removed
```

## Common Consolidation Scenarios

### Scenario 1: Fixing Typos

You've been tracking time with a typo in an activity name:

```bash
zw activity rename --from "Meetigns" --to "Meetings"
```

All 23 entries under "Meetigns" are automatically updated to "Meetings".

### Scenario 2: Handling Agency Constraints

Your staffing agency prefers fewer, broader categories. Instead of:

```
Client A > Development > Features
Client A > Development > Bug Fixes
Client A > Development > Code Review
Client A > QA > Testing
Client A > QA > Automation
```

Consolidate to:

```bash
zw activity rename \
  --from "Client A > Development > Features" \
  --from "Client A > Development > Bug Fixes" \
  --from "Client A > Development > Code Review" \
  --to "Client A > Development"

zw activity rename \
  --from "Client A > QA > Testing" \
  --from "Client A > QA > Automation" \
  --to "Client A > QA"
```

Now all entries are organized under just two high-level activities.

### Scenario 3: Consolidating Duplicates

You've been inconsistent with naming. Fix it:

```bash
zw activity rename \
  --from "Frontend Development" \
  --from "Frontend > Development" \
  --from "FE Dev" \
  --from "Frontend Dev Work" \
  --to "Client A > Frontend > Development"
```

All 127 entries across four variations are merged into one activity.

### Scenario 4: Cleaning Up Old Clients

You finished a project and want to consolidate historical entries:

```bash
zw activity rename \
  --from "Old Client > Project Alpha > Development" \
  --from "Old Client > Project Alpha > QA" \
  --from "Old Client > Project Alpha > Meetings" \
  --to "Archive > Old Client > Project Alpha"
```

All historical entries are grouped under an "Archive" company for easy reference.

## Before & After: A Real Example

**Before consolidation** (scattered activities):

```bash
$ zw activity list
• ABC Corp > Development > Features
• ABC Corp > Dev > Bug Fixes
• ABC Corp > Frontend Development
• ABC Corp > Frontend > Features
• ABC Corp > Meetings
• ABC Corp > Meeting Notes
• Personal > General > General
• Personal > Admin > Admin Work
• Personal > Admin > General
```

**Consolidation commands:**

```bash
# Fix ABC Corp inconsistencies
zw activity rename \
  --from "ABC Corp > Dev > Bug Fixes" \
  --to "ABC Corp > Development > Bug Fixes"

zw activity rename \
  --from "ABC Corp > Frontend Development" \
  --from "ABC Corp > Frontend > Features" \
  --to "ABC Corp > Frontend > Development"

zw activity rename \
  --from "ABC Corp > Meeting Notes" \
  --to "ABC Corp > Meetings"

# Consolidate Personal admin
zw activity rename \
  --from "Personal > Admin > Admin Work" \
  --from "Personal > Admin > General" \
  --to "Personal > Admin"
```

**After consolidation** (clean and organized):

```bash
$ zw activity list
• ABC Corp > Development > Features
• ABC Corp > Development > Bug Fixes
• ABC Corp > Frontend > Development
• ABC Corp > Meetings
• Personal > General > General
• Personal > Admin
```

Much cleaner!

## Tips & Best Practices

### Plan Before Consolidating

Think about your structure before renaming:

```bash
# Decide on a consistent format first
# Option A: Company > Project > Activity
# Option B: Company > Activity > Subactivity
# Option C: Client > Billable Category
```

### Check Entry Counts First

See how many entries are affected:

```bash
zw activity search "old-name"
# Shows all entries so you know the impact
```

### Consolidate in Batches

If you have many activities, do a few at a time and verify:

```bash
# Consolidate one client first
zw activity rename --from "Client A Old Name" --to "Client A > Development"

# Verify it worked
zw activity search "Client A"

# Then move to the next batch
zw activity rename --from "Client B Old Name" --to "Client B > Development"
```

### Keep Hierarchies Consistent

Use consistent separators and levels:

```bash
# ✅ Consistent
"Company > Project > Task Type"
"Company > Project > Task Type"

# ❌ Inconsistent
"Company > Project > Task Type"
"Company - Project - Task Type"
"Company/Project/Task"
```

### Use Codes for Broad Categories

If you work for multiple agencies or have many clients, consider using codes:

```bash
zw activity rename \
  --from "Old Agency Name > Development" \
  --to "AGENCY_CODE > Development"

# E.g., "A001 > Development", "A002 > Development"
```

## Troubleshooting

### "Activity Not Found"

The activity name doesn't exist exactly as written. Check:

```bash
# Search for it
zw activity search "part-of-name"

# List all activities
zw activity list
```

### Forgot to Quote the Name

```bash
# ❌ This won't work
zw activity rename --from Client > Development --to New Name

# ✅ Always quote names with > or spaces
zw activity rename --from "Client > Development" --to "New Name"
```

### Want to Undo a Merge

The merge is permanent, but you can:

1. Create a new activity with the old name
2. Move entries back using a rename

```bash
# Create the old activity again
zw activity create "Old Activity Name"

# Move entries that need it (you'll need to do this via the API or web app)
```

***

For more on tracking time and working with activities, see:

* [Getting Started](https://docs.zipwire.io/tools-and-integrations/getting-started)
* [Common Workflows](https://docs.zipwire.io/tools-and-integrations/workflows)
* [Configuration](https://docs.zipwire.io/tools-and-integrations/configuration)

Use the built-in help anytime:

```bash
zw activity --help
zw activity rename --help
```
