Skip to content

Instantly share code, notes, and snippets.

@lmmx
Last active November 1, 2024 18:17
Show Gist options
  • Save lmmx/b4e9577b544d12a54c9102adefc0a550 to your computer and use it in GitHub Desktop.
Save lmmx/b4e9577b544d12a54c9102adefc0a550 to your computer and use it in GitHub Desktop.
Custom instruction to make Claude Artifacts use persistent file identifiers and names

Custom instruction to make Claude Artifacts use persistent and distinct file identifiers in Projects

  • The title attribute of the <AntArtifact> XML tag becomes the file_name attribute when 'Add to Project' is clicked.
  • Since Claude defaults to a human-readable title (e.g. "Modified Web Page With New Features"), this will tend to change the filename in the Project
  • It's easier to keep a single file copy in your Project docs ("Project Knowledge") when the file names are persistent in this way
Click to show earlier versions

0.0.1

  • fix: Ensures file names are not changed upon Artifact update to a Project document

When updating an Artifact, always use its original identifier. For example, if the Artifact's identifier is "index" and its type is "html," keep using "index" and do not change it to something like "modified-index." Use the unsuffixed file stem (e.g., "index" not "index.html") as the identifier. Also, use this identifier as the title; don't change it to something like "Modified Index Page." This ensures the Artifact is properly overwritten in the project.

Version 0.0.2

  • fix: Ensures new Artifact titles do not clash with existing Project documents' file names

When updating an Artifact, always use its original identifier. For example, if the Artifact's identifier is "index" and its type is "html," keep using "index" and do not change it to something like "modified-index." Use the unsuffixed file stem (e.g., "index" not "index.html") as the identifier. Also, use this identifier as the title; don't change it to something like "Modified Index Page." This ensures the Artifact is properly overwritten in the project. When creating a brand new Artifact, rather than updating an existing one, ensure you do not use the same identifier/title as an existing doc. Check the file stem and type would not clash with an existing one (but if the file types differ then you can use the same stem, e.g. "index" CSS file and "index" HTML file would not collide due to the different file extensions when saved: "index.css" and "index.html" would be distinct files so the Artifacts are distinct too). Use your intuition on what to name new files, don't just resort to incrementing a file count imitating a file clash, for eample by changing a clashing "index" file stem to "index (2)" if it represents a HTML info page that could be titled as "info" instead.

Version 0.0.3

  • fix: Avoid inappropriately combining Artifacts and repeating them inline when they should reference the Artifact

When creating a new Artifact, first decide whether to update an existing Artifact or create a new one. Never combine multiple files into a single Artifact, as this produces invalid Project files. When updating an Artifact, always use its original identifier. For example, if the Artifact's identifier is "index" and its type is "html," keep using "index" and do not change it to something like "modified-index." Use the unsuffixed file stem (e.g., "index" not "index.html") as the identifier. Also, use this identifier as the title; don't change it to something like "Modified Index Page." This ensures the Artifact is properly overwritten in the project. When creating a brand new Artifact, rather than updating an existing one, ensure you do not use the same identifier/title as an existing doc. Check the file stem and type would not clash with an existing one (but if the file types differ then you can use the same stem, e.g. "index" CSS file and "index" HTML file would not collide due to the different file extensions when saved: "index.css" and "index.html" would be distinct files so the Artifacts are distinct too). Do not repeat the content of existing Artifacts inline when they should be referenced by the file location.

Version 0.0.4

  • refactor: Simplify verbose instructions
  • refactor: use bullet points to clarify behaviour when updating/creating Artifacts
  • refactor: separate paragraph for unconditional behaviour

When creating a new Artifact, decide if you need to update an existing Artifact in the Project's documents or create a new one. **Updating an Artifact:** Always use its original identifier. For example, if the Artifact's identifier is "index" and its type is "html," keep using "index" and do not change it to something like "modified-index." Use the unsuffixed file stem (e.g., "index" not "index.html") as the identifier. Also, use this identifier as the title; don't change it to something like "Modified Index Page." This ensures the Artifact is properly overwritten in the project. **Creating a New Artifact:** Ensure you do not use an existing identifier or title. Check that the file stem and type do not clash with an existing one. Different file types can use the same stem (e.g., "index.css" and "index.html" are distinct). In both cases (updating/creating Artifacts), never combine multiple files into a single Artifact to avoid invalid Project files. Do not repeat the content of existing Artifacts; reference the file location instead.

Version 0.0.5

  • fix: try to prevent inline repetition of component Artifacts that should be transcluded by file location reference

When creating a new Artifact, decide if you need to update an existing Artifact in the Project's documents or create a new one. **Updating an Artifact:** Always use its original identifier. For example, if the Artifact's identifier is "index" and its type is "html," keep using "index" and do not change it to something like "modified-index." Use the unsuffixed file stem (e.g., "index" not "index.html") as the identifier. Also, use this identifier as the title; don't change it to something like "Modified Index Page". This ensures the Artifact is properly overwritten in the project. **Creating a New Artifact:** Ensure you do not use an existing identifier or title. Check that the file stem and type do not clash with an existing one. Different file types can use the same stem (e.g., "index.css" and "index.html" are distinct). In both cases (updating/creating Artifacts), never combine multiple files into a single Artifact to avoid invalid Project files. When creating components for use in other files, make the component first and then reference its location in the Artifact it is to be transcluded into, rather than repeat the component content inline.

Version 0.0.6

  • fix: successfully prevent inlining of component Artifacts by requiring explicit request for an asset if it's ambiguous whether to make it inline
# Guidelines for Creating and Updating Artifacts

## General Principles

1. Before creating or updating artifacts, review the existing project structure and assets to understand their purposes and relationships.
2. When creating a new visual asset or file, assume it's distinct from existing assets unless explicitly stated otherwise.
3. If there's any ambiguity about whether to create a new artifact or update an existing one, ask for clarification.

## Creating a New Artifact

1. Ensure you do not use an existing identifier or title.
2. Check that the file stem and type do not clash with an existing one. Different file types can use the same stem (e.g., "index.css" and "index.html" are distinct).
3. Use specific and distinct naming for new assets to avoid confusion with existing ones.
4. When creating components for use in other files, make the component first and then reference its location in the Artifact it is to be transcluded into, rather than repeat the component content inline.

## Updating an Artifact

1. Always use its original identifier. For example, if the Artifact's identifier is "index" and its type is "html," keep using "index" and do not change it to something like "modified-index."
2. Use the unsuffixed file stem (e.g., "index" not "index.html") as the identifier.
3. Use this identifier as the title; don't change it to something like "Modified Index Page."
4. This ensures the Artifact is properly overwritten in the project.

## Important Notes

- Never combine multiple files into a single Artifact to avoid invalid Project files.
- Pay attention to the context provided in the request, including the intended use and placement of new assets.
- If a request involves creating a new asset that seems similar to an existing one, seek clarification about whether it should be a new file or an update to the existing one.

Remember, clear communication is key. If you're unsure about any aspect of creating or updating an artifact, it's always better to ask for more information or clarification.

Version 0.0.7

  • refactor: return to the single line markdown format that succeeded in v0.0.5
  • feat: add the following 3 new pieces of info that were introduced in v0.0.6 (to the end of the prompt)
    • Review the existing project structure and assets to understand their purposes and relationships.
    • Assume new visual assets or files are distinct from existing assets unless explicitly stated otherwise.
    • Pay attention to the context provided in the request, including the intended use and placement of new assets.
      • Note: this last one seems like a stupid thing to say, of course it is already "paying attention to the context"!

When creating a new Artifact, decide if you need to update an existing Artifact in the Project's documents or create a new one. **Updating an Artifact:** Always use its original identifier. For example, if the Artifact's identifier is "index" and its type is "html," keep using "index" and do not change it to something like "modified-index. Use the unsuffixed file stem (e.g., "index" not "index.html") as the identifier. Also, use this identifier as the title; don't change it to something like "Modified Index Page". This ensures the Artifact is properly overwritten in the project. **Creating a New Artifact:** Ensure you do not use an existing identifier or title. Check that the file stem and type do not clash with an existing one. Different file types can use the same stem (e.g., "index.css" and "index.html" are distinct). In both cases (updating/creating Artifacts), never combine multiple files into a single Artifact to avoid invalid Project files. When creating components for use in other files, make the component first and then reference its location in the Artifact it is to be transcluded into, rather than repeat the component content inline. Review the existing project structure and assets to understand their purposes and relationships. Assume new visual assets or files are distinct unless stated otherwise, and pay attention to the context provided in the request, including the intended use and placement of new assets.

[!WARNING] Bug (regression): identifiers and titles no longer match

Version 0.0.8

  • fix: reassert that identifier and title must match exactly

When creating a new Artifact, decide if you need to update an existing Artifact in the Project's documents or create a new one. **Updating an Artifact:** Always use its original identifier. For example, if the Artifact's identifier is "index" and its type is "html," keep using "index" and do not change it to something like "modified-index. Use the unsuffixed file stem (e.g., "index" not "index.html") as the identifier. Also, use this identifier as the title; don't change it to something like "Modified Index Page". This ensures the Artifact is properly overwritten in the project. **Creating a New Artifact:** Ensure you do not use an existing identifier or title. Check that the file stem and type do not clash with an existing one. Different file types can use the same stem (e.g., "index.css" and "index.html" are distinct). In both cases (updating/creating Artifacts), some rules should always be followed. The title and identifier must always be an exact match. Never combine multiple files into a single Artifact to avoid invalid Project files. When creating components for use in other files, make the component first and then reference its location in the Artifact it is to be transcluded into, rather than repeat the component content inline. Review the existing project structure and assets to understand their purposes and relationships. Assume new visual assets or files are distinct unless stated otherwise, and pay attention to the context provided in the request, including the intended use and placement of new assets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment