关于
This skill automatically adds PUT workflow annotations to source files using language-specific comment syntax across 30+ languages. It handles annotation generation, multiline formatting, .internal variables, and validation through automatic comment prefix detection. Use it when documenting workflows in existing codebases, data pipelines, or multi-step computations after creating an annotation plan.
快速安装
Claude Code
推荐npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/annotate-source-files在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Annotate Source Files
Add PUT workflow annotations → putior extracts structured workflow data + generates Mermaid diagrams.
Use When
- After
analyze-codebase-workflow+ annotation plan - Add workflow docs new/existing src
- Enrich auto-detected w/ manual labels + connections
- Doc data pipelines, ETL, multi-step computations
In
- Required: Src files to annotate
- Required: Annotation plan or workflow steps knowledge
- Optional: Style — single-line or multiline (default: single-line)
- Optional: Use
put_generate()skeletons? (default: yes)
Do
Step 1: Determine Comment Prefix
Each lang has specific prefix. get_comment_prefix() → correct one.
library(putior)
# Common prefixes
get_comment_prefix("R") # "#"
get_comment_prefix("py") # "#"
get_comment_prefix("sql") # "--"
get_comment_prefix("js") # "//"
get_comment_prefix("ts") # "//"
get_comment_prefix("go") # "//"
get_comment_prefix("rs") # "//"
get_comment_prefix("m") # "%"
get_comment_prefix("lua") # "--"
→ String like "#", "--", "//", or "%".
Line + block comments: putior detects annotations in both line comments (
//,#,--) + C-style block comments (/* */,/** */). JS/TS both//+/* */scanned. Python triple-quote strings (''' ''') not detected — use#for Python.
If err: Ext not recognized → lang may not be supported. Check get_supported_extensions(). Unsupported langs → use # conventional default.
Step 2: Generate Skeletons
put_generate() → annotation templates based on auto-detected I/O.
# Print suggestions to console
put_generate("./src/etl/")
# Single-line style (default)
put_generate("./src/etl/", style = "single")
# Multiline style for complex annotations
put_generate("./src/etl/", style = "multiline")
# Copy to clipboard for pasting
put_generate("./src/etl/", output = "clipboard")
Example out for R file:
# put id:'extract_data', label:'Extract Customer Data', input:'customers.csv', output:'raw_data.internal'
Example out for SQL:
-- put id:'load_data', label:'Load Customer Table', output:'customers'
→ 1+ annotation comment lines per file, pre-filled w/ detected fn names + I/O.
If err: No suggestions → file may not have recognizable I/O patterns. Write annotations manually.
Step 3: Refine Annotations
Edit generated skeletons → accurate labels, connections, metadata.
Annotation syntax:
<prefix> put id:'unique_id', label:'Human Readable Label', input:'file1.csv, file2.rds', output:'result.parquet, summary.internal'
Fields:
id(required): Unique ID, for node connectionslabel(required): Human-readable desc shown diagraminput: Comma-separated insoutput: Comma-separated outs.internalext: Marks in-memory vars (not persisted between scripts)node_type: Mermaid shape + class styling. Values:"input"— stadium shape([...])data srcs + config"output"— subroutine shape[[...]]generated artifacts"process"— rectangle[...]processing steps (default)"decision"— diamond{...}conditional logic"start"/"end"— stadium shape([...])entry/terminal
Example w/ node_type:
# put id:'config', label:'Load Config', node_type:'input', output:'config.internal'
# put id:'transform', label:'Apply Rules', node_type:'process', input:'config.internal', output:'result.rds'
# put id:'report', label:'Generate Report', node_type:'output', input:'result.rds'
Multiline syntax (complex):
# put id:'complex_step', \
# label:'Multi-line Label', \
# input:'data.csv, config.yaml', \
# output:'result.parquet'
Block comment syntax (//-prefix langs only: JS, TS, Go, Rust, C, C++, Java, etc.):
Langs w/ // line comments also support PUT in /* */ + /** */ blocks. Use * put as line prefix inside block body:
/* put id:'init', label:'Initialize Config', output:'config.internal' */
/**
* put id:'process', \
* label:'Process Records', \
* input:'config.internal, records.json', \
* output:'results.json'
*/
function processRecords(config, records) {
// ...
}
JSDoc annotations useful documenting workflow + API docs:
/**
* Transform raw sensor data into normalized readings.
* put id:'normalize', label:'Normalize Sensor Data', input:'raw_readings.json', output:'normalized.parquet'
*/
export function normalizeSensorData(readings: SensorReading[]): NormalizedData {
// ...
}
Note: Block comment annotations not supported for
#-prefix (R, Python, Shell) or---prefix (SQL, Lua). Line comments only those. Block-originated no backslash continuation across lines.
Cross-file data flow (connect scripts via file-based I/O):
# Script 1: extract.R
# put id:'extract', label:'Extract Data', output:'raw_data.internal, raw_data.rds'
data <- read.csv("source.csv")
saveRDS(data, "raw_data.rds")
# Script 2: transform.R
# put id:'transform', label:'Transform Data', input:'raw_data.rds', output:'clean_data.parquet'
data <- readRDS("raw_data.rds")
arrow::write_parquet(clean, "clean_data.parquet")
→ Annotations refined w/ accurate IDs, labels, I/O reflecting actual data flow.
If err: Unsure I/O → .internal ext for in-memory intermediates + explicit file names for persisted.
Step 4: Insert Annotations
Place at top of file or immediately above relevant code block.
Placement conventions:
- File-level: Top after shebang or header comment
- Block-level: Immediately above code block it describes
- Multi per file: Distinct workflow phases
Example in R:
#!/usr/bin/env Rscript
# ETL Extract Script
#
# put id:'read_source', label:'Read Source Data', input:'raw_data.csv', output:'df.internal'
df <- read.csv("raw_data.csv")
# put id:'clean_data', label:'Clean and Validate', input:'df.internal', output:'clean.rds'
df_clean <- df[complete.cases(df), ]
saveRDS(df_clean, "clean.rds")
Edit tool → insert into existing files no disturb surrounding.
→ Annotations inserted at appropriate locations per file.
If err: Break syntax highlighting → verify prefix correct for lang. PUT = std comments + should not affect exec.
Step 5: Validate
Run putior validation → syntax + connectivity.
# Scan annotated files
workflow <- put("./src/", validate = TRUE)
# Check for validation issues
print(workflow)
cat(sprintf("Total nodes: %d\n", nrow(workflow)))
# Verify connections by checking input/output overlap
inputs <- unlist(strsplit(workflow$input, ",\\s*"))
outputs <- unlist(strsplit(workflow$output, ",\\s*"))
connected <- intersect(inputs, outputs)
cat(sprintf("Connected data flows: %d\n", length(connected)))
# Generate diagram to visually inspect
cat(put_diagram(workflow, theme = "github", show_source_info = TRUE))
# Merge with auto-detected for maximum coverage
merged <- put_merge("./src/", merge_strategy = "supplement")
cat(put_diagram(merged, theme = "github"))
→ All annotations parse no err. Diagram shows connected workflow. put_merge() fills gaps from auto-detection.
If err: Common issues:
- Missing close quote:
id:'name→id:'name' - Double quotes inside:
id:"name"→id:'name' - Duplicate IDs across files: each
idmust be unique across entire scanned dir - Backslash continuation wrong line:
\must be last char before newline
Check
- Every annotated file has syntactically valid PUT annotations
-
put("./src/")returns df w/ expected node count - No duplicate
idvalues across scanned dir -
put_diagram()produces connected flowchart (not all isolated) - Multiline annotations (if used) parse correct w/ backslash continuation
-
.internalvars appear only outputs, never cross-file ins - Files excluded via
excludeno appear in workflow (e.g.,put("./src/", exclude = "test_")skips test helpers)
Traps
- Quote nesting: PUT uses single quotes:
id:'name'. Double quotes → parsing issues when annotation in string ctx. - Duplicate IDs: Every
idmust be globally unique within scanned scope. Naming:<script>_<step>(e.g.,extract_read,transform_clean). - .internal as cross-file in:
.internalexists only during script exec. Pass data between scripts → persisted file format (.rds,.csv,.parquet) as out of one + in of next. - Missing connections: Disconnected nodes → check out filenames in 1 annotation exactly match in filenames in another (including exts).
- Wrong prefix:
#in SQL or//in Python → annotation treated as code not comment. Always verifyget_comment_prefix(). - Forget multiline continuation: Every continued line must end
\+ next line must start w/ comment prefix. - Python triple-quote strings: putior no scan (
''' ''',""" """). Always#for Python PUT. - Meta-pipeline annotations: Annotate build script that also scans for annotations (e.g., script calling
put()+put_diagram()) → script's own annotations appear in generated diagram. Exclude file from scanning (seegenerate-workflow-diagramTraps) or no PUT in build script itself.
→
analyze-codebase-workflow— prereq: produces annotation plan this followsgenerate-workflow-diagram— next: generate final from annotationsinstall-putior— putior installed before annotatingconfigure-putior-mcp— MCP tools interactive annotation assistance
GitHub 仓库
Frequently asked questions
What is the annotate-source-files skill?
annotate-source-files is a Claude Skill by pjt222. Skills package instructions and resources that Claude loads on demand, so Claude can perform annotate-source-files-related tasks without extra prompting.
How do I install annotate-source-files?
Use the install commands on this page: add annotate-source-files to Claude Code as a plugin, or clone its repository into your skills directory, then restart Claude so it picks up the skill.
What category does annotate-source-files belong to?
annotate-source-files is in the Meta category, tagged word, automation and data.
Is annotate-source-files free to use?
Yes. annotate-source-files is listed on AIMCP and free to install. It runs inside Claude, so no separate service account is required to use the skill itself.
相关推荐技能
Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。
这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。
该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。
SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。
