一键导入
add-thunk
Add a Redux async thunk with loading/error states to governanceSlice. Use when adding new async data fetching.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Add a Redux async thunk with loading/error states to governanceSlice. Use when adding new async data fetching.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Scaffold a new dashboard chart component with registry, types, and proper theme integration.
Create a new customizable dashboard with its own chart registry, provider, and page. Use when adding dashboards like DRep or SPO dashboard.
Context window conservation rules. Invoke when approaching context limits or before large tasks.
Deep reflection on the skill learning system itself. Analyzes what's working, what's stale, and proposes structural improvements. The meta-skill.
End-of-session automation. Creates a journey and evolves skills based on session learnings.
Run the build and intelligently fix TypeScript errors with guardrails. Stops if fixes introduce more errors or the same error persists after 3 attempts.
| name | add-thunk |
| description | Add a Redux async thunk with loading/error states to governanceSlice. Use when adding new async data fetching. |
Add a new async thunk to the governance slice with proper loading/error state management.
$0 - Thunk name in camelCase (e.g., loadVoterStats)$1 - Service function name (e.g., fetchVoterStats)Edit src/store/governanceSlice.ts - add to GovernanceState interface:
// Data
${dataPropertyName}: ${DataType} | null;
// Loading state
isLoading${PascalCaseName}: boolean;
// Error state
${camelCaseName}Error: string | null;
Add to initialState:
${dataPropertyName}: null,
isLoading${PascalCaseName}: false,
${camelCaseName}Error: null,
Add the service function import at the top:
import { ${$1} } from "@/services/api";
Add after existing thunks (before const governanceSlice = createSlice):
export const ${$0} = createAsyncThunk(
"governance/${$0}",
async (${paramIfNeeded}, { rejectWithValue }) => {
try {
const data = await ${$1}(${paramIfNeeded});
if (!data) {
return rejectWithValue("${Human readable name} not found");
}
return data;
} catch (error) {
return rejectWithValue(
error instanceof Error ? error.message : "Failed to load ${human readable name}"
);
}
}
);
If you need a setter action, add to reducers:
set${PascalCaseName}: (state, action: PayloadAction<${DataType} | null>) => {
state.${dataPropertyName} = action.payload;
state.${camelCaseName}Error = null;
},
Add to extraReducers builder:
// Load ${human readable name}
builder
.addCase(${$0}.pending, (state) => {
state.isLoading${PascalCaseName} = true;
state.${camelCaseName}Error = null;
})
.addCase(${$0}.fulfilled, (state, action) => {
state.isLoading${PascalCaseName} = false;
state.${dataPropertyName} = action.payload;
})
.addCase(${$0}.rejected, (state, action) => {
state.isLoading${PascalCaseName} = false;
state.${camelCaseName}Error = action.payload as string;
});
Add to exports:
export const {
// ... existing exports
set${PascalCaseName},
} = governanceSlice.actions;
export const loadStats = createAsyncThunk(
"governance/loadStats",
async (_, { rejectWithValue }) => {
// ...
}
);
export const loadDetail = createAsyncThunk(
"governance/loadDetail",
async (id: string, { rejectWithValue }) => {
// ...
}
);
export const loadFiltered = createAsyncThunk(
"governance/loadFiltered",
async ({ type, status }: { type: string; status: string }, { rejectWithValue }) => {
// ...
}
);
| Thunk Name | State Property | Loading State | Error State |
|---|---|---|---|
loadVoterStats | voterStats | isLoadingVoterStats | voterStatsError |
loadDRepDetails | drepDetails | isLoadingDRepDetails | drepDetailsError |
Import and dispatch the thunk in your component:
import { ${$0} } from "@/store/governanceSlice";
const dispatch = useAppDispatch();
useEffect(() => {
dispatch(${$0}());
}, [dispatch]);
Select data and loading state:
const { ${dataPropertyName}, isLoading${PascalCaseName} } = useAppSelector(
(state) => state.governance
);