# Primary Workflow for Movement dApp Development

**IMPORTANT:** Analyze the agents and activate the agents that are needed for the task during the process.
**IMPORTANT:** Ensure token efficiency while maintaining high quality.

## Workflow Overview

```
/plan → /cook:contracts → /deploy-smart-contract → /cook:frontend → /test → /deploy-full
```

---

## Phase 1: Product Planning (/plan)

**Agent:** `product-manager`

- Delegate to `product-manager` agent to create PRD with user stories in `./plans` directory.
- Define problem statement and target users
- Write prioritized user stories (P0, P1, P2)
- Define acceptance criteria for each story
- Focus on WHAT to build, not HOW
- **DO NOT** include technical implementation details in this phase.

**Output:** `plans/{YYMMDD}-{name}/prd.md`

---

## Phase 2: Smart Contract Development (/cook:contracts)

**Agent:** `smart-contract`

- Delegate to `smart-contract` agent to implement Move contracts.
- Write clean, secure, and gas-optimized Move code
- Follow Move security best practices
- Implement all entry functions and view functions
- Emit events for all state changes
- Use descriptive error codes
- **[IMPORTANT]** After creating or modifying contract files, run `movement move compile` to check for compile errors.
- **[IMPORTANT]** Run `movement move test` to verify contract logic.

**Output:** `contracts/sources/*.move`, `contracts/tests/*.move`

---

## Phase 3: Deploy Smart Contract (/deploy-smart-contract)

**Agent:** `devops`

- Delegate to `devops` agent to deploy contracts to Movement network.

**Deployment Steps:**

1. **Check config.yaml** - Ensure `.movement/config.yaml` is configured correctly:
   ```yaml
   profiles:
     default:
       network: Custom
       private_key: "0xYOUR_PRIVATE_KEY"
       public_key: "0xYOUR_PUBLIC_KEY"
       account: "YOUR_ACCOUNT_ADDRESS"
       rest_url: "https://testnet.movementnetwork.xyz/v1"
       faucet_url: "https://faucet.testnet.movementnetwork.xyz/"
   ```

2. **Add address to Move.toml**:
   ```toml
   [addresses]
   default = "YOUR_ADDRESS"
   ```

3. **Deploy to Movement Network**:
   ```bash
   movement move publish
   # Type Y and press Enter when prompted
   ```

4. **Verify on Explorer** - Check `https://explorer.movementnetwork.xyz/`

- **IMPORTANT:** Ensure sufficient testnet tokens from faucet before deploying.
- **IMPORTANT:** Never deploy to mainnet without testnet verification.

**Output:** Deployed contract address, transaction hashes

---

## Phase 4: Frontend Development (/cook:frontend)

**Agent:** `frontend`

- Delegate to `frontend` agent to implement React frontend.
- Implement wallet connection with `@aptos-labs/wallet-adapter-react`
- Create custom hooks for contract interaction
- Build responsive UI components
- Handle loading, error, and success states
- Follow TypeScript strict mode (no `any` types)
- **[IMPORTANT]** After creating or modifying frontend files, run `npm run build` to check for compile errors.

**Output:** `frontend/src/components/`, `frontend/src/hooks/`

---

## Phase 5: Testing (/test)

**Agent:** `tester`

- Delegate to `tester` agent to run all tests and analyze the summary report.
  - Move contract unit tests
  - Frontend component tests
  - Integration tests with testnet
- Target >90% code coverage
- Tests are critical for ensuring code quality and reliability
- **DO NOT** ignore failing tests just to pass the build.
- **IMPORTANT:** Make sure you don't use fake data, mocks, cheats, tricks, or temporary solutions just to pass tests.
- **IMPORTANT:** Always fix failing tests following the recommendations and delegate to `tester` agent to run tests again. Only finish your session when all tests pass.

**Output:** Test results, coverage report

---

## Phase 6: Deploy Frontend (/deploy-full)

**Agent:** `devops`

- Delegate to `devops` agent to deploy the complete dApp.
- Build production frontend bundle
- Deploy frontend to hosting (Vercel, Netlify, etc.)
- Configure environment variables for mainnet
- Verify end-to-end functionality
- Set up monitoring and alerts

**Output:** Deployed frontend URL, deployment logs

---

## Debugging Flow

When a user reports bugs or issues:

1. Delegate to `tester` agent to reproduce and identify the issue
2. If contract issue → delegate to `smart-contract` agent to fix
3. If frontend issue → delegate to `frontend` agent to fix
4. Delegate to `tester` agent to run tests and verify the fix
5. If tests fail, fix them and repeat from step 4
6. Delegate to `devops` agent to redeploy if needed

---

## Quick Reference

| Phase | Command | Agent | Output |
|-------|---------|-------|--------|
| Plan | `/plan` | product-manager | PRD in `plans/` |
| Contracts | `/cook:contracts` | smart-contract | Code in `contracts/` |
| Deploy SC | `/deploy-smart-contract` | devops | Contract on-chain |
| Frontend | `/cook:frontend` | frontend | Code in `frontend/` |
| Test | `/test` | tester | Test results |
| Deploy FE | `/deploy-full` | devops | Live dApp |

## Status Check

Use `/watzup` at any time to check project status and get recommendations for next steps.

