@@ -632,6 +632,272 @@ def test_ai_skills_flag_appears_in_help(self):
632632 assert "agent skills" in plain .lower ()
633633
634634
635+ class TestHandoffsFieldInSkills :
636+ """Test handling of handoffs field in command templates for AI skills (ADO sync feature)."""
637+
638+ def test_skill_generation_with_handoffs_in_template (self , project_dir ):
639+ """Skills should generate successfully from templates containing handoffs field."""
640+ # Create template with handoffs
641+ cmds_dir = project_dir / ".claude" / "commands"
642+ cmds_dir .mkdir (parents = True )
643+
644+ (cmds_dir / "specify.md" ).write_text (
645+ "---\n "
646+ "description: Create specification\n "
647+ "handoffs:\n "
648+ " - label: Sync to Azure DevOps\n "
649+ " agent: speckit.adosync\n "
650+ " prompt: Sync user stories to ADO\n "
651+ " send: true\n "
652+ " - label: Build Plan\n "
653+ " agent: speckit.plan\n "
654+ " send: false\n "
655+ "---\n "
656+ "\n "
657+ "# Specify Command\n "
658+ "\n "
659+ "Create specs.\n " ,
660+ encoding = "utf-8" ,
661+ )
662+
663+ result = install_ai_skills (project_dir , "claude" )
664+
665+ assert result is True
666+ skill_file = project_dir / ".claude" / "skills" / "speckit-specify" / "SKILL.md"
667+ assert skill_file .exists ()
668+ content = skill_file .read_text ()
669+
670+ # Verify skill has valid structure
671+ assert "name: speckit-specify" in content
672+ assert "description:" in content
673+ # Body content should be preserved
674+ assert "Create specs." in content
675+
676+ def test_skill_generation_with_multiline_handoffs_prompt (self , project_dir ):
677+ """Skills should generate successfully from templates with multiline handoffs prompts."""
678+ cmds_dir = project_dir / ".claude" / "commands"
679+ cmds_dir .mkdir (parents = True )
680+
681+ (cmds_dir / "plan.md" ).write_text (
682+ "---\n "
683+ "description: Create plan\n "
684+ "handoffs:\n "
685+ " - label: Sync Tasks\n "
686+ " agent: speckit.adosync\n "
687+ " prompt: |\n "
688+ " Read the tasks.md file and show me all the tasks.\n "
689+ " Ask me which tasks I want to sync.\n "
690+ " Then create Task work items in Azure DevOps.\n "
691+ " send: true\n "
692+ "---\n "
693+ "\n "
694+ "# Plan\n "
695+ "\n "
696+ "Plan body.\n " ,
697+ encoding = "utf-8" ,
698+ )
699+
700+ result = install_ai_skills (project_dir , "claude" )
701+
702+ assert result is True
703+ skill_file = project_dir / ".claude" / "skills" / "speckit-plan" / "SKILL.md"
704+ content = skill_file .read_text ()
705+
706+ # Verify skill was generated successfully
707+ assert "name: speckit-plan" in content
708+ assert "Plan body." in content
709+
710+ def test_handoffs_field_parseable_in_generated_skill (self , project_dir ):
711+ """Generated SKILL.md should have valid parseable YAML regardless of source frontmatter."""
712+ cmds_dir = project_dir / ".claude" / "commands"
713+ cmds_dir .mkdir (parents = True )
714+
715+ (cmds_dir / "tasks.md" ).write_text (
716+ "---\n "
717+ "description: Generate tasks\n "
718+ "handoffs:\n "
719+ " - label: Sync to ADO\n "
720+ " agent: speckit.adosync\n "
721+ " prompt: Sync tasks to Azure DevOps\n "
722+ "---\n "
723+ "\n "
724+ "# Tasks\n "
725+ "\n "
726+ "Task content.\n " ,
727+ encoding = "utf-8" ,
728+ )
729+
730+ install_ai_skills (project_dir , "claude" )
731+
732+ skill_file = project_dir / ".claude" / "skills" / "speckit-tasks" / "SKILL.md"
733+ content = skill_file .read_text ()
734+
735+ # Extract and parse frontmatter to verify it's valid YAML
736+ parts = content .split ("---" , 2 )
737+ assert len (parts ) >= 3
738+ parsed = yaml .safe_load (parts [1 ])
739+
740+ # The generated SKILL.md should have agentskills.io compliant frontmatter
741+ assert isinstance (parsed , dict )
742+ assert "name" in parsed
743+ assert parsed ["name" ] == "speckit-tasks"
744+ assert "description" in parsed
745+ assert "compatibility" in parsed
746+
747+ # Body should be preserved
748+ assert "Task content." in content
749+
750+ def test_templates_with_handoffs_and_scripts_fields (self , project_dir ):
751+ """Skills should generate from templates with multiple complex fields like handoffs and scripts."""
752+ cmds_dir = project_dir / ".claude" / "commands"
753+ cmds_dir .mkdir (parents = True )
754+
755+ (cmds_dir / "specify.md" ).write_text (
756+ "---\n "
757+ "description: Spec command\n "
758+ "handoffs:\n "
759+ " - label: Sync to ADO\n "
760+ " agent: speckit.adosync\n "
761+ " prompt: |\n "
762+ " Sync user stories from spec.md.\n "
763+ " The spec file path is: {spec_file_path}\n "
764+ "scripts:\n "
765+ " sh: scripts/bash/create-new-feature.sh\n "
766+ " ps: scripts/powershell/create-new-feature.ps1\n "
767+ "---\n "
768+ "\n "
769+ "# Specify\n "
770+ "\n "
771+ "Command body.\n " ,
772+ encoding = "utf-8" ,
773+ )
774+
775+ install_ai_skills (project_dir , "claude" )
776+
777+ skill_file = project_dir / ".claude" / "skills" / "speckit-specify" / "SKILL.md"
778+ content = skill_file .read_text ()
779+
780+ # Skill should be generated successfully
781+ assert "name: speckit-specify" in content
782+ assert "Command body." in content
783+
784+ def test_multiple_handoffs_dont_break_skill_generation (self , project_dir ):
785+ """Templates with multiple handoffs should generate skills without errors."""
786+ cmds_dir = project_dir / ".claude" / "commands"
787+ cmds_dir .mkdir (parents = True )
788+
789+ (cmds_dir / "plan.md" ).write_text (
790+ "---\n "
791+ "description: Plan command\n "
792+ "handoffs:\n "
793+ " - label: Sync User Stories\n "
794+ " agent: speckit.adosync\n "
795+ " prompt: Sync user stories\n "
796+ " send: true\n "
797+ " - label: Sync Tasks\n "
798+ " agent: speckit.adosync\n "
799+ " prompt: Sync tasks with -FromTasks\n "
800+ " send: false\n "
801+ " - label: Create Checklist\n "
802+ " agent: speckit.checklist\n "
803+ " send: true\n "
804+ "---\n "
805+ "\n "
806+ "# Plan\n "
807+ "\n "
808+ "Planning content.\n " ,
809+ encoding = "utf-8" ,
810+ )
811+
812+ result = install_ai_skills (project_dir , "claude" )
813+
814+ assert result is True
815+ skill_file = project_dir / ".claude" / "skills" / "speckit-plan" / "SKILL.md"
816+ content = skill_file .read_text ()
817+
818+ # Skill should be generated with valid structure
819+ assert "name: speckit-plan" in content
820+ assert "Planning content." in content
821+
822+ def test_handoffs_field_optional_in_skills (self , project_dir ):
823+ """Commands without handoffs should still generate valid skills."""
824+ cmds_dir = project_dir / ".claude" / "commands"
825+ cmds_dir .mkdir (parents = True )
826+
827+ (cmds_dir / "legacy.md" ).write_text (
828+ "---\n "
829+ "description: Legacy command without handoffs\n "
830+ "---\n "
831+ "\n "
832+ "# Legacy Command\n " ,
833+ encoding = "utf-8" ,
834+ )
835+
836+ result = install_ai_skills (project_dir , "claude" )
837+
838+ assert result is True
839+ skill_file = project_dir / ".claude" / "skills" / "speckit-legacy" / "SKILL.md"
840+ assert skill_file .exists ()
841+ content = skill_file .read_text ()
842+
843+ # Should have valid structure without handoffs
844+ assert "name: speckit-legacy" in content
845+ assert "Legacy command without handoffs" in content
846+
847+ def test_empty_handoffs_array_in_skills (self , project_dir ):
848+ """Commands with empty handoffs array should generate valid skills."""
849+ cmds_dir = project_dir / ".claude" / "commands"
850+ cmds_dir .mkdir (parents = True )
851+
852+ (cmds_dir / "test.md" ).write_text (
853+ "---\n "
854+ "description: Test command\n "
855+ "handoffs: []\n "
856+ "---\n "
857+ "\n "
858+ "# Test\n " ,
859+ encoding = "utf-8" ,
860+ )
861+
862+ result = install_ai_skills (project_dir , "claude" )
863+
864+ assert result is True
865+ skill_file = project_dir / ".claude" / "skills" / "speckit-test" / "SKILL.md"
866+ content = skill_file .read_text ()
867+
868+ # Should handle empty handoffs gracefully
869+ assert "name: speckit-test" in content
870+
871+ def test_adosync_command_generates_skill (self , project_dir ):
872+ """The adosync command itself should generate a valid skill."""
873+ cmds_dir = project_dir / ".claude" / "commands"
874+ cmds_dir .mkdir (parents = True )
875+
876+ (cmds_dir / "adosync.md" ).write_text (
877+ "---\n "
878+ "description: Sync selected user stories or tasks to Azure DevOps\n "
879+ "scripts:\n "
880+ " sh: scripts/bash/create-ado-workitems.sh\n "
881+ " ps: scripts/powershell/create-ado-workitems.ps1\n "
882+ "---\n "
883+ "\n "
884+ "# ADO Sync Command\n "
885+ "\n "
886+ "Sync to Azure DevOps.\n " ,
887+ encoding = "utf-8" ,
888+ )
889+
890+ result = install_ai_skills (project_dir , "claude" )
891+
892+ assert result is True
893+ skill_file = project_dir / ".claude" / "skills" / "speckit-adosync" / "SKILL.md"
894+ assert skill_file .exists ()
895+ content = skill_file .read_text ()
896+
897+ assert "name: speckit-adosync" in content
898+ assert "Azure DevOps" in content
899+
900+
635901class TestParameterOrderingIssue :
636902 """Test fix for GitHub issue #1641: parameter ordering issues."""
637903
0 commit comments