跳到主要内容

viben idea

AI-driven idea generation command that analyzes project codebase to automatically generate improvement suggestions.

Overview

The viben idea command analyzes the project codebase to automatically generate improvement suggestions. It supports 6 built-in types and user-defined custom types. Generated ideas can be converted to tasks using the promote command.

Built-in Types

TypeDescription
code_improvementsCode improvements - improvement opportunities based on existing patterns
ui_ux_improvementsUI/UX improvements - visual and interaction enhancements
documentation_gapsDocumentation gaps - missing or insufficient documentation
security_hardeningSecurity hardening - security vulnerabilities and hardening measures
performance_optimizationsPerformance optimizations - performance bottlenecks and optimization techniques
code_qualityCode quality - code quality improvements and refactoring patterns

Command Structure

viben idea <subcommand> [options]

Subcommand Overview

SubcommandDescription
generateGenerate ideas (core command)
listList generated ideas
list-typesList available idea types
viewView idea details
promoteConvert idea to task
clearClear all ideas and sessions
removeDelete idea

Generate Ideas

viben idea generate --types <type>... [options]

Required Parameters:

ParameterDescription
--types, -tIdea types to generate, multiple selection allowed

Optional Parameters:

ParameterDescriptionDefault
--output, -oOutput directory.viben/ideas/
--model, -mAI modelGlobal config
--max-ideasMaximum ideas per type5
--appendAppend mode, preserve existing ideasfalse
--focusFocus area for generation-
--overrideForce regenerate all typesfalse
--jsonJSON format output for progressfalse

Examples:

# Generate code improvements and code quality ideas
viben idea generate --types code_improvements code_quality

# Use custom type
viben idea generate --types my_custom_type --model opus

# Append mode, maximum 10 per type
viben idea generate -t security_hardening --append --max-ideas 10

List Ideas

viben idea list [options]

Options:

ParameterDescription
--type, -tFilter by type
--effort, -eFilter by effort (trivial/small/medium/large/complex)
--status, -sFilter by status (draft/promoted/dismissed)
--jsonJSON format output

Output:

Ideas (3):

[a1b2c3d4] code_improvements draft small
Add retry logic to API calls
Add automatic retry logic for API calls to handle temporary network failures
Why: Current code fails directly on network errors without retry mechanism
Files:
- src/api/client.ts
- src/api/request.ts
Implementation:
Use exponential backoff strategy, retry up to 3 times

[b2c3d4e5] code_improvements draft medium
Extract common validators
Extract common validation logic into a separate module
Why: Multiple places have duplicate validation logic
Files:
- src/utils/validators.ts
- src/forms/*.ts

[c3d4e5f6] security_hardening promoted small
Add input sanitization
Add input sanitization to prevent XSS attacks
Why: User input is rendered directly without filtering
Task: 03-11-input-sanitization

List Types

viben idea list-types [--json]

Output:

TYPE SOURCE DESCRIPTION
code_improvements builtin Code improvements - improvement opportunities based on existing patterns
ui_ux_improvements builtin UI/UX improvements - visual and interaction enhancements
documentation_gaps builtin Documentation gaps - missing or insufficient documentation
security_hardening builtin Security hardening - security vulnerabilities and hardening measures
performance_optimizations builtin Performance optimizations - performance bottlenecks and optimization techniques
code_quality builtin Code quality - code quality improvements and refactoring patterns
api_design custom docs/idea-types/api_design.md

View Idea Details

viben idea view <idea-id> [--json]

Output:

[a1b2c3d4] code_improvements draft small
Add retry logic to API calls
Created: 2026-03-11T14:30:00Z

Description
Add automatic retry logic for API calls to handle temporary network failures

Rationale
Current code fails directly on network errors without retry mechanism

Affected Files
- src/api/client.ts
- src/api/request.ts

Existing Patterns
- error handling in src/utils/error.ts

Implementation
Use exponential backoff strategy, retry up to 3 times.
1. Add retry wrapper in src/api/client.ts
2. Configure maximum retry count and backoff time
3. Retry on retriable error codes

Promote Idea to Task

viben idea promote <idea-id> [options]

Options (consistent with viben task create):

ParameterDescriptionDefault
-s, --slug <name>Task identifierGenerated from idea title
-b, --branch <branch>Custom branch namefeature/<slug>
-a, --assignee <dev>Assign toCurrent developer
-p, --priority <priority>Priority (P0-P3)Mapped from effort
-d, --description <text>Task descriptionIdea's description
--agent <agent-id>Associated agent configuration-
--executor <type>Executor typeCLAUDE_CODE
--model <model>Model to use-
--startAutomatically add to queuefalse
--worktreeRun in git worktreefalse
--jsonJSON format outputfalse

Effort -> Priority Default Mapping:

EffortPriority
trivialP3
smallP3
mediumP2
largeP1
complexP1

Examples:

# Convert idea to task (simplest way)
viben idea promote ci-001

# Specify priority and slug
viben idea promote ci-001 --slug add-retry-logic --priority P1

# Create and automatically start task
viben idea promote ci-001 --start

# Develop in isolated worktree
viben idea promote ci-001 --worktree --start

# Full example
viben idea promote ci-001 \
--slug add-retry-logic \
--branch feature/api-retry \
--priority P1 \
--executor CLAUDE_CODE \
--model opus \
--start

Clear Ideas

Clear all ideas and sessions. This is a destructive operation that removes all session directories under .viben/ideas/.

viben idea clear [--force] [--json]

Options:

ParameterDescription
--force, -fSkip confirmation warning
--jsonJSON format output

Examples:

# Clear all ideas (shows warning)
viben idea clear

# Skip warning and clear directly
viben idea clear --force

# JSON format output
viben idea clear --force --json

Output:

Warning: This will remove ALL ideas and sessions. Use --force to skip this warning.
Cleared 15 idea(s)
备注

clear is a shortcut for remove --all with clearer semantics. Both commands display a warning by default and require --force to skip.

Remove Ideas

viben idea remove <idea-id>... [--type <type>] [--all]

Options:

ParameterDescription
--type, -tDelete all ideas of specified type
--allDelete all ideas

Examples:

# Delete single idea
viben idea remove ci-001

# Delete multiple ideas
viben idea remove ci-001 ci-002 sq-001

# Delete all ideas of a type
viben idea remove --type code_improvements

# Clear all ideas
viben idea remove --all

Data Structure

Directory Structure

.viben/
└── ideas/
└── <date>-<slug>/ # One directory per generation
├── idea.json # Metadata
├── idea_code_improvements_<name1>.md # Each idea in separate file
├── idea_code_improvements_<name2>.md
├── idea_security_hardening_<name1>.md
└── idea_my_custom_type_<name1>.md

docs/
└── idea-types/ # Custom type prompt templates
├── api_design.md
└── refactoring.md

idea.json Format

{
"id": "03-11-api-improvement",
"types": ["code_improvements", "security_hardening"],
"model": "sonnet",
"summary": {
"total_ideas": 10,
"by_type": {"code_improvements": 5, "security_hardening": 5},
"by_status": {"draft": 9, "promoted": 1}
},
"files": [
"idea_code_improvements_add-retry-logic.md",
"idea_code_improvements_extract-validators.md",
"idea_security_hardening_input-sanitization.md"
],
"generated_at": "2026-03-11T14:30:00Z",
"updated_at": "2026-03-11T14:35:00Z"
}

idea_*.md Format

---
id: a1b2c3d4
type: code_improvements
name: add-retry-logic
title: Add retry logic to API calls
description: Add automatic retry logic for API calls to handle temporary network failures
rationale: Current code fails directly on network errors without retry mechanism
estimated_effort: small
status: draft
promoted_to: null
created_at: 2026-03-11T14:30:00Z
affected_files:
- src/api/client.ts
- src/api/request.ts
existing_patterns:
- error handling in src/utils/error.ts
---

Use exponential backoff strategy, retry up to 3 times.

1. Add retry wrapper in `src/api/client.ts`
2. Configure maximum retry count and backoff time
3. Retry on retriable error codes (e.g., 5xx, network timeout)

Execution Flow

viben idea generate Pipeline

+-------------------------------------------------------------+
| GENERATE PIPELINE |
+-------------------------------------------------------------+
| |
| STEP 1: Parse Arguments |
| +-------------------------------------+ |
| | - Validate --types parameter | |
| | - Load type prompt (built-in or | |
| | custom) | |
| | - Determine output directory & model | |
| +-------------------------------------+ |
| | |
| v |
| STEP 2: Create Output Directory |
| +-------------------------------------+ |
| | .viben/ideas/<date>-<slug>/ | |
| | - Initialize idea.json | |
| +-------------------------------------+ |
| | |
| v |
| STEP 3: Generate Ideas in Parallel |
| +----------+ +----------+ +----------+ |
| | type_1 | | type_2 | | type_n | |
| | AI Agent | | AI Agent | | AI Agent | |
| +----+-----+ +----+-----+ +----+-----+ |
| | | | |
| v v v |
| +---------------------------------------------+ |
| | idea_type1_name1.md, idea_type1_name2.md... | |
| | idea_type2_name1.md, idea_type2_name2.md... | |
| | idea_typen_name1.md, idea_typen_name2.md... | |
| +---------------------------------------------+ |
| | |
| v |
| STEP 4: Update Metadata |
| +-------------------------------------+ |
| | - Count ideas by type | |
| | - Update idea.json summary | |
| +-------------------------------------+ |
| |
+-------------------------------------------------------------+

Custom Types

Users can create custom type prompt templates in docs/idea-types/*.md.

---
name: api_design
description: API design improvements - RESTful conventions, interface consistency, version management
max_ideas: 5
---

# API Design Ideation Agent

You are an API design expert responsible for analyzing the project codebase and proposing API improvement suggestions.

## Analysis Focus

1. RESTful convention compliance
2. Interface naming consistency
3. Request/response format uniformity
4. Error handling standards
5. API version management

## Output Requirements

For each improvement suggestion, provide:

- **title**: Brief description
- **description**: Improvement content
- **rationale**: Why improvement is needed
- **affected_files**: Files involved
- **existing_patterns**: Existing patterns for reference
- **implementation_approach**: Implementation method
- **estimated_effort**: trivial/small/medium/large/complex

YAML Header Fields

Custom type templates use YAML frontmatter with the following fields:

FieldRequiredDescription
nameYesType identifier
descriptionYesType description (displayed in list-types)
focus_areasNoList of areas to focus on during analysis
max_ideasNoDefault maximum number of ideas, default 5
output_formatNoOutput format specification
modelNoPreferred model for this type

The body (after the YAML header) is the prompt content, sent directly to the AI.

Built-in Type Storage

Built-in types are stored in packages/core/templates/viben/idea-types/ and loaded directly from this directory at runtime:

packages/core/templates/viben/idea-types/
code_improvements.md # Code improvements
code_quality.md # Code quality
documentation_gaps.md # Documentation gaps
performance_optimizations.md # Performance optimizations
security_hardening.md # Security hardening
ui_ux_improvements.md # UI/UX improvements

Type Lookup Order

The CLI looks up idea type prompts in the following order:

  1. docs/idea-types/<type>.md (project custom types, takes priority)
  2. packages/core/templates/viben/idea-types/<type>.md (built-in fallback)

This means:

  • Built-in types are available even without running viben init
  • Projects can override built-in types by placing files in docs/idea-types/
  • Custom types only need to be created in docs/idea-types/