First, make an applicability judgment
- If the userhas not specified a working directory: pause immediately and first ask the user to provide a working directory.
- If the user is only asking "how should a budget be written / what principles are there", answer directly or give suggestions, and do not start this skill.
- If the user is 2026 Young Scientists A/B/C and the scenario belongs tothe lump-sum system: first clearly remind them that "usually no budget justification is required"; continue only when the user explicitly states that it is a historical template, a specific institution's requirement, or a budget-based scenario.
Required inputs
First ask the user to provide them in the format of skills/nsfc-budget/references/info_form.md . At minimum, obtain:
- Working directory (required)
- Proposal main text or other materials
- Project type:
general | local | youth - Budget basis: at least state whether "this is the total requested amount" or "this is the direct cost basis that needs explanation"
If the user has not provided everything, handle it according to the following rules:
- Total budget not provided: take the default value according to
config.yaml:defaults.total_budget_wan. - Target word count of the main text not provided: follow the recommended range according to
config.yaml:defaults.target_chars. - Per-section limit: according to
config.yaml:defaults.per_section_max_chars。 - Template not provided: according to
config.yaml:defaults.template_id。 - Legal values of budget mode: see
config.yaml:rules.budget_modes。 - Legal values of budget basis: see
config.yaml:rules.budget_scopes。
Process
Input
Provide the necessary inputs according to the user's request and the configuration file; missing information should be clearly listed and steps that depend on that input should be stopped.
Execution steps
- When a bug caused by a design flaw of this skill appears in the user's environment, first use
bensz-collect-bugsto record it according to the specification in~/.bensz-skills/bugs/; it is strictly forbidden to directly modify the source code of the skill already installed in the user's local Claude Code / Codex. - If the AI can still complete the user's task through a workaround, it should first record the bug, then continue to complete the current task.
- When the user explicitly requests a public reporting action such as "report bensz skills bugs", call the local
ghandbensz-collect-bugs, and only upload newly added bugs tohuangwb8/bensz-bugs; do not pull / clone the entire bug repository.
Goal: Based on the proposal main text and supplementary materials, write a budget justification that "can withstand both financial and academic scrutiny", and deliver an editable LaTeX project and budget.pdf。
Initialize run
First create the hidden workspace and the budget_spec.json skeleton:
python3 skills/nsfc-budget/scripts/init_budget_run.py \
--workdir <workdir> \
--project-type <general|local|youth> \
--template-id 01
If the user has already provided material paths, multiple --material <path>can be appended. The script will copy material snapshots to .bensz-api/task-{yyyymmdd-hhmm}-{简短描述}/nsfc-budget/{yyyy-mm-dd-hh-mm}/input/materials/.
If initialization is repeated within the same minute, the script will automatically append a suffix to avoid directory name conflicts, preventing run directories from contaminating each other.
Thoroughly understand the materials and form a "task-requirement-amount-basis" chain
After reading the main text and supplementary materials, first form an internal judgment within the hidden workspace, then fill in budget_spec.json:
- Every sum of money must be traceable toa specific research task。
- Each section must explainwhy to spend, where to spend, how it is calculated, and why this amount is reasonable。
- Do not fabricate equipment, collaborating units, number of tests, travel frequency, number of labor personnel, or price basis.
- When evidence is insufficient, either ask the user, or conservatively write "not listed for now / no collaborative transfer for now / no other source of funds for now"; do not fabricate.
For writing principles, see:skills/nsfc-budget/references/budget-writing-rules.md。
Fill in budget_spec.json
The script-generated budget_spec.json is theonly structured intermediate draft. At minimum complete:
meta: project title, project type, budget mode, working directory, output directory, template ID, word count targetbudget: total budget basis, total direct costs (if known), equipment/business/labor/collaborative transfer/other source amountssections: body paragraphs for the five sections (array)evidence: key calculation basis, necessary assumptions, points to be confirmed
Requirements:
设备费 + 业务费 + 劳务费 = 直接费用总额(if you have already clarified the direct cost basis)budget.*_wanandsections.*.amount_wanmust remain consistent, to avoid drift between two sources of amounts.合作研究转拨资金must not form a logical conflict with the first three items其他来源资金must state the source and use; if none, explicitly write "none"- Values such as amounts, word count limits, and tolerances must not be negative; when invalid, fix the JSON first rather than rendering it with defects.
Rendering, validation, iteration
Use the script to render the JSON into a LaTeX project, and leave the validation report and compilation log in a hidden directory:
python3 skills/nsfc-budget/scripts/render_budget_project.py \
--spec <workdir>/.bensz-api/task-{yyyymmdd-hhmm}-{简短描述}/nsfc-budget/{yyyy-mm-dd-hh-mm}/budget_spec.json
The script will:
- Copy the template to
<workdir>/<output_dirname>/ - Write the five sections into the corresponding
extraTex/*.tex - Validate amount relationships, paragraph lengths, visible character counts, and template/path constraints
- Validate whether
budget_spec.jsonis still located in<workdir>/.bensz-api/task-{yyyymmdd-hhmm}-{简短描述}/nsfc-budget/, ensuring the hidden workspace commitment is not broken - Automatically escape common LaTeX special characters (such as
%、#、&、_), reducing compilation failures caused by natural language body text - Save in the hidden directory
validation_report.md/json - If validation fails, the terminal will directly provide a summary of the first batch of errors and the
validation_report.mdpath - Compilation output
budget.pdf
If validation fails, first fix budget_spec.json and then rerun the script until it passes.
Manual review before delivery
Before delivery, at least review these points:
- Whether the budget basis is clearly stated: total requested amount vs direct costs
- Whether equipment/testing/travel/labor truly correspond one-to-one with the research tasks
- Whether there are sentences that are "written very fully but have no evidence"
- Whether there are hidden loopholes where "the amounts add up, but the logic does not"
- Whether there are traces of fabrication where "it should be written as none, but a paragraph was forced in"
By default, adopt the following structured strategy:
-
Strict overview: first explain that the budget complies with policy consistency, goal relevance, and economic rationality.
-
Item-by-item implementation: each section must at least clearly explain "use + calculation + necessity + basis".
-
Say less empty talk: do not write information-free sentences such as "to ensure the smooth progress of the project" or "is of great significance", unless they are immediately followed by specific tasks and expenditures.
-
Amounts serve tasks: the statement is not "financial prose"; every paragraph must be traceable back to the research plan.
-
Better to have nothing than something inferior: When materials are missing, be conservative first, ask questions first, clarify boundaries first; do not fill in the gaps yourself.
-
skills/nsfc-budget/references/info_form.md -
skills/nsfc-budget/references/budget-writing-rules.md -
skills/nsfc-budget/scripts/init_budget_run.py -
skills/nsfc-budget/scripts/render_budget_project.py -
skills/nsfc-budget/models/01/.template.yaml
Output
The final output must simultaneously contain:
<workdir>/<output_dirname>/: Complete LaTeX project<workdir>/<output_dirname>/budget.pdf
Intermediate processes are kept in:
<workdir>/.bensz-api/task-{yyyymmdd-hhmm}-{简短描述}/nsfc-budget/{yyyy-mm-dd-hh-mm}/
Output management
Intermediate files for new tasks of this Skill are uniformly written to ./.bensz-api/task-{yyyymmdd-hhmm}-{简短描述}/{skill名}/input|output|log/. The same task reuses one task root directory; only multi-Skill collaboration creates shared/. Formal deliverables are not written to this directory; historical hidden directories only allow explicitly compatible reading, migration, or cleanup.
Validation
After completion, execute the Skill's existing static checks, script validation, or manual review, and record the pass criteria.
Failure and recovery
Preserve error evidence and completed artifacts; retry from the most recent failed step only after the input, environment, or external dependency has recovered.
Constraints
- All intermediate files can only be placed in
<workdir>/.bensz-api/task-{yyyymmdd-hhmm}-{简短描述}/nsfc-budget/。 - Do not scatter drafts, logs, plans, screenshots, temporary JSON, or compilation intermediate files elsewhere in the working directory.
- Final visible deliverables are only placed in
<workdir>/<output_dirname>/(for default values seeconfig.yaml:defaults.output_dirname)。 template_id、output_dirname、.template.yamlinsection_files/latex_entry/pdf_namemust all berelatively safe paths; must not contain absolute paths,./..out-of-bounds segments.output_dirnamemust not point to the working directory root path, nor overlap with the hidden workspace<workdir>/.bensz-api/task-{yyyymmdd-hhmm}-{简短描述}/nsfc-budget/.
Common hard constraints
- When a task needs to be persisted to disk, use a unique
./.bensz-api/task-{yyyymmdd-hhmm}-{简短描述}/root directory; shared materials go intoshared/, and Skill-specific materials go into that Skill'sinput/、output/、log/。 - Formal deliverables, source code, and formal plans are saved according to project conventions and are not written to the task workspace; without authorization, do not overwrite, delete, migrate, or write remotely.
- Project maintenance changes check BAC availability and record requirements, AI outputs, tool results, file changes, and validation summaries; BAC only performs process auditing and does not replace attribution, responsibility, or compliance judgment.
- Do not record API Keys, access tokens, passwords, Cookies, environment/credential files, private Prompts, identity information, local usernames, hostnames, or unnecessary large volumes of raw data.
- File paths must be normalized and restricted to the authorized project scope; external URLs, subprocesses, and network access follow least privilege to prevent path traversal, SSRF, and command injection.
- The Skill version is uniquely recorded in its own
config.yaml:skill_info.version; public API, protocol, directory, or configuration changes synchronize documentation andCHANGELOG.md。 - Only design flaws in the Skill or Bensz infrastructure itself are handed to
bensz-collect-bugs; first write a sanitized version to~/.bensz-skills/bugs/, the current task is not interrupted, public reporting only occurs when the user explicitly requests it, and directly modifying the user's installed Skill source code is prohibited.
Skill-specific constraints
Must not exceed the scope declared by this Skill's description and the process above; do not disguise unverified information as definitive conclusions.