mcpbeat Sign in

Code Completion Semantic Constraints Agent Skill

Automatically complete partial code snippets while satisfying semantic constraints including variable types, invariants, pre/post-conditions, interface contracts, and expected input/output behavior. Use when users provide incomplete code with specific requirements like "complete this function that takes a list and returns sorted unique elements" or "fill in this method body that must maintain the invariant that x stays positive" or "implement this interface method with these type constraints." Produces compilable, executable code with tests and a constraint satisfaction report.

1k tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
141
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill code-completion-semantic-constraints

The instruction itself

14 sections, as written by the author

Code Completion with Semantic Constraints

Overview

Complete partial code snippets while satisfying specified semantic constraints. Produces compilable code, verification tests, and a detailed report explaining how each constraint was satisfied.

Workflow

1. Parse Input

Extract and categorize the provided information:

Partial Code: Identify the incomplete code structure (function signature, class skeleton, method stub, etc.)

Semantic Constraints: Categorize constraints by type:

  • Type constraints: Variable types, return types, generic bounds
  • Invariants: Pre-conditions, post-conditions, loop invariants
  • Behavioral constraints: Expected input/output pairs, edge case handling
  • Interface contracts: Method signatures, protocol conformance
  • Performance constraints: Time/space complexity requirements

2. Analyze Constraints

For each constraint:

  • Determine if it's satisfiable
  • Identify dependencies between constraints
  • Note any conflicts or ambiguities
  • If constraints are unclear or conflicting, ask for clarification before proceeding

3. Complete the Code

Generate code that:

  • Compiles without errors in the target language
  • Satisfies all specified constraints
  • Follows language idioms and best practices
  • Includes necessary imports, type annotations, and error handling
  • Uses minimal complexity (avoid over-engineering)

4. Generate Verification Tests

Create minimal test cases that verify:

  • Type constraints are respected
  • Pre-conditions and post-conditions hold
  • Expected input/output behavior is correct
  • Edge cases are handled properly
  • Performance constraints are met (if specified)

5. Produce Constraint Satisfaction Report

Document how each constraint was satisfied:

  • Map each constraint to the code that satisfies it
  • Explain the reasoning for implementation choices
  • Note any assumptions made
  • Highlight any constraints that required trade-offs

Examples

Example 1: Type and Behavioral Constraints

Input:

def process_items(items):
    # TODO: complete this function
    pass

Constraints:

  • items is a list of integers
  • Return a list of unique integers in ascending order
  • Handle empty list (return empty list)
  • Time complexity: O(n log n)

Output: Completed function with sorting logic, tests for empty/normal/duplicate cases, and report explaining constraint satisfaction.

Example 2: Interface Contract

Input:

public class DataCache implements Cache {
    // TODO: implement required methods
}

Constraints:

  • Implement Cache interface (get, put, remove methods)
  • Thread-safe operations
  • LRU eviction policy with max size 100
  • Return null for missing keys

Output: Complete class implementation, concurrency tests, and report mapping each interface method to implementation.

Example 3: Invariant Preservation

Input:

void update_balance(Account* acc, int amount) {
    // TODO: complete
}

Constraints:

  • Pre-condition: acc != NULL && acc->balance >= 0
  • Post-condition: acc->balance >= 0 (balance never negative)
  • If amount would make balance negative, set to 0 instead

Output: Implementation with bounds checking, tests for edge cases, and report showing invariant preservation.

Output Format

Provide three components:

1. Completed Code

  • Fully compilable and executable
  • Includes necessary imports, type annotations, error handling
  • Follows language conventions

2. Verification Tests

  • Minimal test suite covering constraint verification
  • Include edge cases and boundary conditions
  • Use appropriate testing framework for the language

3. Constraint Satisfaction Report

  • Table or list mapping each constraint to implementation details
  • Explanation of design choices
  • Any assumptions or trade-offs made

Language Support

This skill works with any programming language. Adapt constraint types and verification approaches to language-specific features (e.g., type systems, contract programming, assertion libraries).

Other skills for the same job

different authors, same section of the catalogue
MCP Builder
by anthropics
vendor ×13

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

30k tokens scripts
Changelog Generator
by frostant
×9

Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.

774 tokens
Finishing A Development Branch
by ZhanlinCui
×7

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup

1k tokens
MCP Builder
by JayZeeDesign
×7

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

37k tokens scripts
Vercel React Native Skills
by vercel-labs
vendor ×6

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

39k tokens
Vercel React Best Practices
by ratacat
×5

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

34k tokens
Next Best Practices
by vercel-labs
vendor ×4

Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling

20k tokens
Using Git Worktrees
by ZhanlinCui
×4

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification

1k tokens

How to use it

Copy the folder

Take arabelatso/code-completion-semantic-constraints from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.