Skip to content

[refactoring] Extract Go Code Analysis Constraints into shared prompt skill #17751

@github-actions

Description

@github-actions

Skill Overview

At least 5 workflows contain a nearly word-for-word identical "Important Constraints" block and Serena project activation instructions in their prompt text. This prompt skill can be extracted into a shared component that provides the standard Go code analysis guidelines — covering file exclusions, directory focus, Serena activation steps, and common bash discovery commands.

Current Usage

This skill appears (as duplicated prompt text) in the following workflows:

  • typist.md (lines ~130–155: "Important Constraints" + "Phase 0: Setup and Activation")
  • semantic-function-refactor.md (lines ~95–115: "Important Constraints" + "Project Activation")
  • duplicate-code-detector.md (lines ~50–75: "Project Activation" + "Tool Usage Sequence")
  • daily-file-diet.md (lines ~145–165: "Analyze File Structure Using Serena" + activation)
  • sergo.md (lines ~80–110: "Serena Tool Usage Guide" + project activation)

Common Duplicated Text

All 5 workflows contain variants of this block (15–25 lines each):

## Important Constraints

1. **Only analyze `.go` files** — Ignore all other file types
2. **Skip test files** — Never analyze files ending in `_test.go`
3. **Focus on `pkg/` directory** — Primary analysis area
4. **Use Serena for semantic analysis** — Leverage the MCP server's capabilities

## Serena Project Activation

Use the `activate_project` tool before any analysis:

\`\`\`
Tool: activate_project
Args: { "path": "$\{\{ github.workspace }}" }
\`\`\`

Then use `get_symbols_overview` for file structure, `search_for_pattern` for code patterns,
and `find_referencing_symbols` for usage analysis.

Proposed Shared Component

File: .github/workflows/shared/go-analysis-constraints.md

Configuration: (frontmatter only, no tools — pure prompt skill)

---
# Pure prompt skill — no tools or steps
---

Markdown body (prompt skill):

## Go Code Analysis Constraints

When analyzing Go code in this repository, follow these constraints:

1. **Only analyze `.go` files** — Ignore all other file types (`.md`, `.yaml`, `.cjs`, `.sh`, etc.)
2. **Skip test files** — Never analyze or modify files ending in `_test.go`
3. **Focus on `pkg/` directory** — Primary analysis area for production code
4. **Exclude generated files** — Skip `*.lock.yml` and other auto-generated files
5. **Use Serena for semantic analysis** — Prefer LSP-backed analysis over text grep when possible

## Serena Project Activation

Before analyzing code, activate the Serena project:

\`\`\`
Tool: activate_project
Args: { "path": "$\{\{ github.workspace }}" }
\`\`\`

### Useful Serena Tools

| Tool | Purpose |
|------|---------|
| `get_symbols_overview` | Understand file structure |
| `search_for_pattern` | Find code patterns |
| `find_symbol` | Locate specific symbols |
| `find_referencing_symbols` | Trace symbol usage |
| `read_file` | Read file with LSP context |

## Go File Discovery

```bash
# All non-test Go files in pkg/
find pkg -name "*.go" ! -name "*_test.go" -type f | sort

# Largest files (candidates for refactoring)
find pkg -name "*.go" ! -name "*_test.go" -exec wc -l {} \; | sort -rn | head -20

# Files by package
find pkg/ -maxdepth 1 -ls

**Usage Example**:

```yaml
imports:
  - shared/mcp/serena-go.md           # Tool config
  - shared/go-analysis-constraints.md  # Prompt guidelines

Impact

  • Workflows affected: 5+ workflows
  • Lines saved: ~20–30 lines of prompt text per workflow = ~100–150 lines total
  • Consistency benefit: All Go analysis workflows use the same file discovery commands, constraint wording, and Serena activation pattern — reducing subtle inconsistencies between workflows
  • Discoverability: New workflow authors have a clear reference for Go analysis best practices

Implementation Plan

  1. Create .github/workflows/shared/go-analysis-constraints.md with standardized constraint text
  2. Update typist.md to import the shared component and remove duplicated text
  3. Update semantic-function-refactor.md to import and remove duplicated text
  4. Update duplicate-code-detector.md to import and remove duplicated text
  5. Update daily-file-diet.md to import and remove duplicated text
  6. Update sergo.md to import and remove duplicated text
  7. Run make recompile to regenerate all lock files
  8. Verify all workflows compile correctly

Related Analysis

This recommendation comes from the Workflow Skill Extractor analysis run on 2026-02-22.

See full analysis report in the linked discussion.

Generated by Workflow Skill Extractor

  • expires on Feb 24, 2026, 4:19 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions