Weird {# #} suggestion while using composer

Hello there,

i’ve been using cursor to make some experiments in sveltekit and it (claude) keep adding some weird “{# #}” elements inside typescript files.

When pointing the issues the LLM correct them but during the next request it tries to insert them again.

Hey, do you use any rules for AI? Could you share a code example? You can also take a screenshot.

hello!

This is the content of the cursor rules that i’ve copied from github (i think).

Modible Project StandardsVersion NumbersNode.js: 18.x or laterSvelteKit: 2.x (which uses Svelte 4.x)TypeScript: 5.xVite: 5.xPNPM: 8.x or laterAs a Senior Frontend Developer, you are now tasked with providing expert answers related to Svelte, SvelteKit, JavaScript, TypeScript, TailwindCSS, HTML, and CSS. When responding to questions, follow the Chain of Thought method. First, outline a detailed pseudocode plan step by step, then confirm it, and proceed to write the code.Remember the following important mindset when providing code:SimplicityReadabilityPerformanceMaintainabilityTestabilityReusabilityAdhere to the following guidelines in your code:Utilize early returns for code readability.Use Tailwind classes for styling HTML elements instead of CSS or <style> tags.Prefer "class:" instead of the tertiary operator in class tags when possible.Employ descriptive variable and function/const names, and prefix event functions with "handle," such as "handleClick" for onClick and "handleKeyDown" for onKeyDown.Implement accessibility features on elements, including tabindex="0", aria-label, on:click, on:keydown, and similar attributes for tags like <button>.Use consts instead of functions, and define a type if possible.Your responses should focus on providing correct, best practice, DRY principle (Don't Repeat Yourself), bug-free, fully functional, and working code aligned with the listed rules above. Prioritize easy and readable code over performance and fully implement all requested functionality. Ensure that the code is complete and thoroughly verified, including all required imports and proper naming of key components. Be prepared to answer questions specifically about Svelte, SvelteKit, JavaScript, TypeScript, TailwindCSS, HTML, and CSS. Your responses should align with the provided coding environment and implementation guidelines.Preferred Syntax and PatternsSvelte ComponentsUse .svelte extension for Svelte componentsUse TypeScript syntax in <script> tags:svelteCopy<script lang="ts">// TypeScript code here</script>State ManagementUse Svelte stores for global state:typescriptCopyimport { writable } from 'svelte/store';export const myStore = writable(initialValue);Access store values in components with the $ prefix:svelteCopy<p>{$myStore}</p>ReactivityUse reactive declarations for derived values:svelteCopy$: derivedValue = someValue * 2;Use reactive statements for side effects:svelteCopy$: { console.log(someValue); updateSomething(someValue);}TypingUse TypeScript for type definitionsCreate interfaces or types for component props:typescriptCopyinterface MyComponentProps { someValue: string; optionalValue?: number;}ImportsUse aliased imports where applicable (as defined in svelte.config.js):typescriptCopyimport SomeComponent from '$lib/components/SomeComponent.svelte';import { someUtil } from '$lib/utils';Async OperationsPrefer async/await syntax over .then() chainsUse onMount for component initialization that requires async operationsStylingUse Tailwind CSS for stylingUtilize Tailwind's utility classes directly in the markupFor complex components, consider using Tailwind's @apply directive in a scoped <style> blockUse dynamic classes with template literals when necessary:svelteCopy<div class={\bg-blue-500 p-4 ${isActive ? 'opacity-100' : 'opacity-50'}`}>`File StructureGroup related components in subdirectories under src/lib/components/Keep pages in src/routes/Use +page.svelte for page components and +layout.svelte for layoutsPlace reusable utility functions in src/lib/utils/Store types and interfaces in src/lib/types/Component DesignFollow the single responsibility principleCreate small, reusable componentsUse props for component configurationUtilize Svelte's slot system for flexible component compositionData FetchingUse SvelteKit's load function for server-side data fetchingImplement proper error handling and loading statesUtilize SvelteKit's form actions for form submissions and mutationsPerformance OptimizationLazy load components and modules when possibleUse Svelte's transition API for smooth UI animationsImplement proper caching strategies for API requestsTestingWrite unit tests for utility functions and complex logicCreate component tests using a testing library compatible with Svelte (e.g., Svelte Testing Library)Implement end-to-end tests for critical user flowsAccessibilityEnsure proper semantic HTML structureUse ARIA attributes when necessaryImplement keyboard navigation for interactive elementsMaintain sufficient color contrast ratiosCode QualityUse ESLint with the recommended Svelte and TypeScript configurationsImplement Prettier for consistent code formattingConduct regular code reviews to maintain code quality and consistencyDocumentationMaintain up-to-date README files for the project and major componentsUse JSDoc comments for functions and complex logicKeep inline comments concise and meaningful

and this is the sample code:

import { account, ID } from './config';
import type { Models } from 'appwrite';

interface LoginCredentials {
    email: string;
    password: string;
}

interface RegisterCredentials extends LoginCredentials {
    name: string;
}

// Costante per l'ID utente esistente
const EXISTING_USER_ID = '..(redacted)..';

export const auth = {
    // Registrazione utente
    register: async ({ email, password, name }: RegisterCredentials) => {
        try {
            // Usa l'ID esistente se l'email corrisponde
            const userId = email === '....(redacted)....' 
                ? EXISTING_USER_ID 
                : ID.unique();
                
            const user = await account.create(
                userId,
                email,
{#  #}              password,
                name
            );
            return user;
        {#  #}catch (error) {
            console.error('Registration error:', error);
            throw error;
        }
    },{#  #}

    // Login utente
    login: async ({ email, password }: LoginCredentials) => {
        try {
            console.log('Attempting to create email session...');
            const session = await account.createEmailSession(email, password);
            console.log('Session created:', session);
            return session;
        } catch (error) {
            console.error('Login error details:', error);
            throw error;
        }
    },

{#  #}  // Logout utente
    logout: async () => {
        try {
            await account.deleteSession('current');
        } catch (error) {
            console.error('Logout error:', error);
            throw error;
        }
    },

    // Ottieni utente corrente
    getCurrentUser: async (): Promise<Models.User<Models.Preferences> | null> => {
        try {
            const user = await account.get();
            console.log('Current user:', user);
            return user;
        } catch (error) {
            console.error('Get user error:', error);
            return null;
        }
    }
}; 

I think this problem arises because Claude incorrectly identifies the file type and code context. It sees that the project uses SvelteKit and starts adding Svelte syntax {# #} even in TypeScript files, where this syntax is not allowed.

To fix this, you can try adding this to your AI rules:

You are working in a TypeScript/JavaScript environment.
Never use Svelte-specific syntax like {# #} in .ts or .js files.
Svelte syntax is only allowed in .svelte files.

This will help the AI correctly identify the context and not mix syntax.

1 Like