用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/nomos-guild/cgov --skill add-thunk命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 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.
正在显示 SKILL.md
| 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
);