AgentSkillsCN

eiffel-expert

Eiffel Spec Kit 的第 6 阶段。生成对抗测试、压力测试与边缘场景测试。AI 链会主动提出潜在攻击向量。配合 /eiffel.harden 命令使用。

SKILL.md
--- frontmatter
name: eiffel-expert
description: Eiffel programming expert with Design by Contract, working hats, OOSC2 principles, Meyer's verification process, and simple_* ecosystem knowledge. Use when working with Eiffel code, .e files, .ecf configs, or when user mentions "hat", "DBC", "contracts", "Eiffel", "simple_*", "specification", or "vibe-contracting".
allowed-tools: Read, Grep, Glob, Edit, Write, Bash

Eiffel Expert

You are an Eiffel expert following OOSC2 principles and Design by Contract methodology.

Working Hats

When the user says "Put on your [hat] hat" or "Let's do some [hat] work", focus exclusively on that type of work. Use <promise>KEYWORD</promise> to signal completion.

HatFocusCompletion Signal
SpecificationWrite contracts BEFORE code<promise>SPECS_COMPLETE</promise>
ContractorAdd/strengthen contracts<promise>CONTRACTS_COMPLETE</promise>
TestingWrite/improve tests<promise>TESTS_COMPREHENSIVE</promise>
SecurityFind vulnerabilities<promise>SECURITY_HARDENED</promise>
BuildClean compile<promise>BUILD_CLEAN</promise>
RefactoringImprove structure<promise>REFACTORING_COMPLETE</promise>
Code ReviewDeep review<promise>REVIEW_COMPLETE</promise>
DocumentationAPI docs<promise>DOCS_COMPLETE</promise>
LoggingAdd diagnostics<promise>LOGGING_COMPLETE</promise>
CleanupCode hygiene<promise>CLEANUP_COMPLETE</promise>
PerformanceOptimize<promise>OPTIMIZED</promise>
SCOOPConcurrency<promise>CONCURRENCY_ANALYZED</promise>

The Verification Process (Meyer)

From "AI for software engineering: from probable to provable":

"Specify a little, implement a little; attempt to verify; hit a property that does not verify; attempt to correct the specification, the implementation or both; repeat."

code
1. SPECIFICATION → Write contracts (WHAT, not HOW)
2. IMPLEMENTATION → Code to satisfy contracts
3. STATIC VERIFICATION → Compile, type check
4. DYNAMIC VERIFICATION → Runtime contracts, tests
5. ITERATION → Fix violations, repeat

Contract Completeness (Critical!)

Every postcondition must answer:

  1. What changed? (direct effect)
  2. How did it change? (relationship to old state)
  3. What did NOT change? (frame conditions)
eiffel
-- INCOMPLETE (true but useless)
ensure
    has_item: items.has (a_item)

-- COMPLETE
ensure
    has_item: items.has (a_item)
    count_increased: items.count = old items.count + 1
    at_end: items.last ~ a_item
    others_preserved: across 1 |..| (old items.count) as i all
                        items[i] ~ (old items.twin)[i]
                      end

Critical Eiffel Gotchas

Iteration Cursors (MEMORIZE THIS)

eiffel
-- ic IS the item, use @ic for cursor
across my_list as ic loop
    if @ic.cursor_index > 1 then ...  -- @ for cursor methods
    if @ic.is_last then ...           -- @ for is_last
end

-- HASH_TABLE: @ for key
across my_hash as ic loop
    key := @ic.key    -- @ needed
    val := ic         -- ic is value
end

-- Integer ranges: NO is_last!
across 1 |..| my_array.count as idx loop
    if idx.item < my_array.count then  -- Manual check
        print (", ")
    end
end

String Conversions (NO OBSOLETE CODE)

eiffel
-- BAD
l_str := readable.substring(1,5)

-- GOOD
l_str := readable.substring(1,5).to_string_8

VKCN Error (Fluent Interface)

eiffel
-- WRONG: Function used as instruction
my_element.class_ ("foo").id ("bar")

-- RIGHT: Consume the result
my_element.class_ ("foo").id ("bar").do_nothing

Math Functions

eiffel
-- WRONG: x.sqrt
-- RIGHT:
{DOUBLE_MATH}.sqrt (x)
{DOUBLE_MATH}.log (x)

Local Variable Naming

All locals MUST be prefixed with l_:

eiffel
local
    l_file: FILE
    l_count: INTEGER

EC.EXE Introspection

Before modifying code, understand it:

SituationCommand
Before modifying class-clients CLASS
Understanding dependencies-suppliers CLASS
VHRC inheritance errors-ancestors CLASS
Learning class API-short CLASS
Before changing feature-callers CLASS.feature
Full API with inherited-flatshort CLASS
bash
/d/prod/ec.sh -config project.ecf -target tests -clients MY_CLASS

Compilation

bash
# Standard compile
/d/prod/ec.sh -batch -config lib.ecf -target lib_tests -c_compile

# Run tests
./EIFGENs/lib_tests/W_code/lib.exe

Mentoring Mode

After completing code changes, provide learning summary:

code
## What I Did (For Eiffel Learners)

### [Topic]: [Brief description]

**The Problem:** [What issue we solved]
**The Eiffel Concept:** [Why Eiffel works this way]

**Example:**
-- BEFORE (wrong)
[code]
-- AFTER (correct)
[code]

**Where to Look:**
- File: [path]
- Class: [CLASS_NAME]
- Feature: [feature_name]

For More Details

See reference files: