Skip to content

Commit 9947ae7

Browse files
YuanyuanMa03claude
andauthored
feat: add mode system with 6 AI personality presets (#1255)
* docs: update contributors * docs: update contributors * feat: add mode system with 6 AI personality presets Add a /mode command that lets users switch between 6 interaction modes, each with distinct system prompts, UI themes, permission defaults, and response verbosity: - Default (⚡) — balanced, everyday development - Gentle (🌸) — patient explanations for learning - Dr. Sharp (🔍) — strict 3-phase code review workflow - Workhorse (🐴) — auto-execute, minimal confirmations - Token Saver (💰) — minimal replies to save tokens - Super AI (🧠) — deep analysis, proactive suggestions Custom modes can be defined via YAML files in ~/.claude/modes/. New files: - src/modes/types.ts — CCBMode interface - src/modes/defaults.ts — 6 built-in mode presets - src/modes/store.ts — mode state management with useSyncExternalStore - src/commands/mode/index.ts — command registration - src/commands/mode/mode.tsx — mode picker UI Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 6b205f5 commit 9947ae7

6 files changed

Lines changed: 429 additions & 0 deletions

File tree

src/commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { context, contextNonInteractive } from './commands/context/index.js'
1919
import diff from './commands/diff/index.js'
2020
import doctor from './commands/doctor/index.js'
2121
import memory from './commands/memory/index.js'
22+
import mode from './commands/mode/index.js'
2223
import help from './commands/help/index.js'
2324
import ide from './commands/ide/index.js'
2425
import init from './commands/init.js'
@@ -327,6 +328,7 @@ const COMMANDS = memoize((): Command[] => [
327328
mcp,
328329
memory,
329330
mobile,
331+
mode,
330332
model,
331333
outputStyle,
332334
remoteEnv,

src/commands/mode/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { Command } from '../../commands.js'
2+
3+
const mode = {
4+
type: 'local-jsx',
5+
name: 'mode',
6+
description:
7+
'Switch interaction mode (default, gentle, sharp, workhorse, token-saver, super-ai)',
8+
isEnabled: () => true,
9+
argumentHint: '<mode-slug>',
10+
load: () => import('./mode.js'),
11+
} satisfies Command
12+
13+
export default mode

src/commands/mode/mode.tsx

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { useMemo } from 'react';
2+
import { Box, Text } from '@anthropic/ink';
3+
import { Select } from '../../components/CustomSelect/select.js';
4+
import type { LocalJSXCommandCall, LocalJSXCommandOnDone } from '../../types/command.js';
5+
import { getCurrentModeSlug, listModes, setCurrentMode } from '../../modes/store.js';
6+
7+
function ModePicker({ onDone }: { onDone: LocalJSXCommandOnDone }) {
8+
const modes = listModes();
9+
const currentSlug = getCurrentModeSlug();
10+
11+
const options = useMemo(
12+
() =>
13+
modes.map(m => ({
14+
label: (
15+
<Text>
16+
{m.icon} {m.name}{' '}
17+
<Text dimColor>
18+
({m.slug}) — {m.description}
19+
</Text>
20+
</Text>
21+
),
22+
value: m.slug,
23+
})),
24+
[modes],
25+
);
26+
27+
function handleSelect(slug: string) {
28+
setCurrentMode(slug);
29+
const target = modes.find(m => m.slug === slug);
30+
onDone(`${target?.icon} Mode switched to: ${target?.name} (${target?.slug}) — ${target?.description}`, {
31+
display: 'system',
32+
});
33+
}
34+
35+
function handleCancel() {
36+
onDone('Mode selection cancelled.', { display: 'system' });
37+
}
38+
39+
return (
40+
<Box flexDirection="column">
41+
<Box marginBottom={1} flexDirection="column">
42+
<Text color="remember" bold>
43+
Select mode
44+
</Text>
45+
<Text dimColor>Arrow keys to navigate, Enter to select, Esc to cancel.</Text>
46+
</Box>
47+
<Select
48+
defaultValue={currentSlug}
49+
options={options}
50+
onChange={handleSelect}
51+
onCancel={handleCancel}
52+
visibleOptionCount={modes.length}
53+
/>
54+
</Box>
55+
);
56+
}
57+
58+
export const call: LocalJSXCommandCall = async (onDone, _context, args) => {
59+
const slug = args?.trim().toLowerCase();
60+
61+
if (slug) {
62+
const modes = listModes();
63+
const target = modes.find(m => m.slug === slug);
64+
if (!target) {
65+
const available = modes.map(m => `${m.icon} ${m.slug}${m.description}`).join('\n');
66+
onDone(`Unknown mode: "${slug}"\n\nAvailable modes:\n${available}`, {
67+
display: 'system',
68+
});
69+
return;
70+
}
71+
setCurrentMode(slug);
72+
onDone(`${target.icon} Mode switched to: ${target.name} (${target.slug}) — ${target.description}`, {
73+
display: 'system',
74+
});
75+
return;
76+
}
77+
78+
return <ModePicker onDone={onDone} />;
79+
};

src/modes/defaults.ts

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
import type { CCBMode } from './types.js'
2+
3+
const DR_SHARP_SYSTEM_PROMPT = `You are Dr. Sharp, a meticulous code reviewer and diagnostician.
4+
5+
## Core Principles
6+
7+
1. **Diagnose before acting.** Never jump to a fix. Understand the root cause first.
8+
2. **Minimal effective change.** The smallest diff that fully solves the problem wins.
9+
3. **Evidence-based.** Every claim must be backed by code, logs, or behavior you can point to.
10+
4. **No assumptions.** If you're unsure, ask. Never guess about behavior you haven't verified.
11+
12+
## Three-Phase Workflow
13+
14+
### Phase 1: Deep Diagnosis
15+
- Read the relevant code paths end-to-end
16+
- Trace the execution flow from input to output
17+
- Identify the exact point where behavior diverges from expectation
18+
- State your diagnosis clearly before proceeding
19+
20+
### Phase 2: Action Strategy
21+
- List 2-3 possible approaches with trade-offs
22+
- Recommend the minimal effective approach
23+
- Consider: side effects, edge cases, regression risks
24+
- Explain WHY this approach over alternatives
25+
26+
### Phase 3: Mirror Self
27+
- After implementing, re-read the original problem statement
28+
- Verify your fix addresses the root cause, not just the symptom
29+
- Check for related issues the same root cause might trigger
30+
- Run relevant tests to confirm
31+
32+
## Communication Style
33+
34+
- Be direct and specific. No filler.
35+
- Use code references (file:line) when pointing to issues.
36+
- When reviewing: "This will break when X because Y. Fix: Z."
37+
- When diagnosing: "The bug is at X:42. The condition Y evaluates to Z because..."
38+
- Never apologize for finding problems — that's the job.
39+
40+
## Red Flags to Always Check
41+
42+
- Error handling: are errors caught, logged, and propagated correctly?
43+
- Edge cases: null, empty, boundary values, concurrent access
44+
- Security: injection, auth bypass, data leaks
45+
- Performance: N+1 queries, unnecessary allocations, missing indexes
46+
- Type safety: any \`as any\` casts, missing null checks, loose types`
47+
48+
export const DEFAULT_MODES: CCBMode[] = [
49+
{
50+
name: 'Default',
51+
slug: 'default',
52+
description: 'Balanced mode for everyday development',
53+
icon: '⚡',
54+
systemPrompt: '',
55+
ui: {
56+
accentColor: '#D77757',
57+
promptPrefix: '',
58+
},
59+
companionSpecies: 'duck',
60+
permissions: {
61+
defaultMode: 'default',
62+
memoryExtract: true,
63+
},
64+
responseStyle: {
65+
verbosity: 'normal',
66+
},
67+
},
68+
{
69+
name: 'Gentle',
70+
slug: 'gentle',
71+
description: 'Patient explanations, great for learning',
72+
icon: '🌸',
73+
companionSpecies: 'cat',
74+
systemPrompt:
75+
'You are in gentle learning mode. Explain concepts clearly with examples. ' +
76+
'When correcting mistakes, be encouraging and explain why. ' +
77+
'Offer to show alternatives before making changes. ' +
78+
'Use analogies to help understand complex concepts.',
79+
ui: {
80+
accentColor: '#E8A0BF',
81+
promptPrefix: 'gentle',
82+
},
83+
permissions: {
84+
defaultMode: 'default',
85+
memoryExtract: true,
86+
},
87+
responseStyle: {
88+
verbosity: 'verbose',
89+
},
90+
},
91+
{
92+
name: 'Dr. Sharp',
93+
slug: 'sharp',
94+
description: 'Strict review, focused on code quality',
95+
icon: '🔍',
96+
companionSpecies: 'owl',
97+
systemPrompt: DR_SHARP_SYSTEM_PROMPT,
98+
ui: {
99+
accentColor: '#5769F7',
100+
promptPrefix: 'sharp',
101+
},
102+
permissions: {
103+
defaultMode: 'default',
104+
memoryExtract: true,
105+
},
106+
responseStyle: {
107+
verbosity: 'normal',
108+
},
109+
},
110+
{
111+
name: 'Workhorse',
112+
slug: 'workhorse',
113+
description: 'Auto-execute, minimal confirmations',
114+
icon: '🐴',
115+
companionSpecies: 'capybara',
116+
systemPrompt:
117+
'You are in workhorse mode. Execute tasks efficiently with minimal back-and-forth. ' +
118+
'Make reasonable assumptions and proceed. ' +
119+
'Only ask for clarification when truly ambiguous. ' +
120+
'Batch related changes together.',
121+
ui: {
122+
accentColor: '#8B7355',
123+
promptPrefix: 'work',
124+
},
125+
permissions: {
126+
defaultMode: 'acceptEdits',
127+
memoryExtract: false,
128+
},
129+
responseStyle: {
130+
verbosity: 'minimal',
131+
},
132+
},
133+
{
134+
name: 'Token Saver',
135+
slug: 'token-saver',
136+
description: 'Minimal replies, save tokens',
137+
icon: '💰',
138+
companionSpecies: 'snail',
139+
systemPrompt:
140+
'You are in token-saving mode. ' +
141+
'Give the shortest correct answer. ' +
142+
'Skip explanations unless asked. ' +
143+
'Use code blocks directly without preamble. ' +
144+
'No pleasantries or filler.',
145+
ui: {
146+
accentColor: '#4A7C59',
147+
promptPrefix: 'save',
148+
},
149+
permissions: {
150+
defaultMode: 'acceptEdits',
151+
memoryExtract: false,
152+
},
153+
responseStyle: {
154+
verbosity: 'minimal',
155+
},
156+
},
157+
{
158+
name: 'Super AI',
159+
slug: 'super-ai',
160+
description: 'Deep thinking, comprehensive analysis',
161+
icon: '🧠',
162+
companionSpecies: 'dragon',
163+
systemPrompt:
164+
'You are in super AI mode. Think deeply before responding. ' +
165+
'Consider multiple approaches and explain trade-offs. ' +
166+
'Proactively identify related issues and suggest improvements. ' +
167+
'Use structured analysis for complex problems. ' +
168+
'Reference relevant best practices and patterns.',
169+
ui: {
170+
accentColor: '#9B59B6',
171+
promptPrefix: 'super',
172+
},
173+
permissions: {
174+
defaultMode: 'default',
175+
memoryExtract: true,
176+
},
177+
responseStyle: {
178+
verbosity: 'verbose',
179+
},
180+
},
181+
]

0 commit comments

Comments
 (0)