<< All versions

Skill v1.0.0

currentAutomated scan100/100
hydr0pon1c/skills-on-the-fly/22-47
──Details
PublishedNovember 21, 2026 at 04:49 AM
Content Hashsha256:f1fffadd1297fbae...
Git SHAfc2c0936b42a
──Files
Files (1 file, 8.5 KB)
SKILL.md8.5 KBactive
SKILL.md · 95 lines · 8.5 KB

metadata: version: "1.0.0"


SKILL.md

When to use

Use this skill when you need to sort spreadsheet data rows based on a custom grouping order defined by a helper column or list, while preserving the original row order within each group. The target contract typically involves:

  • Identifying a helper column (e.g., column J) that lists names or keys in a desired first-come-first‑shown order.
  • Sorting the rows so that entries matching names in the helper column appear first, in the same order as they appear in the helper column, and preserving their original source order within each group.
  • Entries not in the helper column are placed after all listed entries, preserving their original relative order.
  • Skipping empty cells, headers, and duplicate rows. Duplicates may be defined by a combination of two columns (e.g., identical values in columns B and C).
  • If the helper column is empty, fall back to alphabetical sorting (A–Z) of the relevant data column, still skipping empties, headers, and duplicates.
  • The final output is placed in a specific output range (e.g., columns G and H), sometimes with an additional requirement to sort the output by one of these columns (e.g., “sort only column H lowest to highest”).

Before acting, gather the following evidence from the spreadsheet:

  • Exact column letters and headers (especially the data column to sort, the helper column, and the output columns).
  • Row range containing data: find the header row and the first data row.
  • Whether the helper column is empty or has values.
  • How duplicates are defined (single column or combination of columns).
  • The exact output range (e.g., F2:H10) and whether it includes headers or only data.
  • Any conflicting or ambiguous instructions (e.g., a final sorting requirement that may override the helper-based order) – resolve by checking the example output structure in the spreadsheet content or by examining the answer_position range.

Possible Failure Modes

  1. Misidentifying output columns – Placing the unique key (e.g., the helper‑column value) instead of the associated data value in the first output column, or mixing up the order of output columns.
  2. Not handling duplicates correctly – Using only one column to detect duplicates when the specification requires a pair of columns (e.g., B and C together).
  3. Ignoring the “preserve original order within group” rule – Sorting all rows alphabetically within a helper group instead of keeping their source order.
  4. Forgetting to skip empty cells or header rows – Including header text or blank rows in the sort operation, causing misplaced or missing data.
  5. Incorrect fallback when helper column is empty – Not applying the alphabetical sort condition, or applying it when the helper column is non‑empty.
  6. Off‑by‑one row indexing – Starting the data range on the wrong row (e.g., row 1 instead of row 2) or writing output to the wrong starting cell.
  7. Conflicting final sorting requirement – Overlooking a final statement like “sort only column H lowest to highest” that would reorder the output rows, potentially contradicting the helper‑based order.
  8. Using the helper list order without normalizing – Treating the helper column as a single string of names instead of a list of values separated by rows.

Possible Procedures

  1. Understand the data layout
  • Load the workbook and identify the active sheet.
  • Locate the header row and the first data row.
  • Record column letters for: the data column to sort (e.g., B), the duplicate‑detection column(s) (e.g., B and C), the helper column (J), and the output columns (e.g., G and H).
  1. Parse the helper column
  • Read all values from the helper column (excluding the header row and any empty cells).
  • Preserve the order of first appearance.
  • If the helper column is empty, set a flag to fall back to alphabetical sorting.
  1. Collect source rows
  • Iterate over data rows from the first data row to the last row in the relevant source range (columns A–C or similar).
  • Skip rows where the data column (B) is empty or where the header row is included.
  • For duplicate detection: use a set of tuples (B_value, C_value). If the same pair appears again, skip that row entirely (keep only the first occurrence).
  1. Build the output list
  • For each unique row, determine its helper status:
  • If helper list is non‑empty, find the index of the row’s B value in the helper list (0‑based). If not found, assign a large number (e.g., len(helper_list) + index_of_row_in_source?).
  • Create a sort key tuple:
  • First element: helper index (small number for listed, large number for not listed) OR if helper empty, use a constant value (e.g., 0).
  • Second element: the original row index (to preserve source order within each group).
  • Sort the list of rows by this key.
  1. Handle the empty-helper fallback
  • If the helper column is empty, sort the rows alphabetically by the data column (B). Use a case‑insensitive or string‑based sort as appropriate. If values are numeric, sort numerically.
  • Still skip duplicates and empty cells as before.
  1. Apply any final sorting requirement
  • If the instruction explicitly says “sort only column H lowest to highest” (or similar), reorder the output rows by the value that will go into column H. This overrides the previous ordering.
  • If this seems to contradict the helper‑based order, verify the expected output by inspecting the spreadsheet content’s example output or the answer_position range.
  1. Write to output range
  • Determine the starting cell from answer_position (e.g., F2 for the first row, or G? check).
  • Write the sorted rows to the output columns (e.g., column G gets the name from column B, column H gets the ref from column C or the value that should be sorted).
  • If the output range includes a header row, leave it as is (do not overwrite).
  • Clear any leftover cells in the output range that are not filled by data (optional but safe).
  1. Recovery checks
  • After writing, reload the workbook and verify the exact content of the output range against the expected pattern from the spreadsheet content.
  • If the instruction seems ambiguous (e.g., two different sorting rules), re‑examine the task description and the answer_position to infer the intended logic.
  • Test with a small manual check: e.g., count how many rows are output vs. number of unique non‑empty rows.

Verification Checklist

  • [ ] Output range exactness: The code writes only to the cells specified in answer_position (e.g., F2:H10). No additional cells are modified.
  • [ ] Headers preserved: The header row(s) in the output range are not overwritten; data starts on the correct row.
  • [ ] Duplicates skipped: Rows with identical values in the defined duplicate columns appear only once in the output. Verified by checking a few known duplicates.
  • [ ] Empty cells skipped: Rows where the primary data column (B) is empty are omitted.
  • [ ] Helper-based order correct: If helper column has entries, rows matching the helper list appear first in the helper list’s order; non‑matching rows follow in their original order.
  • [ ] Within‑group order preserved: Within each helper‑matched group, the rows appear in the same order as they did in the source data.
  • [ ] Empty-helper fallback: When the helper column is empty, the output is sorted alphabetically (or numerically) by the data column, and no helper‑based ordering is applied.
  • [ ] Final sorting requirement honored: If the instruction includes a final sort on one column (e.g., “sort only column H lowest to highest”), the output rows are sorted accordingly (this may override previous ordering).
  • [ ] No copying from retrieved examples: All column references, row offsets, and values are derived from the target spreadsheet, not from any example.
  • [ ] Unrelated state preserved: Cells outside the answer_position are unchanged.
  • [ ] Recovery from ambiguity: If the instruction is internally contradictory (e.g., helper order vs. final sort), the agent has resolved the conflict by examining the spreadsheet content and answer_position, and documented the logic in comments.
  • [ ] Error handling: The code checks that required columns exist and that the helper column is not missing. If an error occurs (e.g., missing sheet), the code prints a clear message and does not produce a corrupted output.
All versions