本文へ移動
cccskills
無料GitHub で公開

annotate-source-files

Add PUT workflow annotations to source files using the correct language-specific comment prefix. Covers annotation syntax, skeleton generation via put_generate(), multiline annotations, .internal variables, and validation. Supports 30+ languages with automatic comment prefix detection. Use after analyzing a codebase and having an annotation plan, when adding workflow documentation to new or existing source files, or when documenting data pipelines, ETL processes, or multi-step computations.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md11.9 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Annotate Source Files

Add PUT workflow annotations to source files so putior can extract structured workflow data and generate Mermaid diagrams.

When to Use

  • After analyzing a codebase with analyze-codebase-workflow and having an annotation plan
  • Adding workflow documentation to new or existing source files
  • Enriching auto-detected workflows with manual labels and connections
  • Documenting data pipelines, ETL processes, or multi-step computations

Inputs

  • Required: Source files to annotate
  • Required: Annotation plan or knowledge of the workflow steps
  • Optional: Style preference: single-line or multiline (default: single-line)
  • Optional: Whether to use put_generate() for skeleton generation (default: yes)

Procedure

Step 1: Determine Comment Prefix

Each language has a specific comment prefix for PUT annotations. Use get_comment_prefix() to find the 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")  # "--"

Expected: A string like "#", "--", "//", or "%".

Line and block comments: putior detects annotations in both line comments (//, #, --) and C-style block comments (/* */, /** */). For JS/TS, both // and /* */ blocks are scanned. Python triple-quote strings (''' ''') are not detected — use # for Python annotations.

On failure: If the extension is not recognized, the file language may not be supported. Check get_supported_extensions() for the full list. For unsupported languages, use # as a conventional default.

Step 2: Generate Annotation Skeletons

Use put_generate() to create 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 output for an R file:

# put id:'extract_data', label:'Extract Customer Data', input:'customers.csv', output:'raw_data.internal'

Example output for SQL:

-- put id:'load_data', label:'Load Customer Table', output:'customers'

Expected: One or more annotation comment lines per source file, pre-filled with detected function names and I/O.

On failure: If no suggestions are generated, the file may not contain recognizable I/O patterns. Write annotations manually based on your understanding of the code.

Step 3: Refine Annotations

Edit the generated skeletons to add accurate labels, connections, and metadata.

Annotation syntax reference:

<prefix> put id:'unique_id', label:'Human Readable Label', input:'file1.csv, file2.rds', output:'result.parquet, summary.internal'

Fields:

  • id (required): Unique identifier, used for node connections
  • label (required): Human-readable description shown in diagram
  • input: Comma-separated list of input files or variables
  • output: Comma-separated list of output files or variables
  • .internal extension: Marks in-memory variables (not persisted between scripts)
  • node_type: Controls Mermaid node shape and class styling. Values:
    • "input" — stadium shape ([...]) for data sources and configuration
    • "output" — subroutine shape [[...]] for generated artifacts
    • "process" — rectangle [...] for processing steps (default)
    • "decision" — diamond {...} for conditional logic
    • "start" / "end" — stadium shape ([...]) for entry/terminal nodes

Example with 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 (for complex annotations):

# put id:'complex_step', \
#   label:'Multi-line Label', \
#   input:'data.csv, config.yaml', \
#   output:'result.parquet'

Block comment syntax (for //-prefix languages only: JS, TS, Go, Rust, C, C++, Java, etc.):

Languages that use // for line comments also support PUT annotations inside /* */ and /** */ block comments. Use * put as the line prefix inside the 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-style annotations are particularly useful when documenting workflow steps alongside API documentation:

/**
 * 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 are not supported for #-prefix languages (R, Python, Shell) or ---prefix languages (SQL, Lua). Use only line comments for those languages. Block-originated annotations do not support backslash continuation across lines.

Cross-file data flow (connecting 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")

Expected: Annotations refined with accurate IDs, labels, and I/O fields that reflect actual data flow.

On failure: If unsure about I/O, use .internal extension for in-memory intermediates and explicit file names for persisted data.

Step 4: Insert Annotations into Files

Place annotations at the top of each file or immediately above the relevant code block.

Placement conventions:

  1. File-level annotation: Place at the top of the file, after any shebang line or file header comment
  2. Block-level annotation: Place immediately above the code block it describes
  3. Multiple annotations per file: Use for files with distinct workflow phases

Example placement in an R file:

#!/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")

Use the Edit tool to insert annotations into existing files without disturbing surrounding code.

Expected: Annotations inserted at appropriate locations in each source file.

On failure: If annotations break syntax highlighting in the editor, ensure the comment prefix is correct for the language. PUT annotations are standard comments and should not affect code execution.

Step 5: Validate Annotations

Run putior's validation to check annotation syntax and 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"))

Expected: All annotations parse without errors. The diagram shows a connected workflow. put_merge() fills in any gaps from auto-detection.

On failure: Common validation issues:

  • Missing closing quote: id:'name → id:'name'
  • Using double quotes inside: id:"name" → id:'name'
  • Duplicate IDs across files: each id must be unique across the entire scanned directory
  • Backslash continuation on the wrong line: the \ must be the last character before newline

Validation

  • Every annotated file has syntactically valid PUT annotations
  • put("./src/") returns a data frame with the expected number of nodes
  • No duplicate id values across the scanned directory
  • put_diagram() produces a connected flowchart (not all isolated nodes)
  • Multiline annotations (if used) parse correctly with backslash continuation
  • .internal variables appear only as outputs, never as cross-file inputs
  • Files excluded via exclude parameter do not appear in the workflow (e.g., put("./src/", exclude = "test_") skips test helpers)

Common Pitfalls

  • Quote nesting errors: PUT annotations use single quotes: id:'name'. Double quotes cause parsing issues when the annotation is inside a string context.
  • Duplicate IDs: Every id must be globally unique within the scanned scope. Use a naming convention like <script>_<step> (e.g., extract_read, transform_clean).
  • .internal as cross-file input: .internal variables exist only during script execution. To pass data between scripts, use a persisted file format (.rds, .csv, .parquet) as the output of one script and input of the next.
  • Missing connections: If the diagram shows disconnected nodes, check that output filenames in one annotation exactly match input filenames in another (including extensions).
  • Wrong comment prefix: Using # in a SQL file or // in Python will cause the annotation to be treated as code, not a comment. Always verify with get_comment_prefix().
  • Forgetting multiline continuation: When using multiline annotations, every continued line must end with \ and the next line must start with the comment prefix.
  • Python triple-quote strings: putior does not scan Python triple-quote strings (''' ''', """ """). Always use # for Python PUT annotations.
  • Meta-pipeline annotations: If you annotate a build script that also scans for annotations (e.g., a script that calls put() and put_diagram()), the script's own annotations will appear in the generated diagram. Either exclude the file from scanning (see generate-workflow-diagram Common Pitfalls) or avoid placing PUT annotations in the build script itself.

Related Skills

  • analyze-codebase-workflow — prerequisite: produces the annotation plan this skill follows
  • generate-workflow-diagram — next step: generate the final diagram from annotations
  • install-putior — putior must be installed before annotating
  • configure-putior-mcp — MCP tools provide interactive annotation assistance

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Execute structural metamorphosis using strangler fig migration, chrysalis phases, and interface preservation. Covers transformation planning, parallel running, progressive cutover, rollback design, and post-metamorphosis stabilization for system architecture evolution. Use when assess-form has classified the system as READY for transformation, when migrating from monolith to microservices, when replacing a core subsystem while dependents continue operating, or when any architectural change must be gradual rather than big-bang.

日本語の概要は準備中です。原文の説明を表示しています。

pjt222/agent-almanac372026年10月10日 更新

adaptic

無料

Master skill composing the 5-step synoptic cycle for panoramic synthesis across multiple domains. Orchestrates meditate, expand-awareness, observe, awareness, integrate-gestalt, and express-insight into a coherent process that produces unified understanding rather than sequential compromise. Use when a problem genuinely spans 3+ domains and the interactions between domains matter more than depth in any one, when sequential analysis feels like compromise rather than integration, or before major architectural decisions affecting multiple stakeholders.

日本語の概要は準備中です。原文の説明を表示しています。

pjt222/agent-almanac372026年10月10日 更新

Scaffold a new puzzle type across all 10+ pipeline integration points in jigsawR. Creates the core puzzle module, wires it into the unified pipeline (generation, positioning, rendering, adjacency), adds ggpuzzle geom/stat layers, updates DESCRIPTION and config.yml, extends the Shiny app, and creates a comprehensive test suite. Use when adding a completely new puzzle type to the package or following the 10-point integration checklist to ensure nothing is missed end-to-end.

日本語の概要は準備中です。原文の説明を表示しています。

pjt222/agent-almanac372026年10月10日 更新

Add Rcpp or RcppArmadillo integration to an R package for high-performance C++ code. Covers setup, writing C++ functions, RcppExports generation, testing compiled code, and debugging. Use when an R function is too slow and profiling confirms a bottleneck, when you need to interface with existing C/C++ libraries, or when implementing algorithms (loops, recursion, linear algebra) that benefit from compiled code.

日本語の概要は準備中です。原文の説明を表示しています。

pjt222/agent-almanac372026年10月10日 更新

aikido

無料

Practice aikido as a defensive martial art emphasizing harmony, redirection, and controlled resolution. Covers centering and grounding, ukemi (safe falling and rolling), core techniques (irimi-nage, shiho-nage, kote-gaeshi, ikkyo), blending and tai sabaki (body movement), randori (multiple attacker practice), weapons awareness, and applying principles off the mat. Use when learning a defensive martial art that prioritizes de-escalation, developing the ability to redirect aggression without causing unnecessary harm, building safe falling skills, or cultivating calm centeredness under physical pressure.

日本語の概要は準備中です。原文の説明を表示しています。

pjt222/agent-almanac372026年10月10日 更新

Analyze an arbitrary codebase to identify functions, APIs, and data sources suitable for exposure as MCP tools, producing a tool specification document. Use when planning an MCP server for an existing project, auditing a codebase before wrapping it as an AI-accessible tool surface, comparing what a codebase can do versus what is already exposed via MCP, or generating a tool spec to hand off to scaffold-mcp-server.

日本語の概要は準備中です。原文の説明を表示しています。

pjt222/agent-almanac372026年10月10日 更新

pjt222 のスキルをすべて見る

このスキルの問題を報告する