技能财务分析
- 作者仓库星标 435
- 作者仓库 nvim
- 领域
- 数据
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @benbrastmckie · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 命令执行
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# Financial Analysis Skill
Thin wrapper that routes financial analysis research requests to the `financial-analysis-agent`.
**IMPORTANT**: This skill implements the skill-internal postflight pattern. After the subagent returns,
this skill handles all postflight operations (status update, artifact linking, git commit) before returning.
## Context Pointers
Reference (do not load eagerly):
- Path: `.claude/context/formats/return-metadata-file.md` - Metadata file schema
- Path: `.claude/context/patterns/jq-escaping-workarounds.md` - jq escaping patterns (Issue #1132)
Note: This skill is a thin wrapper. Context is loaded by the delegated agent, not this skill.
## Trigger Conditions
This skill activates when:
### Direct Invocation
- User runs `/research` on a task with language `founder:financial-analysis`
### When NOT to trigger
Do not invoke for:
- Cost breakdown from scratch (use skill-spreadsheet)
- Market sizing (use skill-market)
- General business analysis (use skill-analyze)
- Document review without data gathering (use skill-finance)
---
## Execution Flow
### Stage 1: Input Validation
Validate required inputs:
- `task_number` - Must be provided and exist in state.json
- `mode` - Optional, one of: REVIEW, DILIGENCE, AUDIT, FORECAST
```bash
# Lookup task
task_data=$(jq -r --argjson num "$task_number" \
'.active_projects[] | select(.project_number == $num)' \
specs/state.json)
# Validate exists
if [ -z "$task_data" ]; then
return error "Task $task_number not found"
fi
# Extract fields
task_type=$(echo "$task_data" | jq -r '.task_type // "founder"')
status=$(echo "$task_data" | jq -r '.status')
project_name=$(echo "$task_data" | jq -r '.project_name')
description=$(echo "$task_data" | jq -r '.description // ""')
forcing_data=$(echo "$task_data" | jq -r '.forcing_data // null')
```
---
### Stage 2: Preflight Status Update
```bash
bash .claude/scripts/update-task-status.sh preflight "$task_number" research "$session_id"
```
---
### Stage 3: Create Postflight Marker
```bash
padded_num=$(printf "%03d" "$task_number")
mkdir -p "specs/${padded_num}_${project_name}"
cat > "specs/${padded_num}_${project_name}/.postflight-pending" << EOF
{
"session_id": "${session_id}",
"skill": "skill-financial-analysis",
"task_number": ${task_number},
"operation": "research",
"reason": "Postflight pending: status update, artifact linking, git commit",
"created": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"stop_hook_active": false
}
EOF
```
---
### Stage 3a: Read Artifact Number
```bash
artifact_number=$(jq -r --argjson num "$task_number" \
'.active_projects[] | select(.project_number == $num) | .next_artifact_number // 1' \
specs/state.json)
artifact_padded=$(printf "%02d" "$artifact_number")
```
---
### Stage 4: Prepare Delegation Context
```json
{
"session_id": "{session_id}",
"delegation_depth": 1,
"delegation_path": ["orchestrator", "research", "skill-financial-analysis"],
"timeout": 3600,
"task_context": {
"task_number": "{N}",
"task_name": "{project_name}",
"description": "{description}",
"task_type": "{task_type}"
},
"artifact_number": "{artifact_number}",
"mode": "{mode if provided}",
"forcing_data": "{forcing_data from state.json if present}",
"metadata_file_path": "specs/{NNN}_{SLUG}/.return-meta.json"
}
```
---
### Stage 5: Invoke Subagent
**CRITICAL**: Use the **Agent** tool to spawn the subagent.
```
Tool: Agent (NOT Skill, NOT Plan)
Parameters:
- subagent_type: "financial-analysis-agent"
- prompt: [Include task_context, delegation_context, forcing_data]
- description: "Execute financial analysis for task {N}"
```
The subagent will:
- Ask forcing questions to gather financial data
- Generate XLSX spreadsheet with formulas
- Export financial-metrics.json for Typst integration
- Create research report
- Write metadata to .return-meta.json
---
### Stage 5b: Self-Execution Fallback
**CRITICAL**: If you performed the work above WITHOUT using the Agent tool (i.e., you read files,
wrote artifacts, or updated metadata directly instead of spawning a subagent), you MUST write a
`.return-meta.json` file now before proceeding to postflight. Use the schema from
`return-metadata-file.md` with the appropriate status value for this operation.
If you DID use the Agent tool, skip this stage -- the subagent already wrote the metadata.
---
## Postflight (ALWAYS EXECUTE)
The following stages MUST execute after work is complete, whether the work was done by a
subagent or inline (Stage 5b). Do NOT skip these stages for any reason.
### Stage 6: Read Metadata File
```bash
metadata_file="specs/${padded_num}_${project_name}/.return-meta.json"
if [ -f "$metadata_file" ] && jq empty "$metadata_file" 2>/dev/null; then
status=$(jq -r '.status' "$metadata_file")
# Extract artifacts array
else
status="failed"
fi
```
---
### Stage 7: Update Task Status (Postflight)
```bash
if [ "$status" = "researched" ]; then
bash .claude/scripts/update-task-status.sh postflight "$task_number" research "$session_id"
# Increment next_artifact_number
jq '(.active_projects[] | select(.project_number == '$task_number')).next_artifact_number =
(((.active_projects[] | select(.project_number == '$task_number')).next_artifact_number // 1) + 1)' \
specs/state.json > specs/tmp/state.json && mv specs/tmp/state.json specs/state.json
fi
```
---
### Stage 8: Link Artifacts
Link all artifacts (research report, spreadsheet, metrics JSON) to state.json using two-step jq pattern.
**Update TODO.md**: Link artifact per `@.claude/context/patterns/artifact-linking-todo.md` with `field_name=**Research**`, `next_field=**Plan**`.
---
### Stage 9: Git Commit
```bash
git add -A
git commit -m "task ${task_number}: complete financial analysis research
Session: ${session_id}
```
---
### Stage 10: Cleanup
```bash
rm -f "specs/${padded_num}_${project_name}/.postflight-pending"
rm -f "specs/${padded_num}_${project_name}/.return-meta.json"
```
---
### Stage 11: Return Brief Summary
```
Financial analysis research complete for task {N}:
- Mode: {MODE}, forcing questions completed
- Generated XLSX, JSON metrics, and research report
- Status updated to [RESEARCHED]
```
---
## MUST NOT (Postflight Boundary)
After the agent returns, this skill MUST NOT:
1. **Edit source files** - All work is done by agent
2. **Run build/test commands** - Verification is done by agent
3. **Use AskUserQuestion** - Interactive tools are for agent use only
4. **Analyze financial data** - Analysis is agent work
5. **Write reports or spreadsheets** - Artifact creation is agent work
The postflight phase is LIMITED TO:
- Reading agent metadata file
- Calling `update-task-status.sh` for status updates
- Incrementing `next_artifact_number` via jq
- Linking artifacts in state.json
- Git commit
- Cleanup of temp/marker files
Reference: @.claude/context/standards/postflight-tool-restrictions.md
章节与文件索引
按说明文件中的顺序排列。
上下文指针
触发条件
直接调用
何时不触发
第一阶段:输入验证
文件/命令 -> financial-analysis-agent · .claude/context/formats/return-metadata-file.md · .claude/context/patterns/jq-escaping-workarounds.md · /research · founder:financial-analysis · task_number · mode · .return-meta.json
内容校验值 -> f434d10aeff9
当前原文的自动摘译,尚未人工审校。
上下文指针
参考(不要急于加载): 路径:
.claude/context/formats/return-metadata-file.md- 元数据文件模式 路径:.claude/context/patterns/jq-escaping-workarounds.md- jq 转义模式(问题#1132) 注意:此技能是一个薄包装器。上下文由委托代理加载,而不是由该技能加载。触发条件
该技能在以下情况下激活:
直接调用
用户在使用语言
founder:financial-analysis的任务上运行/research何时不触发
请勿调用以下目的: 从头开始进行成本细分(使用技能电子表格) 市场规模估算(使用技能市场) 一般业务分析(使用技能分析) 无需收集数据的文档审查(使用技能财务)
第一阶段:输入验证
验证所需的输入:
task_number- 必须提供并存在于 state.json 中mode- 可选,其中之一:审核、勤勉、审计、预测