agentleFS
AWSKnown publisheraws/aws-lambda-dotnet/.agents/skills/new-event-source/SKILL.md

new-event-source

Skill1.7k starsChanged 7 months agoApache-2.0View on GitHub

Add a new AWS event source attribute (e.g., Kinesis, Kafka, MQ) to the Lambda .NET Annotations framework, including the attribute class, source generator integration, CloudFormation writer, unit tests, writer tests, source generator tests, and integration tests

Trending

Quiet since July.about the whole repository

Dec 2025: 1 mentionJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the aws/aws-lambda-dotnet repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about aws/aws-lambda-dotnet

The biggest 5 of 18 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 18

Talked about on GitHub (18 times).

On GitHub · 18

13 more on GitHub

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 3 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before starting, gather from the user:

    line 12
  2. Distinctive:

    Read these files to understand existing patterns before creating new ones:

    line 22
  3. Very specific:

    Add copyright header: // Copyright Amazon.com, Inc.

    line 35
  4. Very specific:

    All optional properties use nullable backing fields with Is<PropertyName>Set internal properties

    line 38
  5. Very specific:

    Use Regex("^[a-zA-Z0-9]+$") for ResourceName validation

    line 41
  6. Very specific:

    Add else if block for the new attribute type after the existing event attribute blocks.

    line 65
  7. Very specific:

    Add else if block mapping the attribute to the EventType enum value.

    line 71
  8. Very specific:

    Add descriptor with the next available AWSLambda0XXX ID for invalid attribute validation errors.

    line 77
  9. Very specific:

    Add Validate{ServiceName}Events() call in ValidateFunction method

    line 85
  10. Very specific:

    Create private Validate{ServiceName}Events() method that validates:

    line 86
  11. Distinctive:

    Add the new attribute name if the SyntaxReceiver filters by attribute name strings.

    line 101
  12. Very specific:

    Add case AttributeModel<{ServiceName}EventAttribute> in the event processing switch

    line 107
  13. Very specific:

    Create Process{ServiceName}Attribute() method that writes CF template properties

    line 108
  14. Very specific:

    Invalid event test spans: must reference exact line numbers in the .cs.error file

    line 192

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Adding a New Event Source to Lambda Annotations

This skill guides you through adding a complete new event source attribute to the AWS Lambda .NET Annotations framework. Use this when a user asks to add support for a new AWS event source like Kinesis, Kafka, MQ, etc.

Prerequisites

Before starting, gather from the user:

  1. Service name (e.g., "Kinesis", "Kafka", "MQ")
  2. Primary resource identifier (e.g., stream ARN, topic ARN, broker ARN)
  3. CloudFormation event type string (e.g., "Kinesis", "MSK", "MQ")
  4. Event class name from the corresponding Amazon.Lambda.*Events NuGet package (e.g., KinesisEvent)
  5. Optional properties the attribute should support (e.g., BatchSize, StartingPosition, Filters)
  6. Whether @ references use Fn::GetAtt or Ref — event source mappings use Fn::GetAtt, subscriptions use Ref

Reference Examples

Read these files to understand existing patterns before creating new ones:

  • SNS (simplest, subscription-based): Libraries/src/Amazon.Lambda.Annotations/SNS/SNSEventAttribute.cs
  • SQS (event source mapping with batching): Libraries/src/Amazon.Lambda.Annotations/SQS/SQSEventAttribute.cs
  • DynamoDB (stream-based): Libraries/src/Amazon.Lambda.Annotations/DynamoDB/DynamoDBEventAttribute.cs
  • S3 (notification-based): Libraries/src/Amazon.Lambda.Annotations/S3/S3EventAttribute.cs

Steps

Step 1: Create the Event Attribute Class

Create: Libraries/src/Amazon.Lambda.Annotations/{ServiceName}/{ServiceName}EventAttribute.cs

Key patterns:

  • Add copyright header: // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + // SPDX-License-Identifier: Apache-2.0
  • Inherit from Attribute with [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] (use AllowMultiple = false for event types where multiple triggers on the same function don't make sense, e.g., Schedule events)
  • Constructor takes the primary resource identifier as a required string parameter
  • All optional properties use nullable backing fields with Is<PropertyName>Set internal properties
  • Include auto-derived ResourceName property (strips @ prefix or extracts name from ARN)
  • Include internal List<string> Validate() method with all validation rules
  • Use Regex("^[a-zA-Z0-9]+$") for ResourceName validation

Step 2: Register Type Full Names

Modify: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/TypeFullNames.cs

Add constants:

public const string {ServiceName}EventAttribute = "Amazon.Lambda.Annotations.{ServiceName}.{ServiceName}EventAttribute";
public const string {ServiceName}Event = "Amazon.Lambda.{ServiceName}Events.{ServiceName}Event";

Also add to EventType enum if needed in Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/EventType.cs.

Step 3: Create the Attribute Builder

Create: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/{ServiceName}EventAttributeBuilder.cs

Extracts attribute data from Roslyn AttributeData. Use consistent else if chaining. Reference: SNSEventAttributeBuilder.cs.

Step 4: Register in AttributeModelBuilder

Modify: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/AttributeModelBuilder.cs

Add else if block for the new attribute type after the existing event attribute blocks.

Step 5: Register in EventTypeBuilder

Modify: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/EventTypeBuilder.cs

Add else if block mapping the attribute to the EventType enum value.

Step 6: Add DiagnosticDescriptor

Modify: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Diagnostics/DiagnosticDescriptors.cs

Add descriptor with the next available AWSLambda0XXX ID for invalid attribute validation errors.

Modify: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Diagnostics/AnalyzerReleases.Unshipped.md — add the new diagnostic ID.

Step 7: Add Validation in LambdaFunctionValidator

Modify: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Validation/LambdaFunctionValidator.cs

  1. Add Validate{ServiceName}Events() call in ValidateFunction method
  2. Create private Validate{ServiceName}Events() method that validates:
    • Attribute properties via Validate() method
    • Method parameters (first must be event type, optional second is ILambdaContext)
    • Return type (usually void or Task)

Step 8: Add Dependency Check

Modify: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Validation/LambdaFunctionValidator.cs

In ValidateDependencies, add check for Amazon.Lambda.{ServiceName}Events NuGet package.

Step 9: Check SyntaxReceiver

Check: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/SyntaxReceiver.cs

Add the new attribute name if the SyntaxReceiver filters by attribute name strings.

Step 10: Add CloudFormation Writer Logic

Modify: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Writers/CloudFormationWriter.cs

  1. Add case AttributeModel<{ServiceName}EventAttribute> in the event processing switch
  2. Create Process{ServiceName}Attribute() method that writes CF template properties
    • Event source mappings (SQS, DynamoDB, Kinesis): use Fn::GetAtt for @ references
    • Subscription events (SNS): use Ref for @ references
    • Track synced properties in metadata

Step 11: Create Attribute Unit Tests

Create: Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/{ServiceName}EventAttributeTests.cs

Cover: constructor, defaults, property tracking, ResourceName derivation, all validation paths. Reference: SQSEventAttributeTests.cs, DynamoDBEventAttributeTests.cs, SNSEventAttributeTests.cs.

Step 12: Create CloudFormation Writer Tests

Create: Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/WriterTests/{ServiceName}EventsTests.cs

This is a partial class CloudFormationWriterTests. Include tests for:

  1. Verify{ServiceName}EventAttributes_AreCorrectlyApplied — Theory with JSON/YAML and property combinations
  2. Verify{ServiceName}EventProperties_AreSyncedCorrectly — Synced properties update when attributes change
  3. SwitchBetweenArnAndRef_For{Resource} — ARN to @ reference switching
  4. Verify{Resource}CanBeSet_FromCloudFormationParameter — CF Parameters handling
  5. VerifyManuallySet{ServiceName}EventProperties_ArePreserved — Hand-edited template preservation

Reference: SQSEventsTests.cs, DynamoDBEventsTests.cs, SNSEventsTests.cs.

Step 13: Create Valid Event Examples + Source Generator Test

Create: Libraries/test/TestServerlessApp/{ServiceName}EventExamples/Valid{ServiceName}Events.cs.txt Create: Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/{ServiceName}/ (generated handler snapshots) Create: Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ServerlessTemplates/{serviceName}Events.template Modify: Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/SourceGeneratorTests.cs — add VerifyValid{ServiceName}Events() test

Step 14: Create Invalid Event Examples + Source Generator Test

Create: Libraries/test/TestServerlessApp/{ServiceName}EventExamples/Invalid{ServiceName}Events.cs.error

Cover: invalid property values, invalid params, invalid return type, multiple events, invalid ARN, invalid resource name.

Modify: Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/SourceGeneratorTests.cs — add VerifyInvalid{ServiceName}Events_ThrowsCompilationErrors() test with diagnostic assertions including line spans.

Step 15: Create Generated Code Snapshots

Create: Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/{ServiceName}/

Tip: Run the source generator once to get actual output, then use as snapshot.

Step 16: Create Integration Test

Create: Libraries/test/TestServerlessApp.IntegrationTests/{ServiceName}EventSourceMapping.cs Modify: Libraries/test/TestServerlessApp.IntegrationTests/IntegrationTestContextFixture.cs — resource lookup Modify: Libraries/test/TestServerlessApp.IntegrationTests/DeploymentScript.ps1 — if needed

Step 17: Update AnalyzerReleases.Unshipped.md

Modify: Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Diagnostics/AnalyzerReleases.Unshipped.md

File Map Summary

ActionFile Path
Createsrc/Amazon.Lambda.Annotations/{ServiceName}/{ServiceName}EventAttribute.cs
Modifysrc/Amazon.Lambda.Annotations.SourceGenerator/TypeFullNames.cs
Createsrc/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/{ServiceName}EventAttributeBuilder.cs
Modifysrc/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/AttributeModelBuilder.cs
Modifysrc/Amazon.Lambda.Annotations.SourceGenerator/Models/EventTypeBuilder.cs
Modifysrc/Amazon.Lambda.Annotations.SourceGenerator/Diagnostics/DiagnosticDescriptors.cs
Modifysrc/Amazon.Lambda.Annotations.SourceGenerator/Validation/LambdaFunctionValidator.cs
Modifysrc/Amazon.Lambda.Annotations.SourceGenerator/SyntaxReceiver.cs
Modifysrc/Amazon.Lambda.Annotations.SourceGenerator/Writers/CloudFormationWriter.cs
Modifysrc/Amazon.Lambda.Annotations.SourceGenerator/Diagnostics/AnalyzerReleases.Unshipped.md
Createtest/Amazon.Lambda.Annotations.SourceGenerators.Tests/{ServiceName}EventAttributeTests.cs
Createtest/Amazon.Lambda.Annotations.SourceGenerators.Tests/WriterTests/{ServiceName}EventsTests.cs
Createtest/TestServerlessApp/{ServiceName}EventExamples/Valid{ServiceName}Events.cs.txt
Createtest/TestServerlessApp/{ServiceName}EventExamples/Invalid{ServiceName}Events.cs.error
Createtest/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/{ServiceName}/
Createtest/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ServerlessTemplates/{serviceName}Events.template
Modifytest/Amazon.Lambda.Annotations.SourceGenerators.Tests/SourceGeneratorTests.cs
Createtest/TestServerlessApp.IntegrationTests/{ServiceName}EventSourceMapping.cs
Modifytest/TestServerlessApp.IntegrationTests/IntegrationTestContextFixture.cs

Important Conventions

  • Copyright header on every new .cs file
  • Consistent else if chaining in attribute builders (never if then if for the same loop)
  • Both JSON and YAML template formats must be tested in writer tests
  • Invalid event test spans must reference exact line numbers in the .cs.error file
  • .cs.txt extension for valid test files (prevents deployment)
  • .cs.error extension for invalid test files (prevents compilation)
  • Use enums instead of strings when you need to represent a fixed, known set of constants that do not change frequently (e.g., StartingPosition, AuthType, HttpApiVersion). Enums provide compile-time type safety, eliminate the need for manual string validation in the Validate() method, and prevent invalid values from being set. In attribute builders, enum values come through Roslyn's AttributeData as their underlying int value and must be cast accordingly (e.g., (MyEnum)(int)pair.Value.Value). When writing enum values to CloudFormation templates, use .ToString() to convert back to the string representation.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.