Skip to content

feat: Add /improve command for self-improving toolkit#20

Open
tonyoconnell wants to merge 9 commits intomainfrom
improve/self-improvement-system
Open

feat: Add /improve command for self-improving toolkit#20
tonyoconnell wants to merge 9 commits intomainfrom
improve/self-improvement-system

Conversation

@tonyoconnell
Copy link
Collaborator

Summary

This PR adds a self-improvement system that captures learnings from development sessions and creates PRs to improve the toolkit.

New Features

  • /improve skill: Analyzes session errors and patterns, presents learnings to user, creates PR with fixes
  • docs/self-improvement.md: Full documentation of the philosophy and workflow
  • Updated CLAUDE.md: Added /improve to slash commands list

Bug Fixes (Discovered During Testing)

  • MCP tests hang: Server was starting unconditionally on import, keeping test process alive
    • Fix: Guard server startup with entry point check
  • Stale genesis tests: Removed 725 lines of tests for deprecated template (replaced by swarm-starter)

The /improve Workflow

1. Analyze session → find errors fixed, patterns discovered
2. Check duplicates → skip what's already documented  
3. Present learnings → user selects what to add
4. Test changes → npm run build && npm run test
5. Create branch, commit, push → open PR for review

Test Results

CLI:       12 passed, 0 failed
MCP:       16+ passed, 0 failed (no longer hangs!)
SDK:       109 passed, 0 failed  
Templates: 80 passed, 0 failed

Why This Matters

  • Team members can use the toolkit, fix issues, and contribute improvements
  • Learnings are captured and shared automatically
  • PR-based workflow ensures quality review
  • Makes the toolkit self-improving with use

This PR was created using /improve - the first improvement captured by the system!

🤖 Generated with Claude Code

tonyoconnell and others added 9 commits March 5, 2026 11:51
…generator

Templates:
- swarm-starter: Full commerce stack for agent swarms
  - PaymentService, PricingTable, TierManager
  - WalletManager, RevenueTracker, SelfAwareMixin
  - HoldingsManager for cross-token operations
  - Memory + LLM integration (ASI1-mini)

- consumer-commerce: Multi-token payment processing
  - FET + USDC support with fiat onramp
  - Invoice management, delegation flows
  - Booking, subscription, escrow presets

- people.ts: Org chart to agent swarm generator
  - Transform any org structure into coordinated agents
  - C-Suite → infrastructure layer
  - Departments → specialist agents
  - Teams → service agents
  - Built-in examples: startup, smb, enterprise, marketing

Presets:
- 5 C-Suite roles: ceo, cto, cfo, coo, cro
- 7 Marketing roles: writer, social, community, analytics, outreach, ads, strategy
- 4 Consumer commerce roles: payment-processor, booking-agent, subscription-manager, escrow-service

Co-Authored-By: Claude Opus 4.5 <[email protected]>
New modules:
- payments.ts: Multi-token payment service
  - FET + USDC support on BSC (testnet/mainnet)
  - Token registry with known addresses
  - ERC-20 transfer/balance functions

- delegation.ts: Spending delegation (ERC-20 approve/transferFrom)
  - checkAllowance, spendFromDelegation
  - createSpendingLimitHandoff for user approval flow

Enhanced modules:
- handoff.ts: Add fiat onramp links (MoonPay/Transak)
- commerce.ts: Add invoice CRUD, active invoice tracking
- types.ts: PaymentToken, Invoice, Delegation types
- onchain.ts: Multi-token balance queries

Exports 26 functions (verified by smoke tests)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
New commands:
- marketing: Deploy 7-agent Marketing Team (960 FET)
- alliance: Deploy 27-agent ASI Alliance (3,240 FET)
- org-template: Generate YAML org chart templates
- swarm-from-org: Deploy custom swarms from org charts
- wallet: Multi-token balance, send, delegate operations
- pay: Direct payments in FET/USDC

Enhanced commands:
- create: Register marketing/alliance commands
- scaffold: Support org-chart generation

Options:
- --dry-run: Preview without deploying
- --output <dir>: Scaffold locally only
- --json: Machine-readable output
- -y, --yes: Skip confirmation prompts

Co-Authored-By: Claude Opus 4.5 <[email protected]>
New tools:
- multi_token_payment: Send FET/USDC payments
- check_spending_limit: Read ERC-20 allowances
- create_delegation: Generate delegation handoff links
- get_fiat_link: Generate MoonPay/Transak URLs
- create_invoice: Create payment invoices
- list_invoices: Query invoices by status
- get_multi_token_balances: FET + USDC + BNB balances

Enhanced tools:
- scaffold_swarm: Support org-chart-based generation
- check_agent_commerce: Add invoice/delegation tracking
- deploy_swarm: Enhanced preset support

Total tools: 28 (all verified working)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
New rules:
- marketing-swarm.md: 7-role marketing team with pricing/intervals
- consumer-payments.md: Multi-token support, delegation, invoices
- workflow.md: 8-phase agent lifecycle (NEVER skip Phase 3: Optimize)

New skills:
- /alliance: Deploy 27-agent ASI Alliance
- /welcome: Onboarding flow for new users

Updated:
- payment-protocol.md: Verified official imports available
- uagent-patterns.md: Runtime-verified wallet access patterns
- build-agent, build-swarm, deploy: Phase 3 optimization step

Co-Authored-By: Claude Opus 4.5 <[email protected]>
New documentation:
- workflow.md: Complete 8-phase agent lifecycle
- marketing-team.md: 7-agent marketing swarm guide
- tutorial-marketing-team.md: Step-by-step deployment tutorial
- people-to-swarm.md: Org chart to agent transformation
- the-agent-economy.md: Economic infrastructure deep dive
- playbook.md: Comprehensive agent development playbook
- openclaw-implementation.md: OpenCLaw integration guide
- stack.md: Technology stack overview
- sequence.md: Agent interaction diagrams

Updated docs to reference new commands and patterns.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Marketing Team agents (7 fully working examples):
- writer.py: Content creation via ASI1-mini
- social.py: Twitter/X posting and scheduling
- community.py: Telegram group management
- analytics.py: Engagement reports
- outreach.py: Partnership pitches via Resend
- ads.py: Ad copy and A/B testing
- strategy.py: Campaign coordination + cross-agent delegation

Org chart templates (YAML):
- startup.yaml: 2 agents (founders)
- smb.yaml: 6 agents (3 C-suite + 3 depts)
- enterprise.yaml: 14 agents (5 C-suite + 6 depts + 3 teams)

Updated:
- CLAUDE.md: Document new commands and workflow
- README.md: Marketing and Alliance command docs
- smoke-tests: Verify 9 templates, 16 presets

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Remove 17 compiled JavaScript files that were accidentally committed to src/.
These files should only exist in dist/ after running npm run build.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add a self-improvement system that captures learnings from sessions
and creates PRs to improve the toolkit.

New features:
- /improve skill: Analyzes session, extracts learnings, creates PR
- docs/self-improvement.md: Full documentation of the system
- Added to CLAUDE.md slash commands

Bug fixes discovered during testing:
- MCP tests hang: Server started unconditionally on import
  Fix: Guard server startup with entry point check
- Stale genesis template tests: Removed (replaced by swarm-starter)

The /improve workflow:
1. Analyze session for errors fixed and patterns discovered
2. Check for duplicates against existing rules
3. Present learnings to user for selection
4. Test changes (npm run build && npm run test)
5. Create branch, commit, push, and open PR

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Comment on lines +419 to +429
await ctx.send(sender, ChatMessage(
timestamp=datetime.now(),
msg_id=msg.msg_id,
content=[TextContent(text=response)],
))

await ctx.send(sender, ChatMessage(
timestamp=datetime.now(),
msg_id=msg.msg_id,
content=[EndSessionContent()],
))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The consumer-commerce.ts template reuses the incoming msg_id for outgoing messages, instead of generating a new unique ID for each, which is inconsistent with other templates.
Severity: HIGH

Suggested Fix

Modify the template to generate a new unique ID for each outgoing ChatMessage. This can be done by setting the msg_id field to the result of uuid4(), aligning it with the pattern used in the reply() helper function found in other templates.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/templates/src/templates/consumer-commerce.ts#L419-L429

Potential issue: In the `consumer-commerce.ts` template, the generated Python code
reuses the `msg_id` from the incoming message for two separate outgoing `ChatMessage`
objects. This is incorrect, as the established protocol and all other templates generate
a new unique ID using `uuid4()` for each outgoing message. Sending multiple messages
with the same ID can cause protocol tracking issues on the receiving end, potentially
leading to one message overriding the other or the session terminating before the
response is correctly processed.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant